:root {
  color-scheme: dark;
  font-family: Inter, "Segoe UI", sans-serif;
  font-size: 13px;
  background: #020617;
  color: #e2e8f0;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top, rgba(59, 130, 246, 0.22), transparent 30%),
    linear-gradient(180deg, #020617 0%, #0f172a 100%);
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  border: 0;
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 12px;
  cursor: pointer;
  background: #2563eb;
  color: #fff;
  transition: transform 0.15s ease, opacity 0.15s ease;
}

button:hover {
  transform: translateY(-1px);
}

button.secondary {
  background: rgba(148, 163, 184, 0.18);
  color: #e2e8f0;
}

button.secondary.danger {
  background: rgba(239, 68, 68, 0.2);
  color: #fca5a5;
}

button.secondary.danger:hover:not(:disabled) {
  background: rgba(239, 68, 68, 0.35);
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.app-shell {
  padding: 12px;
}

.hero {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 12px;
}

.hero h1 {
  margin: 0 0 2px;
  font-size: 17px;
  font-weight: 600;
}

.hero p {
  margin: 0;
  max-width: 760px;
  font-size: 13px;
  color: #94a3b8;
  line-height: 1.5;
}

.badge {
  padding: 5px 10px;
  font-size: 12px;
  border: 1px solid rgba(96, 165, 250, 0.35);
  border-radius: 999px;
  color: #93c5fd;
  white-space: nowrap;
}

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}

.checkbox-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
}

.hint {
  margin: 6px 0 0;
  font-size: 0.9em;
  color: #94a3b8;
  line-height: 1.4;
}

.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.tab-btn {
  padding: 5px 10px;
  font-size: 12px;
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid rgba(148, 163, 184, 0.15);
  color: #cbd5e1;
}

.tab-btn.active {
  background: #2563eb;
  color: #fff;
}

.grid {
  display: grid;
  grid-template-columns: minmax(380px, 1.15fr) minmax(360px, 0.85fr);
  gap: 14px;
}

.prices-grid {
  grid-template-columns: minmax(380px, 1fr) minmax(320px, 1fr);
}

.prices-filters-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.panel {
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid rgba(148, 163, 184, 0.15);
  border-radius: 10px;
  padding: 12px;
  box-shadow: 0 10px 32px rgba(2, 6, 23, 0.22);
  backdrop-filter: blur(12px);
}

.nested-panel {
  background: rgba(2, 6, 23, 0.35);
  border: 1px solid rgba(148, 163, 184, 0.1);
  box-shadow: none;
}

.panel h2,
.panel h3 {
  margin: 0 0 8px;
  font-size: 0.95rem;
  font-weight: 600;
}

.stack {
  display: grid;
  gap: 8px;
}

.field {
  display: grid;
  gap: 6px;
}

.field label {
  font-size: 13px;
  color: #cbd5e1;
}

.field input,
.field textarea,
.field select {
  width: 100%;
  font-size: 13px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.9);
  color: #e2e8f0;
  padding: 8px 10px;
  outline: none;
}

.field textarea {
  min-height: 160px;
  resize: vertical;
}

.field small {
  font-size: 12px;
  color: #94a3b8;
  line-height: 1.45;
}

.table-wrap {
  overflow: auto;
  border: 1px solid rgba(148, 163, 184, 0.12);
  border-radius: 10px;
  background: rgba(2, 6, 23, 0.55);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 960px;
  font-size: 13px;
}

.data-table th,
.data-table td {
  padding: 8px 10px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.1);
  text-align: left;
  vertical-align: top;
}

.data-table th {
  position: sticky;
  top: 0;
  background: rgba(15, 23, 42, 0.96);
  z-index: 1;
  color: #cbd5e1;
  font-weight: 600;
}

.data-table tr:nth-child(even) td {
  background: rgba(15, 23, 42, 0.2);
}

.cell-input {
  width: 120px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.9);
  color: #e2e8f0;
  padding: 8px 10px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.cell-input.dirty {
  border-color: rgba(250, 204, 21, 0.7);
}

.cell-input.saving {
  border-color: rgba(96, 165, 250, 0.85);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.18);
}

.cell-input.save-ok {
  border-color: rgba(74, 222, 128, 0.8);
  background: rgba(20, 83, 45, 0.22);
}

.cell-input.save-error {
  border-color: rgba(248, 113, 113, 0.8);
  background: rgba(127, 29, 29, 0.22);
}

