/* UA DROP — интерфейс управления конвейером */

:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --surface-3: #eef0f3;
  --border: #e2e5ea;
  --border-strong: #cdd2da;
  --text: #15171c;
  --text-2: #464c59;
  --muted: #7b8291;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: #eef0ff;
  --accent-text: #3d35c4;
  --on-accent: #ffffff;
  --success: #15803d;
  --success-soft: #e7f6ec;
  --warning: #b45309;
  --warning-soft: #fdf2e0;
  --danger: #c42424;
  --danger-soft: #fdeaea;
  --info: #0e7490;
  --info-soft: #e3f4f7;
  --ai: #7c3aed;
  --ai-soft: #f2ecff;
  --on-solid: #ffffff;
  --radius-sm: 7px;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06);
  --shadow: 0 4px 18px rgba(16, 24, 40, 0.08);
  --shadow-lg: 0 16px 48px rgba(16, 24, 40, 0.18);
  --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "Cascadia Mono", Consolas, "SF Mono", Menlo, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111317;
    --surface: #181b21;
    --surface-2: #1d2027;
    --surface-3: #252932;
    --border: #2b3039;
    --border-strong: #3a404c;
    --text: #eceef2;
    --text-2: #b9bfcb;
    --muted: #8a91a0;
    --accent: #7c74ff;
    --accent-hover: #918aff;
    --accent-soft: #24234a;
    --accent-text: #b3aeff;
    --on-accent: #ffffff;
    --success: #4ade80;
    --success-soft: #16301f;
    --warning: #fbbf24;
    --warning-soft: #33280f;
    --danger: #f87171;
    --danger-soft: #3a1a1c;
    --info: #67d4e6;
    --info-soft: #132d33;
    --ai: #b794ff;
    --ai-soft: #2a2140;
    /* Светлые акценты тёмной темы — текст на них тёмный, иначе не читается. */
    --on-solid: #101216;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow: 0 4px 18px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.55);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }
h1 { font-size: 22px; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }

svg.icon { width: 18px; height: 18px; flex: none; }
.icon-sm svg.icon, svg.icon.sm { width: 15px; height: 15px; }

/* ---------- Каркас ---------- */

.app {
  display: grid;
  grid-template-columns: 228px minmax(0, 1fr);
  min-height: 100vh;
}

/* z-index обязателен: липкое меню образует свой слой, и без него панель
   уведомлений внутри меню уходила под карточки главного экрана. */
.sidebar {
  position: sticky;
  top: 0;
  z-index: 30;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 16px 12px;
  background: var(--surface);
  border-right: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 14px;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.04em;
  color: var(--text);
}
.brand:hover { text-decoration: none; }

.brand-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 6px; }
.bell-host { position: relative; }
.bell {
  position: relative;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
}
.bell:hover, .bell.open { background: var(--surface-3); color: var(--text); }
.bell svg.icon { width: 20px; height: 20px; }
.bell-count {
  position: absolute;
  top: 2px;
  right: 1px;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--warning);
  color: #fff;
  font-size: 10.5px;
  font-weight: 700;
  line-height: 17px;
  text-align: center;
  box-shadow: 0 0 0 2px var(--surface);
}
.bell-count.urgent { background: var(--danger); }

.notice-panel {
  position: fixed;
  left: 236px;
  top: 12px;
  z-index: 60;
  width: 440px;
  max-width: calc(100vw - 252px);
  max-height: calc(100vh - 24px);
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}
.notice-panel-head { display: flex; align-items: center; gap: 8px; padding: 12px 14px; }
.notice-panel-head .spacer { flex: 1; }
.notice-empty { display: flex; align-items: center; gap: 8px; padding: 18px 14px; color: var(--muted); border-top: 1px solid var(--border); }
.notice-empty svg.icon { color: var(--success); }
.notice-item {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  gap: 10px;
  padding: 12px 14px;
  border-top: 1px solid var(--border);
}
.notice-item .ni-icon {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: var(--surface-3);
  color: var(--text-2);
}
.notice-item .ni-icon svg.icon { width: 16px; height: 16px; }
.notice-item.danger .ni-icon { background: var(--danger-soft); color: var(--danger); }
.notice-item.warning .ni-icon { background: var(--warning-soft); color: var(--warning); }
.notice-item.info .ni-icon { background: var(--info-soft); color: var(--info); }
.notice-item .ni-title { font-weight: 650; }
.notice-item .ni-text { margin-top: 2px; font-size: 13px; color: var(--text-2); }
.notice-item .ni-links { margin-top: 4px; font-size: 13px; color: var(--muted); }

.brand-mark {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 800;
}

.nav { display: flex; flex-direction: column; gap: 2px; }

.nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--text-2);
  font-weight: 550;
}
.nav a:hover { background: var(--surface-3); text-decoration: none; }
.nav a.active { background: var(--accent-soft); color: var(--accent-text); }

/* Короткие подписи, вкладка «Ещё» и верхняя полоса — только для телефона. */
.nav .short, .nav .nav-mobile, .topbar-extra { display: none; }

.nav .nav-sep {
  margin: 10px 10px 4px;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.nav .count {
  margin-left: auto;
  min-width: 22px;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--text-2);
  font-size: 12px;
  font-weight: 650;
  text-align: center;
  line-height: 20px;
}
.nav a.active .count { background: var(--surface); }
.nav .count.hot, .nav a.active .count.hot { background: var(--accent); color: var(--on-accent); }

.sidebar-foot {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
  padding: 0 8px;
}

.mode-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 12px;
}
.mode-pill.live { background: var(--success-soft); color: var(--success); }
.mode-pill.dry { background: var(--warning-soft); color: var(--warning); }

.main {
  min-width: 0;
  padding: 22px 28px 120px;
}

.page-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 18px;
}
.page-head .spacer { flex: 1; }
.page-sub { color: var(--muted); font-size: 13px; }