.prewrap-cell {
  white-space: pre-wrap;
  line-height: 1.4;
  color: #94a3b8;
  max-width: 420px;
}

.table-empty {
  color: #94a3b8;
  text-align: center;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.toolbar.spread {
  justify-content: space-between;
}

.snapshot-head {
  align-items: center;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.stats.stats-wide {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.stat-card {
  padding: 6px 10px;
  border-radius: 8px;
  background: rgba(30, 41, 59, 0.7);
  border: 1px solid rgba(148, 163, 184, 0.12);
}

.stat-card .label {
  color: #94a3b8;
  font-size: 11px;
  margin-bottom: 2px;
}

.stat-card .value {
  font-size: 15px;
  font-weight: 700;
}

.message {
  padding: 10px 12px;
  font-size: 13px;
  border-radius: 10px;
  line-height: 1.5;
}

.message.error {
  background: rgba(127, 29, 29, 0.4);
  border: 1px solid rgba(248, 113, 113, 0.35);
  color: #fecaca;
}

.message.success {
  background: rgba(20, 83, 45, 0.38);
  border: 1px solid rgba(74, 222, 128, 0.32);
  color: #bbf7d0;
}

.list {
  display: grid;
  gap: 8px;
  max-height: 360px;
  overflow: auto;
}

.list.list-tall {
  max-height: 560px;
}

.item {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.14);
  background: rgba(15, 23, 42, 0.7);
}

.item--incomplete-prices {
  border-left: 4px solid #eab308;
}

.item-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  align-items: center;
}

.item-title {
  font-weight: 600;
  word-break: break-all;
}

.item-meta {
  color: #94a3b8;
  font-size: 13px;
}

.item-meta.prewrap {
  white-space: pre-wrap;
  line-height: 1.45;
  margin-top: 6px;
}

.item-actions {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}

.item-actions button {
  padding: 4px 8px;
  font-size: 11px;
  border-radius: 6px;
}

.pill {
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 11px;
  border: 1px solid transparent;
}

.pill.ok {
  color: #86efac;
  background: rgba(20, 83, 45, 0.36);
  border-color: rgba(74, 222, 128, 0.18);
}

.pill.bad {
  color: #fca5a5;
  background: rgba(127, 29, 29, 0.34);
  border-color: rgba(248, 113, 113, 0.18);
}

.cookie-block {
  font-family: Consolas, "Courier New", monospace;
  font-size: 11px;
  line-height: 1.5;
  max-height: 180px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  padding: 10px;
  border-radius: 10px;
  background: rgba(2, 6, 23, 0.7);
  border: 1px solid rgba(148, 163, 184, 0.12);
}

.mono {
  font-family: Consolas, "Courier New", monospace;
  word-break: break-all;
}

.snapshot-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(320px, 0.8fr);
  gap: 14px;
}

.ads-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(148, 163, 184, 0.1);
  margin-bottom: 10px;
}

.ads-filters .field {
  min-width: 0;
}

.ads-filters .field label {
  font-size: 12px;
}

.ads-filters input[type="text"],
.ads-filters input[type="number"],
.ads-filters input[type="date"] {
  width: 100%;
  min-width: 90px;
  padding: 6px 8px;
  font-size: 13px;
}

.ads-filters #adsFilterAdId {
  min-width: 120px;
}

.ads-filters #adsFilterPriceMin,
.ads-filters #adsFilterPriceMax {
  width: 100px;
  min-width: 80px;
}

.ads-filters #adsFilterReset {
  flex-shrink: 0;
}

.ads-feed-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.ad-card {
  display: grid;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.14);
  background: rgba(15, 23, 42, 0.7);
}

.ad-card--profitable {
  border-left: 4px solid #4ade80;
}

.ad-card--incomplete-prices {
  border-left: 4px solid #eab308;
}

.ad-card--unprofitable {
  border-left: 4px solid #f87171;
}

.ad-photo-wrap {
  position: relative;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-radius: 12px;
  background: rgba(30, 41, 59, 0.7);
}

.ad-profit-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  font-size: 12px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
  pointer-events: none;
  line-height: 1.3;
}

.ad-profit-badge--pos {
  background: rgba(15, 23, 42, 0.75);
  color: #4ade80;
  border: 1px solid rgba(74, 222, 128, 0.4);
}

.ad-profit-badge--neg {
  background: rgba(15, 23, 42, 0.75);
  color: #f87171;
  border: 1px solid rgba(248, 113, 113, 0.4);
}

.ad-fav-btn {
  position: absolute;
  bottom: 8px;
  right: 8px;
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 50%;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  color: rgba(255, 255, 255, 0.4);
  transition: color 0.15s, background 0.15s;
}

.ad-fav-btn:hover {
  background: rgba(15, 23, 42, 0.9);
  color: #f87171;
}

.ad-fav-btn--active {
  color: #f87171;
  border-color: rgba(248, 113, 113, 0.5);
}

.ad-photo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.ad-photo-placeholder {
  display: grid;
  place-items: center;
  color: #94a3b8;
}

.ad-card-body {
  display: grid;
  gap: 8px;
}

.ad-price {
  font-size: 15px;
  font-weight: 600;
  color: #f8fafc;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px;
}

.ad-price-listing {
  font-size: 17px;
  font-weight: 700;
}

.ad-price-sep {
  color: #64748b;
  font-weight: 400;
}

.ad-price-market {
  color: #94a3b8;
}

.ad-profit-positive {
  color: #4ade80;
  font-size: 13px;
  font-weight: 600;
}

.ad-profit-negative {
  color: #f87171;
  font-size: 13px;
  font-weight: 600;
}

.ad-location {
  font-size: 11px;
  color: #64748b;
  margin-top: 1px;
}

.ad-condition {
  font-size: 12px;
  color: #94a3b8;
  font-weight: 500;
}

.ad-components {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 2px;
}

.ad-comp-chip {
  font-size: 10px;
  font-weight: 500;
  padding: 2px 6px;
  border-radius: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.ad-comp-chip--ok {
  background: rgba(74, 222, 128, 0.1);
  color: #86efac;
  border: 1px solid rgba(74, 222, 128, 0.25);
}

.ad-comp-chip--miss {
  background: rgba(234, 179, 8, 0.1);
  color: #fde047;
  border: 1px solid rgba(234, 179, 8, 0.25);
}

.ad-profit-line {
  font-size: 13px;
  font-weight: 600;
  margin-top: -2px;
}

.log-console {
  min-height: 420px;
  max-height: 520px;
  overflow: auto;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.12);
  background: rgba(2, 6, 23, 0.7);
  padding: 10px;
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
  line-height: 1.5;
}

.log-console-compact {
  min-height: 120px;
  max-height: 180px;
}

.ads-mini-log {
  display: grid;
  gap: 8px;
}

.log-line {
  display: flex;
  gap: 6px;
  align-items: baseline;
  padding: 3px 6px 3px 8px;
  border-left: 3px solid transparent;
  border-bottom: 1px solid rgba(255,255,255,0.03);
  word-break: break-word;
}

.log-line:last-child { border-bottom: 0; }