/* ---------- Кнопки ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 34px;
  padding: 0 13px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, box-shadow 0.12s;
}
.btn:hover { background: var(--surface-2); border-color: var(--muted); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn:disabled { opacity: 0.5; cursor: default; }

.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.success { background: var(--success); border-color: var(--success); color: var(--on-solid); }
.btn.success:hover { filter: brightness(1.07); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: var(--danger-soft); border-color: var(--danger); }
.btn.danger.solid { background: var(--danger); border-color: var(--danger); color: var(--on-solid); }
.btn.ai { background: var(--ai); border-color: var(--ai); color: var(--on-solid); }
.btn.ai:hover { filter: brightness(1.08); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-3); }
.btn.sm { height: 28px; padding: 0 10px; font-size: 13px; gap: 5px; }
.btn.lg { height: 40px; padding: 0 18px; font-size: 15px; }
.btn.icon-only { width: 34px; padding: 0; }
.btn.sm.icon-only { width: 28px; }

.btn .kbd { margin-left: 4px; }

.btn.busy { position: relative; color: transparent !important; pointer-events: none; }
.btn.busy::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-color: var(--muted) var(--muted) var(--muted) transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.btn.primary.busy::after {
  border-color: var(--on-accent) var(--on-accent) var(--on-accent) transparent;
}
.btn.success.busy::after, .btn.ai.busy::after, .btn.danger.solid.busy::after {
  border-color: var(--on-solid) var(--on-solid) var(--on-solid) transparent;
}

.kbd {
  display: inline-block;
  padding: 0 5px;
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: 5px;
  font: 600 11px/16px var(--font);
  color: var(--muted);
  background: var(--surface-2);
}
.btn.primary .kbd, .btn.success .kbd {
  border-color: currentColor;
  color: inherit;
  background: transparent;
  opacity: 0.7;
}

.btn-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* ---------- Карточки ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.card-pad { padding: 16px 18px; }
.card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.card-head .spacer { flex: 1; }
.card-body { padding: 16px 18px; }

.grid { display: grid; gap: 14px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 1100px) {
  .grid.two, .grid.three { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- Бейджи ---------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--text-2);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.badge svg.icon { width: 13px; height: 13px; }
.badge.accent { background: var(--accent-soft); color: var(--accent-text); }
.badge.success { background: var(--success-soft); color: var(--success); }
.badge.warning { background: var(--warning-soft); color: var(--warning); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.ai { background: var(--ai-soft); color: var(--ai); }

/* ---------- Формы ---------- */

.field { display: flex; flex-direction: column; gap: 5px; }
.field-label {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 12.5px;
  font-weight: 650;
  color: var(--text-2);
}
.field-label .counter { margin-left: auto; font-weight: 550; color: var(--muted); }
.field-label .counter.bad { color: var(--danger); }
.field-hint { font-size: 12px; color: var(--muted); }
.field-errors { display: flex; flex-direction: column; gap: 2px; font-size: 12.5px; color: var(--danger); }

.input, .textarea, .select {
  width: 100%;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.input, .select { height: 36px; padding: 0 11px; }
.textarea { padding: 9px 11px; resize: vertical; min-height: 120px; line-height: 1.5; }
.input:focus, .textarea:focus, .select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.input.invalid, .textarea.invalid { border-color: var(--danger); }
.input.title-input { height: 40px; font-size: 15px; font-weight: 600; }
.input.price-input { font-size: 18px; font-weight: 700; height: 42px; }

.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }

.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch .track {
  width: 38px;
  height: 22px;
  border-radius: 999px;
  background: var(--border-strong);
  position: relative;
  transition: background 0.15s;
  flex: none;
}
.switch .track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s;
}
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { transform: translateX(16px); }
.switch input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }

.segmented {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  border-radius: 9px;
  background: var(--surface-3);
}
.segmented button {
  height: 28px;
  padding: 0 12px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--text-2);
  font: inherit;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
}
.segmented button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.segmented button { white-space: nowrap; }

/* ---------- Вкладки ---------- */