/* Цветная полоса слева по уровню */
.log-line.info    { border-left-color: #3b82f6; }
.log-line.success { border-left-color: #22c55e; }
.log-line.warn    { border-left-color: #f59e0b; background: rgba(245,158,11,0.05); }
.log-line.error   { border-left-color: #ef4444; background: rgba(239,68,68,0.07); }

/* Строки с выгодой — особая подсветка */
.log-line.profit  { border-left-color: #fbbf24; background: rgba(34,197,94,0.08); }
.log-line.profit .log-message { color: #86efac; font-weight: 600; }

/* Отступы для вложенных записей */
.log-line.indent-1 { padding-left: 20px; }
.log-line.indent-2 { padding-left: 32px; }

.log-ts {
  color: #475569;
  font-size: 0.72em;
  white-space: nowrap;
  flex-shrink: 0;
  min-width: 58px;
}

/* Бейджи источника */
.log-badge {
  font-size: 0.65em;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 3px;
  white-space: nowrap;
  flex-shrink: 0;
  letter-spacing: 0.03em;
}
.log-badge.pc     { background: #1e3a8a; color: #93c5fd; }
.log-badge.laptop { background: #4c1d95; color: #c4b5fd; }

/* Иконка уровня */
.log-icon {
  flex-shrink: 0;
  width: 14px;
  text-align: center;
  font-style: normal;
}
.log-line.info    .log-icon { color: #60a5fa; }
.log-line.success .log-icon { color: #4ade80; }
.log-line.warn    .log-icon { color: #fbbf24; }
.log-line.error   .log-icon { color: #f87171; }

.log-message {
  flex: 1;
  color: #e2e8f0;
  line-height: 1.45;
}

.log-extra {
  font-size: 0.85em;
  color: #64748b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}

/* Оставляем для совместимости со snapshot-логами */
.log-level { font-weight: 700; }

.helper-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.muted {
  color: #94a3b8;
}

.empty {
  color: #94a3b8;
  font-size: 13px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.45);
  border: 1px dashed rgba(148, 163, 184, 0.2);
}

.hidden {
  display: none !important;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  box-sizing: border-box;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(2, 6, 23, 0.82);
  backdrop-filter: blur(8px);
  cursor: pointer;
}

.modal-box {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border-radius: 20px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  background: rgba(15, 23, 42, 0.95);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.5);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.15);
  flex-shrink: 0;
}

.modal-header h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
}

.modal-close {
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 8px;
  font-size: 18px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  background: rgba(148, 163, 184, 0.15);
  color: #e2e8f0;
  border: 0;
}

.modal-close:hover {
  background: rgba(148, 163, 184, 0.25);
}

.modal-body {
  overflow: auto;
  padding: 14px;
  font-size: 13px;
  flex: 1;
  min-height: 0;
}

.ad-detail-content {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.ad-detail-head {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 16px;
  align-items: start;
}

.ad-detail-photo {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 12px;
  background: rgba(30, 41, 59, 0.7);
}

.ad-detail-meta {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ad-detail-title {
  margin: 0;
  font-size: 17px;
  line-height: 1.35;
  word-break: break-word;
}

.ad-detail-price {
  font-size: 18px;
  font-weight: 700;
  color: #f8fafc;
}

.ad-detail-row {
  font-size: 14px;
  color: #94a3b8;
}

.ad-detail-label {
  color: #cbd5e1;
  margin-right: 6px;
}

.ad-detail-block h5 {
  margin: 0 0 10px;
  font-size: 14px;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.ad-detail-block.ad-detail-missing-prices {
  border-left: 4px solid #eab308;
  background: rgba(234, 179, 8, 0.06);
}

.ad-detail-list {
  margin: 0 0 10px;
  padding-left: 20px;
  color: #e2e8f0;
  line-height: 1.5;
}

.ad-detail-pre {
  white-space: pre-wrap;
  font-size: 13px;
  line-height: 1.5;
  color: #94a3b8;
  padding: 12px;
  border-radius: 10px;
  background: rgba(2, 6, 23, 0.6);
  border: 1px solid rgba(148, 163, 184, 0.1);
}

.ad-detail-description {
  white-space: pre-wrap;
  line-height: 1.55;
  color: #e2e8f0;
  font-size: 14px;
}

.ad-detail-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  padding-top: 8px;
  border-top: 1px solid rgba(148, 163, 184, 0.12);
}

/* ── Нижняя навигация (мобильная) ─────────────────────────────────────── */
.mobile-bottom-nav {
  display: none;
}

.mobile-nav-btn {
  flex: 0 0 auto;
  min-width: 58px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 6px 8px;
  border: none;
  background: none;
  color: #64748b;
  font-size: 10px;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.15s;
  position: relative;
  line-height: 1.2;
  -webkit-tap-highlight-color: transparent;
  min-height: unset;
}

.mobile-nav-btn.active { color: #3b82f6; }

.mobile-nav-icon {
  font-size: 18px;
  line-height: 1;
  display: block;
}

.mobile-nav-badge {
  position: absolute;
  top: 5px;
  right: 8px;
  width: 8px;
  height: 8px;
  background: #22c55e;
  border-radius: 50%;
  border: 2px solid #0f172a;
  display: none;
}

.mobile-nav-btn.running .mobile-nav-badge {
  display: block;
  animation: mobile-badge-pulse 1.5s ease-in-out infinite;
}

@keyframes mobile-badge-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

/* ── Лайтбокс для фото ────────────────────────────────────────────────── */
.photo-lightbox {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.96);
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  cursor: pointer;
}

.photo-lightbox.hidden { display: none; }

.photo-lightbox img {
  max-width: 100%;
  max-height: 90vh;
  border-radius: 10px;
  object-fit: contain;
  pointer-events: none;
}

.photo-lightbox-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  border: none;
  color: #fff;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── Поиск по объявлениям ─────────────────────────────────────────────── */
.ads-search-bar {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 14px;
  font-size: 15px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  background: var(--bg-input, var(--bg));
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
}
.ads-search-bar:focus {
  border-color: var(--accent, #6366f1);
}

/* ── Фильтры с тоглом ─────────────────────────────────────────────────── */
.ads-filters-toggle {
  display: none;
}

.ads-filters-wrap {
  display: contents;
}

/* ── Лог с тоглом ─────────────────────────────────────────────────────── */
.log-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}

.log-section-header h3 { margin: 0; }

.log-toggle-btn {
  display: none;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  font-size: 12px;
  color: #64748b;
  background: none;
  border: 1px solid rgba(148,163,184,0.15);
  border-radius: 6px;
  cursor: pointer;
  min-height: unset;
}

.log-toggle-icon {
  display: inline-block;
  transition: transform 0.2s ease;
  font-style: normal;
}

.log-section.collapsed .log-console { display: none; }
.log-section.collapsed .log-toggle-icon { transform: rotate(-90deg); }

@media (max-width: 1180px) {
  .grid {
    grid-template-columns: 1fr;
  }

  .snapshot-grid {
    grid-template-columns: 1fr;
  }

  .hero {
    flex-direction: column;
  }

  .helper-grid {
    grid-template-columns: 1fr;
  }

  .prices-filters-grid {
    grid-template-columns: 1fr;
  }
}

/* Полоска прогресса при «Обновить все цены» */
.recalc-progress-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
  margin-bottom: 4px;
}
.recalc-progress-bar {
  flex: 1;
  height: 6px;
  background: rgba(148, 163, 184, 0.2);
  border-radius: 3px;
  overflow: hidden;
}
.recalc-progress-fill {
  height: 100%;
  width: 0%;
  background: #2563eb;
  border-radius: 3px;
  transition: width 0.15s ease;
}
.recalc-progress-text {
  font-size: 11px;
  color: #94a3b8;
  min-width: 4em;
}

/* ── Мобильная версия (телефон) ───────────────────────────────────────────── */
@media (max-width: 700px) {
  :root { font-size: 12px; }

  /* Скрываем верхние табы — нижняя навигация заменяет */
  .tabs { display: none; }

  .mobile-bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 56px;
    background: #0f172a;
    border-top: 1px solid rgba(148, 163, 184, 0.15);
    z-index: 500;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .mobile-bottom-nav::-webkit-scrollbar { display: none; }

  /* Отступ снизу под навигацию */
  .app-shell { padding: 8px 8px 68px; }

  /* Prevent iOS zoom on input focus */
  input:not([type="checkbox"]):not([type="radio"]),
  textarea,
  select {
    font-size: 16px !important;
  }

  /* Tap targets — минимум 44px */
  button {
    min-height: 44px;
    padding: 8px 12px;
    font-size: 13px;
  }

  /* Sticky строка кнопок Старт/Стоп */
  .snapshot-head {
    position: sticky;
    top: 0;
    z-index: 10;
    background: #0c1322;
    margin: -8px -8px 0;
    padding: 8px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.1);
    flex-wrap: wrap;
    gap: 6px;
  }

  .snapshot-head .toolbar { flex-wrap: wrap; gap: 6px; }

  /* Тогл фильтров */
  .ads-filters-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    width: 100%;
    min-height: 44px;
    padding: 10px 14px;
    background: rgba(30, 41, 59, 0.5);
    border: 1px solid rgba(148, 163, 184, 0.12);
    border-radius: 8px;
    color: #e2e8f0;
    font-size: 14px;
    cursor: pointer;
  }

  .ads-filters-wrap { display: block; }
  .ads-filters-wrap.collapsed .ads-filters { display: none; }

  /* Тогл логов */
  .log-toggle-btn { display: flex; min-height: unset; }

  /* Swipe handle на модалке */
  .modal-box::before {
    content: '';
    display: block;
    width: 36px;
    height: 4px;
    background: rgba(148, 163, 184, 0.25);
    border-radius: 2px;
    margin: 10px auto 2px;
    flex-shrink: 0;
  }

  .hero h1 { font-size: 14px; }
  .hero p { font-size: 11px; }

  /* Карточки объявлений — 2 колонки */
  .ads-feed-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  .ad-card { padding: 7px 8px; gap: 5px; border-radius: 10px; }

  .ad-photo-wrap {
    aspect-ratio: 3 / 2;
    border-radius: 8px;
    cursor: pointer;
  }

  .ad-price-listing { font-size: 13px; }

  .ad-price-market,
  .ad-profit-positive,
  .ad-profit-negative { font-size: 11px; }

  .ad-condition { font-size: 10px; }
  .item-title { font-size: 12px; }
  .item-meta { font-size: 11px; }

  /* Кнопки карточки — в столбик */
  .item-actions { flex-direction: column; gap: 5px; }
  .item-actions button { width: 100%; }

  .ads-filters { gap: 6px; }

  .panel { padding: 8px; border-radius: 8px; }
  .panel h2, .panel h3 { font-size: 13px; margin-bottom: 6px; }

  .log-console {
    font-size: 11px;
    min-height: 150px;
    max-height: 300px;
    padding: 6px;
  }

  .stat-card .value { font-size: 13px; }
  .stat-card .label { font-size: 10px; }

  /* Модалка — bottom sheet */
  .modal-overlay {
    padding: 0;
    align-items: flex-end;
  }

  .modal-box {
    max-width: 100%;
    max-height: 93vh;
    border-radius: 16px 16px 0 0;
    display: flex;
    flex-direction: column;
  }

  .modal-body { flex: 1; overflow-y: auto; }

  .ad-detail-head { grid-template-columns: 100px 1fr; gap: 10px; }
  .ad-detail-title { font-size: 14px; }
  .ad-detail-price { font-size: 15px; }
}

/* Один столбец на очень узких экранах */
@media (max-width: 400px) {
  .ads-feed-grid { grid-template-columns: 1fr; }
}

/* ── Быстрое заполнение цен ─────────────────────────────────────────────── */
.quick-fill-modal {
  width: 480px;
  max-width: 96vw;
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0;
  overflow: hidden;
}

.quick-fill-modal .modal-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 20px 14px;
  border-bottom: 1px solid #1e293b;
}

.quick-fill-modal .modal-header h3 {
  margin: 0;
  flex: 1;
  font-size: 16px;
}

.qf-counter {
  font-size: 13px;
  color: #64748b;
  white-space: nowrap;
}

.qf-filter-bar {
  display: flex;
  gap: 6px;
  padding: 10px 20px 8px;
  background: #0d1829;
  border-bottom: 1px solid #1e293b;
  flex-wrap: wrap;
}

.qf-chip {
  padding: 4px 12px;
  border-radius: 20px;
  border: 1px solid #334155;
  background: transparent;
  color: #64748b;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  white-space: nowrap;
}

.qf-chip:hover {
  border-color: #475569;
  color: #94a3b8;
}

.qf-chip--active {
  background: #1e40af;
  border-color: #3b82f6;
  color: #e2e8f0;
}

.qf-chip--active:hover {
  background: #2563eb;
}

.qf-progress-wrap {
  height: 3px;
  background: #1e293b;
}

.qf-progress-bar {
  height: 100%;
  background: #3b82f6;
  transition: width 0.2s ease;
  width: 0%;
}

.qf-body {
  padding: 24px 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.qf-category {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #3b82f6;
}

.qf-component {
  font-size: 20px;
  font-weight: 600;
  color: #f1f5f9;
  line-height: 1.3;
  word-break: break-word;
}

.qf-impact {
  font-size: 12px;
  color: #475569;
  margin-bottom: 4px;
}

.qf-impact--active {
  color: #22c55e;
}

.qf-input {
  width: 100%;
  font-size: 28px;
  font-weight: 700;
  padding: 12px 16px;
  border-radius: 10px;
  border: 2px solid #334155;
  background: #0f172a;
  color: #f1f5f9;
  outline: none;
  text-align: center;
  box-sizing: border-box;
  transition: border-color 0.15s;
}

.qf-input:focus {
  border-color: #3b82f6;
}

.qf-hint {
  font-size: 11px;
  color: #334155;
  text-align: center;
}

.qf-footer {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 24px 18px;
  border-top: 1px solid #1e293b;
  font-size: 13px;
  color: #64748b;
}

.qf-footer strong {
  color: #94a3b8;
}

.qf-footer button {
  margin-left: auto;
}

/* ── Рассылка сообщений ─────────────────────────────────────────────────── */
.messaging-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(320px, 0.8fr);
  gap: 14px;
}

.messaging-subprofiles-list {
  display: grid;
  gap: 4px;
  max-height: 220px;
  overflow: auto;
  padding: 6px 0;
}

.messaging-subprofile-row {
  padding: 4px 6px;
  border-radius: 6px;
}

.messaging-subprofile-row:hover {
  background: rgba(30, 41, 59, 0.5);
}

.subprofile-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.subprofile-avatar-placeholder {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(100, 116, 139, 0.3);
  flex-shrink: 0;
}

.category-count {
  margin-left: auto;
  font-size: 11px;
  color: var(--text-muted, #94a3b8);
  background: rgba(100, 116, 139, 0.15);
  padding: 1px 6px;
  border-radius: 10px;
}