.tabs {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.tabs a {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 12px;
  margin-bottom: -1px;
  border-bottom: 2px solid transparent;
  color: var(--text-2);
  font-weight: 600;
}
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.active { color: var(--accent-text); border-bottom-color: var(--accent); }
.tabs .count { font-size: 12px; color: var(--muted); font-weight: 600; }

/* ---------- Таблицы ---------- */

.table { width: 100%; border-collapse: collapse; }
.table th {
  padding: 10px 12px;
  text-align: left;
  font-size: 12px;
  font-weight: 650;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr.clickable { cursor: pointer; }
.table tbody tr.clickable:hover td { background: var(--surface-2); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table .thumb-cell { width: 58px; }

.thumb {
  display: block;
  width: 44px;
  height: 58px;
  object-fit: cover;
  border-radius: 7px;
  background: var(--surface-3);
  border: 1px solid var(--border);
}

.title-cell { font-weight: 600; line-height: 1.35; }
.title-cell .meta { font-weight: 500; }

.meta { font-size: 12px; color: var(--muted); }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
.mono { font-family: var(--mono); font-size: 12.5px; }

/* ---------- Пустые состояния и загрузка ---------- */

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 56px 20px;
  text-align: center;
  color: var(--muted);
}
.empty svg.icon { width: 36px; height: 36px; color: var(--border-strong); }
.empty h3 { color: var(--text); font-size: 15px; }
.empty p { margin: 0; max-width: 420px; }

.loading { display: flex; justify-content: center; padding: 48px; }
.spinner {
  width: 22px;
  height: 22px;
  border: 2.5px solid var(--border-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.spinner.sm { width: 14px; height: 14px; border-width: 2px; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 50% { opacity: 0.55; } }

.skeleton { background: var(--surface-3); border-radius: 8px; animation: pulse 1.4s ease-in-out infinite; }

/* ---------- Главный экран ---------- */

.stages {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
@media (max-width: 1200px) { .stages { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.stage {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.stage.focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.stage-top { display: flex; align-items: center; gap: 8px; color: var(--text-2); font-weight: 600; }
.stage-step {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--surface-3);
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}
.stage-num { font-size: 32px; font-weight: 700; letter-spacing: -0.02em; line-height: 1; }
.stage-num a { color: var(--text); }
.stage-note { font-size: 12.5px; color: var(--muted); min-height: 18px; }
.stage .btn { align-self: flex-start; }
.stage-arrow {
  position: absolute;
  right: -13px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 1;
  width: 12px;
  color: var(--border-strong);
}

.channel-list { display: flex; flex-direction: column; gap: 3px; }
.channel-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
  align-items: center;
  padding: 4px 4px 4px 9px;
  border-radius: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.channel-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; font-weight: 550; }
.channel-count { font-weight: 700; font-variant-numeric: tabular-nums; }

.alerts { display: flex; flex-direction: column; gap: 8px; margin-bottom: 18px; }
.alert {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-weight: 550;
}
.alert .spacer { flex: 1; }
.alert.info { background: var(--info-soft); color: var(--info); }
.alert.warning { background: var(--warning-soft); color: var(--warning); }
.alert.danger { background: var(--danger-soft); color: var(--danger); }
.alert.success { background: var(--success-soft); color: var(--success); }
.alert .btn { color: var(--text); }

.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.sales-line {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 18px;
  border-top: 1px solid var(--border);
  font-size: 13px;
}
.sales-line > span { display: inline-flex; align-items: center; gap: 6px; }
.kpi .kpi-num { font-size: 22px; font-weight: 700; }
.kpi .kpi-label { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 5px; }

.top-list { display: flex; flex-direction: column; gap: 2px; }
.top-item {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 6px;
  border-radius: 9px;
  color: var(--text);
}
.top-item:hover { background: var(--surface-2); text-decoration: none; }
.top-item img { width: 40px; height: 52px; object-fit: cover; border-radius: 6px; background: var(--surface-3); }
.top-item .t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.top-item .stats { display: flex; gap: 10px; color: var(--muted); font-size: 12.5px; }
.top-item .stats span { display: inline-flex; gap: 3px; align-items: center; }

.conn-list { display: flex; flex-direction: column; gap: 8px; }
.conn { display: flex; align-items: center; gap: 10px; }
.conn .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--border-strong); flex: none; }
.conn .dot.ok { background: var(--success); }
.conn .dot.bad { background: var(--danger); }

/* ---------- Проверка ---------- */

.review {
  display: grid;
  grid-template-columns: 272px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.queue {
  position: sticky;
  top: 16px;
  max-height: calc(100vh - 32px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.queue-head { display: flex; flex-direction: column; gap: 8px; padding: 12px; border-bottom: 1px solid var(--border); }
.queue-list { overflow-y: auto; padding: 6px; }
.queue-row {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  gap: 4px;
  align-items: center;
  padding-left: 6px;
  border-radius: 10px;
}
.queue-row > input[type="checkbox"] { width: 15px; height: 15px; accent-color: var(--accent); cursor: pointer; }
.queue-row.selected { background: var(--accent-soft); }

.bulkbar {
  position: sticky;
  top: 10px;
  z-index: 20;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
  padding: 10px 14px;
  box-shadow: var(--shadow);
  border-color: var(--accent);
}
.bulkbar .spacer { flex: 1; }
.bulk-sep { width: 1px; height: 22px; background: var(--border); margin: 0 2px; }

.queue-item {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 10px;
  padding: 8px;
  border-radius: 10px;
  cursor: pointer;
  color: var(--text);
  border: 1px solid transparent;
}
.queue-item:hover { background: var(--surface-2); text-decoration: none; }
.queue-item.active { background: var(--accent-soft); border-color: var(--accent); }
.queue-item .thumb { width: 44px; height: 58px; }
.queue-item .q-title {
  font-weight: 600;
  font-size: 13px;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.queue-item .q-meta { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 5px; align-items: center; }
.queue-item .q-price { font-weight: 700; font-size: 13px; margin-right: 4px; }
.queue-item .badge { height: 19px; font-size: 11px; padding: 0 6px; }

/* Узкий экран: очередь и карточка по очереди, а не рядом. Карточка
   открывается на весь экран, «← Очередь» в её заголовке ведёт назад.
   Стоит после правил очереди, иначе они бы перебили эти. */
@media (max-width: 1100px) {
  .review { grid-template-columns: minmax(0, 1fr); }
  .review-page.has-editor > .page-head,
  .review-page.has-editor > .bulk-host,
  .review-page.has-editor .queue { display: none; }
  .review-page:not(.has-editor):not(.is-empty) .editor-host { display: none; }
  .queue { position: static; max-height: none; overflow: visible; }
  .queue-list { overflow: visible; }
  .review-page.selecting .queue-list { padding-bottom: 150px; }
}

/* Без overflow: hidden — иначе карточка становится контейнером прокрутки
   и панель действий перестаёт прилипать к низу экрана. */
.editor-card > :first-child { border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
.editor-card > .actionbar { border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.editor-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.editor-head .spacer { flex: 1; }
.editor-head .crumbs { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; color: var(--muted); font-size: 13px; }
/* «Назад» в заголовке карточки — когда она открыта на весь экран. */
.editor-back-host { display: none; }
.editor-back { padding: 0 10px 0 6px; }
@media (max-width: 1100px) {
  .editor-back-host:not(:empty) { display: inline-flex; }
  .detail-head { display: none; }
  .editor-head { position: sticky; top: 0; z-index: 12; }
}
.editor-head .crumbs strong { color: var(--text); font-size: 14px; }
.save-state { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); min-width: 92px; }
.save-state.saved { color: var(--success); }
.save-state.error { color: var(--danger); }

.editor-card { container-type: inline-size; }

.editor {
  display: grid;
  grid-template-columns: minmax(250px, 0.8fr) minmax(0, 1.2fr);
  gap: 22px;
  padding: 18px;
}
@container (max-width: 720px) { .editor { grid-template-columns: minmax(0, 1fr); } }

.editor-photos { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.editor-fields { display: flex; flex-direction: column; gap: 16px; min-width: 0; container-type: inline-size; }

.cover {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  background: var(--surface-3);
  border: 1px solid var(--border);
  aspect-ratio: 3 / 4;
  user-select: none;
}
.cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.cover .cover-badge { position: absolute; top: 10px; left: 10px; z-index: 3; }
.cover .cover-tools {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 10px;
  z-index: 3;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.cover .cover-tools .btn { box-shadow: var(--shadow); }

.compare { cursor: ew-resize; touch-action: none; }
.compare .compare-top { clip-path: inset(0 0 0 var(--split, 50%)); }
.compare .compare-line {
  position: absolute;
  top: 0;
  bottom: 0;
  left: var(--split, 50%);
  width: 2px;
  margin-left: -1px;
  background: #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.15);
  z-index: 2;
  pointer-events: none;
}
.compare .compare-knob {
  position: absolute;
  top: 50%;
  left: var(--split, 50%);
  width: 34px;
  height: 34px;
  margin: -17px 0 0 -17px;
  border-radius: 50%;
  background: #fff;
  color: #333;
  box-shadow: var(--shadow);
  display: grid;
  place-items: center;
  z-index: 2;
  pointer-events: none;
}
.compare-label {
  position: absolute;
  top: 10px;
  z-index: 2;
  padding: 2px 8px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  pointer-events: none;
}
.compare-label.left { left: 10px; top: 44px; }
.compare-label.right { right: 10px; }

.cover-overlay {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: rgba(20, 16, 40, 0.55);
  color: #fff;
  font-weight: 600;
  text-align: center;
  padding: 20px;
  backdrop-filter: blur(2px);
}
.cover-overlay .spinner { border-color: rgba(255, 255, 255, 0.35); border-top-color: #fff; width: 30px; height: 30px; }

.variant-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.variant-bar .meta { margin-left: auto; }

/* Кнопки выбранного фото — для пальца вместо перетаскивания и плашек
   на миниатюрах, которые появляются только при наведении мыши. */
.photo-tools { display: none; gap: 8px; flex-wrap: wrap; }
.tile.selected { outline: 2px solid var(--text-2); outline-offset: 2px; }

.strip-head { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); }
.strip-head strong { color: var(--text-2); }
.strip {
  position: relative;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(78px, 1fr));
  gap: 8px;
}
.tile {
  position: relative;
  aspect-ratio: 3 / 4;
  border-radius: 9px;
  overflow: hidden;
  background: var(--surface-3);
  border: 2px solid transparent;
  cursor: grab;
}
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
.tile.is-cover { border-color: var(--accent); }
.tile.excluded img { opacity: 0.32; filter: grayscale(0.7); }
.tile.dragging { opacity: 0.35; }
.tile.drop-before { box-shadow: -4px 0 0 0 var(--accent); }
.tile.drop-after { box-shadow: 4px 0 0 0 var(--accent); }
.tile .tile-num {
  position: absolute;
  top: 4px;
  left: 4px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 5px;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
}
.tile.is-cover .tile-num { background: var(--accent); }
.tile .tile-ai {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 18px;
  height: 18px;
  border-radius: 5px;
  background: var(--ai);
  color: #fff;
  display: grid;
  place-items: center;
}
.tile .tile-ai svg.icon { width: 12px; height: 12px; }
.tile .tile-tools {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  justify-content: center;
  gap: 3px;
  padding: 16px 3px 4px;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.6));
  opacity: 0;
  transition: opacity 0.12s;
}
.tile:hover .tile-tools, .tile:focus-within .tile-tools { opacity: 1; }
.tile .tile-tools button {
  width: 24px;
  height: 24px;
  border: 0;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.92);
  color: #222;
  display: grid;
  place-items: center;
  cursor: pointer;
  padding: 0;
}
.tile .tile-tools button:hover { background: #fff; }
.tile .tile-tools svg.icon { width: 14px; height: 14px; }
.tile .tile-off {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #fff;
  pointer-events: none;
}
.tile .tile-off svg.icon { width: 22px; height: 22px; filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.5)); }

.prices {
  display: grid;
  grid-template-columns: minmax(150px, 1.2fr) repeat(3, minmax(0, 1fr));
  gap: 12px;
  align-items: end;
  padding: 14px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}
@container (max-width: 600px) { .prices { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.price-fact .v { font-size: 16px; font-weight: 700; font-variant-numeric: tabular-nums; }
.price-fact .l { font-size: 12px; color: var(--muted); font-weight: 600; margin-bottom: 4px; }
.price-fact .v.good { color: var(--success); }
.price-fact .v.bad { color: var(--danger); }
.price-fact .v.warn { color: var(--warning); }

.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.row > .field { flex: 1 1 180px; }

.attrs { display: flex; flex-direction: column; gap: 6px; }
.attr-row { display: grid; grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.4fr) 30px; gap: 6px; }
.attr-row .input { height: 32px; }

.source {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-2);
}
.source summary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 14px;
  cursor: pointer;
  font-weight: 650;
  color: var(--text-2);
  list-style: none;
}
.source summary::-webkit-details-marker { display: none; }
.source summary .chev { margin-left: auto; transition: transform 0.15s; color: var(--muted); }
.source[open] summary .chev { transform: rotate(90deg); }
.source .source-body { padding: 0 14px 14px; display: flex; flex-direction: column; gap: 10px; }
.source pre {
  margin: 0;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  font: 13px/1.5 var(--font);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 320px;
  overflow: auto;
}

.similar-list { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.similar-item { display: flex; align-items: center; gap: 10px; }
.similar-link { display: flex; gap: 10px; align-items: center; flex: 1; min-width: 0; color: inherit; }
.similar-link:hover { text-decoration: none; }
.similar-link img, .similar-thumb {
  width: 32px;
  height: 42px;
  flex: none;
  object-fit: cover;
  border-radius: 5px;
  background: var(--surface-3);
}
.similar-item .btn { flex: none; color: inherit; }

.olx-box {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  padding: 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-2);
}
.olx-box .v { font-size: 20px; font-weight: 700; }
.olx-box .l { font-size: 12px; color: var(--muted); }

.notice {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 11px 13px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 550;
}
.notice.danger { background: var(--danger-soft); color: var(--danger); }
.notice.warning { background: var(--warning-soft); color: var(--warning); }
.notice.info { background: var(--info-soft); color: var(--info); }
.notice.success { background: var(--success-soft); color: var(--success); }
.notice ul { margin: 2px 0 0; padding-left: 18px; }

.actionbar {
  position: sticky;
  bottom: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(6px);
}
.actionbar .spacer { flex: 1; }
.actionbar .hint { font-size: 12px; color: var(--muted); display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

.timeline { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; }
.timeline .ev { display: flex; gap: 8px; }
.timeline .ev .t { color: var(--muted); white-space: nowrap; min-width: 86px; }

/* ---------- Сообщения ---------- */

.chat {
  display: grid;
  grid-template-columns: 330px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}
.thread-filters { margin: 10px; }
.conv-head { display: none; }
.deal-amount { width: 130px; }
.deal-note { flex: 1 1 200px; }
.threads { overflow: hidden; }
.thread {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
.thread:hover { background: var(--surface-2); text-decoration: none; }
.thread > .badge { justify-self: end; }
.thread.active { background: var(--accent-soft); }
.thread .t { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thread.unread .t::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 7px;
  border-radius: 50%;
  background: var(--accent);
  vertical-align: 1px;
}

.conversation { display: flex; flex-direction: column; min-height: 520px; }
.messages {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px;
  overflow-y: auto;
  max-height: 60vh;
}
.bubble {
  max-width: 72%;
  padding: 9px 12px;
  border-radius: 14px;
  white-space: pre-wrap;
  word-break: break-word;
}
.bubble .time { display: block; margin-top: 3px; font-size: 11px; opacity: 0.7; }
.bubble.in { align-self: flex-start; background: var(--surface-3); border-bottom-left-radius: 4px; }
.bubble.out { align-self: flex-end; background: var(--accent); color: var(--on-accent); border-bottom-right-radius: 4px; }
.composer { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--border); }
.composer .textarea { min-height: 44px; height: 44px; }

.deal-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
}
.deal-bar .input { height: 32px; }
.deal-bar .input:disabled { opacity: 0.5; }

.product-strip {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
.product-strip img { width: 48px; height: 62px; object-fit: cover; border-radius: 7px; }

/* Узкий экран: список переписок или одна переписка на весь экран.
   Стоит после правил переписки, иначе они бы перебили эти. */
@media (max-width: 1100px) {
  .chat { grid-template-columns: minmax(0, 1fr); }
  .chat.has-conversation .threads,
  .messages-page:has(.chat.has-conversation) > .page-head { display: none; }
  .chat:not(.has-conversation) .conversation { display: none; }
  /* Товар, ссылки и отметка сделки прилипают к верху одной плашкой:
     что за товар, видно в любом месте переписки. */
  .conv-top {
    position: sticky;
    top: 0;
    z-index: 12;
    border-bottom: 1px solid var(--border);
    background: color-mix(in srgb, var(--surface) 96%, transparent);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    box-shadow: 0 6px 16px rgba(16, 24, 40, 0.06);
  }
  .conv-head { display: flex; align-items: center; gap: 10px; padding: 8px 10px 6px 4px; }
  .conv-back { flex: none; }
  .conv-thumb { width: 44px; height: 58px; flex: none; object-fit: cover; border-radius: 7px; background: var(--surface-3); }
  .conv-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
  .conv-title {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 650;
    color: var(--text);
  }
  a.conv-title { color: var(--accent-text); }
  .conv-line { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .conv-olx { flex: none; }
  /* Всё о товаре уже в шапке — отдельная полоса не нужна. */
  .conv-top .product-strip { display: none; }
  .conv-top .deal-bar { padding: 4px 10px 8px; border-bottom: 0; gap: 6px; }
  /* Сумма и заметка — в одну строку: поле ввода по умолчанию не сжимается уже своей ширины. */
  .conv-top .deal-bar .input { min-width: 0; }
  .deal-bar.no-status .deal-amount,
  .deal-bar.no-status .deal-note,
  .deal-bar .deal-saved { display: none; }
  /* Прокручивается вся страница, поле ответа прилипает к низу экрана. */
  .conversation { min-height: 0; }
  .messages { max-height: none; overflow: visible; }
  .composer {
    position: sticky;
    bottom: 0;
    z-index: 5;
    align-items: flex-end;
    background: var(--surface);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  }
}

/* ---------- Панель задач ---------- */

/* По умолчанию выше липкой панели действий карточки, чтобы не закрывать
   «Одобрить». Дальше пользователь двигает панель сам. */
.dock {
  position: fixed;
  right: 18px;
  bottom: 88px;
  z-index: 50;
  width: 380px;
  max-width: calc(100vw - 36px);
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.dock > * { pointer-events: auto; }
.dock-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.dock-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  font-weight: 650;
  cursor: grab;
  user-select: none;
  touch-action: none;
}
.dock.dragging .dock-head { cursor: grabbing; }
.dock.dragging .dock-card { box-shadow: 0 20px 60px rgba(16, 24, 40, 0.28); }
.dock-head .spacer { flex: 1; }
.dock-list { max-height: 50vh; overflow-y: auto; border-top: 1px solid var(--border); }
.job { padding: 10px 12px; border-bottom: 1px solid var(--border); }
.job:last-child { border-bottom: 0; }
.job-top { display: flex; align-items: center; gap: 8px; }
.job-title { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.job-msg { font-size: 12.5px; color: var(--muted); margin-top: 3px; }
.job-msg.error { color: var(--danger); }
.job-msg.ok { color: var(--success); }
.job-bar { height: 4px; margin-top: 7px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.job-bar i { display: block; height: 100%; background: var(--accent); border-radius: 99px; transition: width 0.3s; }
.job-bar.indeterminate i { width: 35% !important; animation: slide 1.1s ease-in-out infinite; }
@keyframes slide { 0% { transform: translateX(-100%); } 100% { transform: translateX(290%); } }
.job-log {
  margin-top: 8px;
  max-height: 200px;
  overflow: auto;
  padding: 8px;
  border-radius: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font: 12px/1.45 var(--mono);
  white-space: pre-wrap;
  word-break: break-word;
}
.job-log .warning { color: var(--warning); }
.job-log .error { color: var(--danger); }
.job-status { display: grid; place-items: center; width: 20px; height: 20px; flex: none; }
.job-status.done { color: var(--success); }
.job-status.failed { color: var(--danger); }
.job-status.cancelled { color: var(--muted); }

/* ---------- Уведомления и диалоги ---------- */

.toasts {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 9px;
  max-width: 560px;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--text);
  color: var(--bg);
  box-shadow: var(--shadow-lg);
  font-weight: 550;
  pointer-events: auto;
  animation: toast-in 0.18s ease-out;
}
.toast.success svg.icon { color: #4ade80; }
.toast.error { background: var(--danger); color: #fff; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-6px); } }

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(10, 12, 18, 0.45);
  animation: fade 0.12s ease-out;
}
@keyframes fade { from { opacity: 0; } }
.modal {
  width: 460px;
  max-width: 100%;
  padding: 20px;
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.modal h2 { font-size: 17px; }
.modal .modal-body { color: var(--text-2); }
.modal .modal-body p { margin: 0 0 8px; }
.modal .btn-row { justify-content: flex-end; margin-top: 6px; }

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 95;
  display: grid;
  place-items: center;
  background: rgba(8, 10, 14, 0.85);
  cursor: zoom-out;
  padding: 24px;
}
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 8px; box-shadow: var(--shadow-lg); }

/* ---------- Настройки ---------- */

.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
@media (max-width: 1150px) { .settings-grid { grid-template-columns: minmax(0, 1fr); } }
.settings-list { display: flex; flex-direction: column; gap: 14px; }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 8px 14px; flex-wrap: wrap; }
.setting-row .txt { flex: 1 1 220px; }
.setting-row .txt { min-width: 0; }
.setting-row .txt .field-hint { margin-top: 2px; }

.inline-edit { display: flex; gap: 6px; align-items: center; }
.inline-edit .input, .inline-edit .select { height: 30px; }

.settings-save-host { position: sticky; bottom: 16px; z-index: 20; }
.settings-save { margin-top: 16px; border-radius: 14px; box-shadow: var(--shadow); }

/* Доступ с телефона: адрес и QR-код */
.lan-status { display: flex; flex-direction: column; gap: 10px; }
.lan-status:empty { display: none; }
.lan-box {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  padding: 14px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.lan-qr { width: 148px; height: 148px; flex: none; padding: 4px; border-radius: 10px; background: #fff; }
.lan-qr svg { display: block; width: 100%; height: 100%; }
.lan-text { flex: 1 1 200px; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.lan-url { font: 650 17px/1.3 var(--mono); word-break: break-all; color: var(--text); user-select: all; }
.pin-field { max-width: 260px; }
.pin-field:not(:placeholder-shown) { letter-spacing: 0.25em; }

/* ---------- Карточки вместо таблиц (телефон) ---------- */

.lcards, .ccards { display: flex; flex-direction: column; }
.lc-all { padding: 12px 14px 4px; font-weight: 600; }
.lcard-row { display: flex; align-items: stretch; border-bottom: 1px solid var(--border); }
.lcard-row:last-child { border-bottom: 0; }
.lcard-row.selected { background: var(--accent-soft); }
.lcard-row .lcard { flex: 1; min-width: 0; border-bottom: 0; padding-left: 4px; }
.lc-check { display: grid; place-items: center; padding: 0 4px 0 14px; cursor: pointer; }
.lc-check input { width: 22px !important; height: 22px !important; }
.lcard {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
.lcard:last-child { border-bottom: 0; }
.lcard:hover { text-decoration: none; }
.lcard:active { background: var(--surface-2); }
.lcard .thumb { width: 56px; height: 74px; flex: none; }
.lc-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.lc-top { display: flex; gap: 10px; align-items: flex-start; }
.lc-title {
  flex: 1;
  min-width: 0;
  font-weight: 600;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.lc-price { flex: none; text-align: right; font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }
.lc-price .meta { font-weight: 500; }
.lc-extra { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; font-size: 13px; color: var(--text-2); }
.lc-extra .stat { display: inline-flex; align-items: center; gap: 4px; font-variant-numeric: tabular-nums; }
.lc-reason { color: var(--text-2); font-size: 12.5px; }

.ccard { display: flex; flex-direction: column; gap: 10px; padding: 14px; border-bottom: 1px solid var(--border); }
.ccard:last-child { border-bottom: 0; }
.ccard-top { display: flex; align-items: flex-start; gap: 12px; }
.ccard-title { font-weight: 650; font-size: 15px; }
.ccard-stats { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; font-size: 13px; color: var(--text-2); }
.ccard .inline-edit .select { width: 130px !important; }
.ccard .inline-edit .input { flex: 1; width: auto !important; }

/* ---------- «Ещё» ---------- */

.menu-list { display: flex; flex-direction: column; margin-bottom: 14px; overflow: hidden; }
.menu-item {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 13px 14px;
  border: 0;
  border-bottom: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.menu-item:last-child { border-bottom: 0; }
.menu-item:hover { background: var(--surface-2); text-decoration: none; }
.menu-icon { display: grid; place-items: center; width: 36px; height: 36px; flex: none; border-radius: 10px; background: var(--surface-3); color: var(--text-2); }
.menu-item.warning .menu-icon { background: var(--warning-soft); color: var(--warning); }
.menu-item.success .menu-icon { background: var(--success-soft); color: var(--success); }
.menu-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; font-weight: 600; font-size: 15px; }
.menu-text .meta { font-weight: 500; font-size: 12.5px; }
.menu-item .chev { color: var(--muted); display: grid; }
.install-hint p { margin: 6px 0 0; color: var(--text-2); }
.install-title { display: flex; align-items: center; gap: 8px; font-weight: 650; }

/* ---------- Вход по PIN ---------- */

.login-page { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 20px; }
.login-card {
  width: 100%;
  max-width: 360px;
  padding: 28px 22px 22px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
}
.login-card p { margin: 0; }
.login-card .brand-mark { width: 52px; height: 52px; border-radius: 14px; font-size: 24px; }
.login-card .pin-input { height: 54px; font-size: 26px; text-align: center; }
.login-card .pin-input:not(:placeholder-shown) { letter-spacing: 0.35em; }
.login-card .btn { width: 100%; height: 48px; font-size: 16px; }
.login-error { min-height: 20px; color: var(--danger); font-weight: 600; }

/* ---------- Мелочи для экрана ---------- */

.scroll-tabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
.scroll-tabs::-webkit-scrollbar { display: none; }
.scroll-tabs a { flex: none; }
.list-search { max-width: 320px; }
.toolbar-gap { flex: 1; }
.sales-link { margin-left: auto; }
input[type="search"] { -webkit-appearance: none; appearance: none; }

/* Сенсорный экран: подсказки клавиш не нужны, плашки на миниатюрах и
   кнопка на снимке заменены кнопками под ним. Лента фото — сразу под
   крупным снимком, чтобы всё для работы с фото было на одном экране. */
@media (hover: none), (pointer: coarse) {
  .kbd, .desktop-hint { display: none !important; }
  .photo-tools { display: flex; }
  .tile .tile-tools, .cover .cover-tools { display: none; }
  .tile { cursor: pointer; }
  .editor-photos > .cover-host { order: 0; }
  .editor-photos > .strip { order: 1; }
  .editor-photos > .photo-tools { order: 2; }
  .editor-photos > .variant-host { order: 3; }
  .editor-photos > .strip-head { order: 4; }
  .editor-photos > .photo-actions { order: 5; }
  /* Вертикальный жест по фото — прокрутка страницы, вбок — ползунок. */
  .compare { touch-action: pan-y; cursor: default; }
  a, button, .tile, .menu-item { -webkit-tap-highlight-color: transparent; }
}

/* ---------- Телефон ---------- */

@media (max-width: 900px) {
  :root { --topbar-h: 52px; --tabbar-h: 58px; }
  html { -webkit-text-size-adjust: 100%; }

  /* Боковое меню распадается: логотип и колокольчик — полоса сверху,
     разделы — вкладки снизу, как в приложениях. */
  .app { display: block; min-height: 100vh; min-height: 100dvh; }
  .sidebar { display: contents; }
  .brand-row {
    position: sticky;
    top: 0;
    z-index: 40;
    display: flex;
    align-items: center;
    gap: 6px;
    height: calc(var(--topbar-h) + env(safe-area-inset-top));
    padding: env(safe-area-inset-top) 10px 0 14px;
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    backdrop-filter: saturate(1.5) blur(12px);
    -webkit-backdrop-filter: saturate(1.5) blur(12px);
    border-bottom: 1px solid var(--border);
  }
  .brand { padding: 0; font-size: 15px; }
  .brand-mark { width: 28px; height: 28px; border-radius: 8px; }
  .topbar-extra { display: flex; align-items: center; gap: 4px; margin-left: auto; }
  .topbar-extra .mode-pill { padding: 4px 8px; font-size: 11.5px; }
  .topbar-extra .bell .spinner { width: 18px; height: 18px; }
  .bell-count.busy { background: var(--accent); }
  .bell { width: 40px; height: 40px; }

  .nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(0, 1fr);
    gap: 0;
    height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
    padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    backdrop-filter: saturate(1.5) blur(12px);
    -webkit-backdrop-filter: saturate(1.5) blur(12px);
    border-top: 1px solid var(--border);
  }
  .nav .nav-desktop { display: none; }
  .nav .nav-mobile { display: flex; }
  .nav a {
    position: relative;
    flex-direction: column;
    justify-content: center;
    gap: 3px;
    padding: 6px 2px 4px;
    border-radius: 0;
    color: var(--muted);
    font-size: 11px;
    font-weight: 600;
  }
  .nav a:hover, .nav a.active { background: transparent; }
  .nav a.active { color: var(--accent-text); }
  .nav a svg.icon { width: 23px; height: 23px; }
  .nav .full { display: none; }
  .nav .short { display: block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .nav .count { position: absolute; top: 4px; left: calc(50% + 5px); min-width: 18px; margin: 0; padding: 0 5px; font-size: 10.5px; line-height: 18px; }
  .nav .count:not(.hot) { display: none; }
  .sidebar-foot { display: none; }

  .main {
    padding: 14px 12px calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 28px);
  }

  /* Карточка объявления или переписка на весь экран: свой заголовок
     с «Назад» и свои кнопки внизу — общие полосы прячутся. */
  body.in-detail .brand-row, body.in-detail .nav { display: none; }
  body.in-detail .main { padding-top: 0; padding-bottom: 0; }

  /* Крупнее и удобнее для пальца. 16px в полях — иначе iPhone
     увеличивает страницу при вводе. */
  .page-head { gap: 8px 10px; margin-bottom: 14px; }
  h1 { font-size: 21px; }
  .btn { height: 40px; }
  .btn.sm { height: 34px; padding: 0 11px; font-size: 13.5px; }
  .btn.icon-only { width: 40px; }
  .btn.sm.icon-only { width: 34px; }
  .input, .select { height: 42px; font-size: 16px; }
  .textarea { font-size: 16px; }
  .input.title-input { height: 44px; font-size: 16px; }
  .inline-edit .input, .inline-edit .select { height: 38px; }
  .segmented button { height: 32px; }
  .check input { width: 20px; height: 20px; }
  .card-head { padding: 12px 14px; }
  .card-body, .card-pad { padding: 14px; }

  /* Окна — листами снизу экрана, кнопки на всю ширину. */
  .modal-backdrop { place-items: end stretch; padding: 0; }
  .modal {
    width: 100%;
    max-width: none;
    max-height: 92vh;
    max-height: 92dvh;
    overflow-y: auto;
    border-radius: 18px 18px 0 0;
    padding: 12px 16px calc(16px + env(safe-area-inset-bottom));
    animation: sheet-up 0.2s ease-out;
  }
  .modal::before {
    content: "";
    align-self: center;
    width: 38px;
    height: 4px;
    margin-bottom: 4px;
    border-radius: 2px;
    background: var(--border-strong);
  }
  .modal > .btn-row { flex-direction: column-reverse; align-items: stretch; }
  .modal > .btn-row .btn { height: 46px; font-size: 15px; }

  /* Сообщения — внизу над кнопками и не ловят нажатия: сверху они
     закрывали бы «Назад» в заголовке карточки. */
  .toasts {
    top: auto;
    bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 12px);
    left: 10px;
    right: 10px;
    transform: none;
    flex-direction: column-reverse;
  }
  body.in-detail .toasts { bottom: calc(84px + env(safe-area-inset-bottom)); }
  .toast { max-width: 100%; pointer-events: none; }
  @keyframes toast-in { from { opacity: 0; transform: translateY(6px); } }

  .notice-panel {
    left: 8px;
    right: 8px;
    top: calc(var(--topbar-h) + env(safe-area-inset-top) + 6px);
    width: auto;
    max-width: none;
    max-height: calc(100dvh - var(--topbar-h) - var(--tabbar-h) - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 20px);
  }

  /* Панель задач — над вкладками во всю ширину. */
  .dock {
    left: 8px;
    right: 8px !important;
    width: auto;
    max-width: none;
    bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 8px) !important;
  }
  .dock-head { cursor: default; }
  .dock-list { max-height: 38vh; }
  body.in-detail .dock { bottom: calc(80px + env(safe-area-inset-bottom)) !important; }

  /* Главная */
  .page-head .head-action { flex: 1 1 100%; }
  .stages { grid-template-columns: minmax(0, 1fr); gap: 10px; margin-bottom: 14px; }
  .stage {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "top num" "note num" "action action";
    gap: 2px 12px;
    padding: 14px;
  }
  .stage-top { grid-area: top; }
  .stage-num { grid-area: num; align-self: center; font-size: 30px; }
  .stage-note { grid-area: note; min-height: 0; }
  .stage-action { grid-area: action; margin-top: 10px; }
  .stage-arrow { display: none; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sales-link { margin-left: 0; }

  /* Проверка: очередь крупнее, отметка — под палец. */
  .queue-head { padding: 10px; }
  .queue-list { padding: 4px; }
  .queue-row { grid-template-columns: 36px minmax(0, 1fr); padding-left: 2px; }
  .queue-row > input[type="checkbox"] { width: 22px; height: 22px; justify-self: center; }
  .queue-item { grid-template-columns: 56px minmax(0, 1fr); gap: 12px; padding: 8px 8px 8px 2px; }
  .queue-item .thumb { width: 56px; height: 74px; }
  .queue-item .q-title { font-size: 14px; }
  .queue-item .q-price { font-size: 14px; }
  .queue-item .badge { height: 21px; font-size: 11.5px; }

  /* Выбранные — панель над вкладками: выбор, решение, ИИ. */
  .bulkbar {
    position: fixed;
    top: auto;
    left: 8px;
    right: 8px;
    bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 8px);
    z-index: 45;
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 6px;
    margin: 0;
    padding: 10px;
  }
  .bulkbar .bulk-sep, .bulkbar .spacer { display: none; }
  .bulkbar .bulk-title { grid-column: span 4; align-self: center; }
  .bulkbar .bulk-clear { grid-column: span 2; order: 1; }
  .bulkbar .bulk-main { grid-column: span 2; order: 2; }
  .bulkbar .bulk-ai { grid-column: span 3; order: 3; }
  .bulkbar .btn { width: 100%; padding: 0 6px; }

  /* Карточка объявления во весь экран, без рамок по бокам. */
  body.in-detail .editor-card {
    margin: 0 -12px calc(76px + env(safe-area-inset-bottom));
    border-radius: 0;
    border-left: 0;
    border-right: 0;
    border-top: 0;
  }
  body.in-detail .editor-card > :first-child { border-radius: 0; }
  .editor-head {
    gap: 4px 6px;
    padding: calc(6px + env(safe-area-inset-top)) 8px 6px;
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
  }
  .editor-head .crumbs {
    order: 10;
    flex: 1 0 100%;
    flex-wrap: nowrap;
    gap: 6px;
    overflow: hidden;
    white-space: nowrap;
    font-size: 12px;
    padding: 0 4px;
  }
  .editor-head .crumbs > * { flex: none; }
  .editor-head .crumbs strong { font-size: 12.5px; }
  .editor-head .crumbs .badge { height: 20px; font-size: 11px; }
  .editor-nav { gap: 4px; }
  .save-state { min-width: 0; font-size: 12px; }
  .editor { padding: 12px; gap: 18px; }
  .cover { max-height: 58vh; max-height: 58dvh; }
  .cover-host { scroll-margin-top: 80px; }

  /* Кнопки решения — всегда под пальцем внизу экрана. */
  .editor-card > .actionbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 35;
    flex-wrap: nowrap;
    gap: 8px;
    padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
    border-radius: 0;
    background: color-mix(in srgb, var(--surface) 95%, transparent);
    box-shadow: 0 -6px 22px rgba(16, 24, 40, 0.1);
  }
  .editor-card > .actionbar .spacer, .editor-card > .actionbar .hint { display: none; }
  .editor-card > .actionbar .btn {
    flex: 0 0 auto;
    flex-direction: column;
    gap: 2px;
    height: 54px;
    min-width: 64px;
    padding: 0 8px;
    font-size: 11.5px;
  }
  .editor-card > .actionbar .btn svg.icon { width: 20px; height: 20px; }
  .editor-card > .actionbar .btn.lg { flex: 1 1 auto; flex-direction: row; gap: 8px; font-size: 16px; padding: 0 14px; }
  .editor-card > .actionbar:has(.btn.lg) .olx-link { display: none; }
  .olx-box { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  /* Переписка во весь экран. */
  body.in-detail .conversation {
    margin: 0 -12px;
    min-height: 100vh;
    min-height: 100dvh;
    border-radius: 0;
    border-left: 0;
    border-right: 0;
    border-top: 0;
  }
  body.in-detail .conv-top { border-radius: 0; }
  body.in-detail .conv-head { padding-top: calc(8px + env(safe-area-inset-top)); }
  body.in-detail .composer { border-radius: 0; padding: 8px 10px calc(8px + env(safe-area-inset-bottom)); }
  .messages { padding: 12px; }
  .bubble { max-width: 86%; }
  .composer .btn { height: 44px; }
  .deal-bar { padding: 10px 12px; }
  .deal-bar .field-label { display: none; }
  .deal-bar .segmented { width: 100%; }
  .deal-bar .segmented button { flex: 1; }
  .deal-amount { width: auto; flex: 1 1 110px; }
  .deal-note { flex: 2 1 160px; }

  /* Настройки: кнопка «Сохранить» над вкладками. */
  .settings-save-host { bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 10px); }
  .settings-save { padding: 10px 12px; }
  .setting-row .segmented { flex-wrap: wrap; }
  .lan-box { flex-direction: column; align-items: stretch; text-align: center; }
  .lan-qr { width: 190px; height: 190px; align-self: center; }
}

@media (max-width: 760px) {
  .row > .field { flex-basis: 100%; }
  .list-search { max-width: none; flex: 1 1 100%; }
  .toolbar-gap { display: none; }
  .list-toolbar > .btn-row { width: 100%; }
  .list-toolbar > .btn-row .btn { flex: 1 1 auto; }
  .tabs { margin-left: -12px; margin-right: -12px; padding: 0 8px; }
  /* Лента фото — одной строкой, листается вбок. */
  .strip {
    display: flex;
    overflow-x: auto;
    gap: 8px;
    padding: 4px;
    margin: -4px;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
  }
  .strip::-webkit-scrollbar { display: none; }
  .strip .tile { flex: 0 0 66px; scroll-snap-align: start; }
  .prices { padding: 12px; gap: 10px; }
}

@keyframes sheet-up { from { transform: translateY(28px); opacity: 0.6; } }
