/**
 * UNIFIED ORDER FEED v3 — изолированные стили (префикс .ofv3-)
 * Не пересекаются с .oft-*, .olc-*, .master-*, .order-*
 */

/* Кабинет мастера v3-only: OFT-root в DOM только для API (hide), не показываем */
body.master-feed-v3-only #masterFeedOftRoot,
body.master-feed-v3-only #masterFeedOftRoot.master-feed-oft-root--hidden-api {
  display: none !important;
  visibility: hidden;
  height: 0 !important;
  min-height: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  overflow: hidden !important;
  pointer-events: none;
}

/* Активная v3: дополнительно скрываем legacy-контейнер */
#panel-feed.master-feed-v3-pilot-active #masterFeedOftRoot {
  display: none !important;
}

/* Плашка ошибки legacy-загрузчика не показываем поверх v3 */
#panel-feed.master-feed-v3-pilot-active #master-feed-error {
  display: none !important;
}

.ofv3-host {
  margin-top: 16px;
  padding: 12px 0 20px;
  border-top: 1px dashed var(--border, #e2e8f0);
}

/* Компактная лента: меньше вертикали до карточек */
#panel-feed.master-feed-v3-pilot-active .ofv3-host {
  margin-top: 2px;
  padding: 0 0 10px;
  border-top: none;
}

.ofv3-host[hidden] {
  display: none !important;
}

.ofv3-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  color: #4338ca;
  background: #eef2ff;
  border: 1px solid #c7d2fe;
  border-radius: 10px;
  padding: 8px 12px;
  margin-bottom: 12px;
}

.ofv3-banner--pilot {
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  row-gap: 10px;
}

.ofv3-banner-title {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 auto;
  min-width: 0;
}

.ofv3-banner-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  flex-shrink: 0;
}

#panel-feed.master-feed-v3-pilot-active .ofv3-toolbar {
  margin-top: 0;
  margin-bottom: 6px;
  gap: 6px;
}

#panel-feed.master-feed-v3-pilot-active .ofv3-list {
  gap: 8px;
}

/* Баннер закрытого доступа мастера (v2 лента) — рядом с .ofv3-banner */
.ofv3-banner--access {
  flex-wrap: wrap;
  align-items: flex-start;
  color: #9a3412;
  background: #fff7ed;
  border-color: #fdba74;
}
.ofv3-banner--access .ofv3-banner-title {
  color: #9a3412;
}
.ofv3-banner--access .ofv3-banner-sub {
  display: block;
  width: 100%;
  flex: 1 0 100%;
  font-weight: 500;
  font-size: 12px;
  line-height: 1.45;
  color: #7c2d12;
  margin-top: 6px;
}

.ofv3-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
}

.ofv3-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 8px;
  border: 1px solid var(--border, #e2e8f0);
  background: var(--card, #fff);
  color: var(--text, #0f172a);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.ofv3-btn:hover:not(:disabled) {
  background: var(--hover, #f8fafc);
  border-color: #cbd5e1;
}

.ofv3-btn:focus {
  outline: none;
}

.ofv3-btn:focus-visible {
  outline: 2px solid #6366f1;
  outline-offset: 2px;
}

.ofv3-host[aria-busy='true'] .ofv3-skel {
  opacity: 0.92;
}

.ofv3-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.ofv3-btn--primary {
  background: #4f46e5;
  border-color: #4f46e5;
  color: #fff;
}

.ofv3-btn--primary:hover:not(:disabled) {
  background: #4338ca;
  border-color: #4338ca;
}

.ofv3-btn--sm {
  padding: 5px 10px;
  font-size: 11px;
}

/* вторичное действие (напр. «Скрыть из ленты») */
.ofv3-btn--ghost {
  font-weight: 500;
  color: var(--muted, #64748b);
  border-color: #e5e7eb;
  background: #fafafa;
}

.ofv3-btn--ghost:hover:not(:disabled) {
  background: #f1f5f9;
  border-color: #cbd5e1;
}

.ofv3-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ofv3-card {
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 12px;
  padding: 12px 14px;
  background: var(--card, #fff);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.ofv3-card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.ofv3-card-id {
  font-size: 13px;
  font-weight: 700;
  color: var(--text, #0f172a);
}

.ofv3-card-status {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
  white-space: nowrap;
}

.ofv3-card-status--neutral {
  background: #f1f5f9;
  color: #475569;
}

.ofv3-card-status--success {
  background: #d1fae5;
  color: #065f46;
}

.ofv3-card-status--warning {
  background: #fef3c7;
  color: #b45309;
}

.ofv3-card-status--danger {
  background: #fee2e2;
  color: #991b1b;
}

.ofv3-card-body {
  font-size: 13px;
  line-height: 1.45;
  color: var(--text, #334155);
}

.ofv3-card-meta {
  font-size: 12px;
  color: var(--muted, #64748b);
  margin-top: 6px;
}

.ofv3-card-meta--hint {
  font-size: 11px;
  line-height: 1.35;
  word-break: break-word;
}

.ofv3-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
  max-width: 100%;
}

/* ═══════════════════════════════════════════════════════════
   Premium v3 card (master feed) — layout aligned with aggregator card
   HTML built in js/order-feed-v3.js::renderOrderCardV3
   ═══════════════════════════════════════════════════════════ */

.ofv3-card.ofv3-card--premium {
  border-radius: 26px;
  border: 1px solid rgba(226, 232, 240, 0.85);
  box-shadow: 0 4px 22px rgba(15, 23, 42, 0.07), 0 1px 3px rgba(15, 23, 42, 0.04);
  padding: 0;
  overflow: hidden;
  background: #fff;
  max-width: min(100%, 680px);
  margin-left: auto;
  margin-right: auto;
}

.ofv3-card.ofv3-card--premium:hover {
  box-shadow: 0 12px 36px rgba(15, 23, 42, 0.09), 0 4px 12px rgba(99, 102, 241, 0.08);
  border-color: rgba(99, 102, 241, 0.22);
}

.ofv3p-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 16px 18px 12px;
  background: #fff;
  border-bottom: 1px solid rgba(241, 245, 249, 0.95);
}

.ofv3p-top-left {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  min-width: 0;
}

.ofv3p-top-right {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  flex-shrink: 0;
  max-width: 58%;
}

.ofv3p-live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ef4444;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.2);
  flex-shrink: 0;
}

.ofv3p-time--empty {
  opacity: 0.45;
}

.ofv3p-time {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted, #64748b);
  white-space: nowrap;
}

.ofv3p-time i {
  font-size: 11px;
  opacity: 0.85;
}

.ofv3p-body {
  padding: 4px 18px 0;
}

.ofv3p-title {
  margin: 0;
  padding: 0 0 4px;
  font-size: clamp(17px, 2.1vw, 21px);
  font-weight: 800;
  line-height: 1.25;
  letter-spacing: -0.02em;
  color: var(--text, #0f172a);
}

.ofv3p-title .ofv3-pill {
  vertical-align: middle;
}

.ofv3p-brand-line {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted, #64748b);
}

.ofv3p-brand-name {
  color: #4f46e5;
  font-weight: 800;
}

.ofv3p-problem {
  margin-top: 4px;
  font-size: 14px;
  font-weight: 600;
  color: #334155;
  line-height: 1.45;
}

.ofv3p-desc {
  margin-top: 6px;
  font-size: 13px;
  color: var(--muted, #64748b);
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.ofv3p-infogrid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0;
  margin-top: 10px;
  padding: 6px 4px;
  background: #f8fafc;
  border: 1px solid rgba(226, 232, 240, 0.9);
  border-radius: 13px;
}

.ofv3p-infocol {
  padding: 6px 8px;
  min-width: 0;
  min-height: 48px;
  box-sizing: border-box;
  border-right: 1px solid rgba(226, 232, 240, 0.85);
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.ofv3p-infocol:last-child {
  border-right: none;
}

.ofv3p-infolabel {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: #94a3b8;
  margin-bottom: 3px;
  line-height: 1.2;
}

.ofv3p-infolabel i {
  font-size: 10px;
  opacity: 0.85;
  color: #22c55e;
}

.ofv3p-infocol--when .ofv3p-infolabel i {
  color: #6366f1;
}

.ofv3p-infocol--money .ofv3p-infolabel i {
  color: #7c3aed;
}

.ofv3p-infoval--primary {
  font-size: 14px;
  font-weight: 800;
  color: var(--text, #0f172a);
  line-height: 1.25;
  word-break: break-word;
}

.ofv3p-infoval--secondary {
  margin-top: 2px;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted, #64748b);
  line-height: 1.25;
}

.ofv3p-infocol--money {
  justify-content: center;
  min-height: 64px;
  max-height: 76px;
  margin: 2px 4px;
  padding: 6px 8px;
  background: #fff;
  border: 1px solid rgba(226, 232, 240, 0.95);
  border-radius: 11px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.ofv3p-infocol--money .ofv3p-infolabel {
  font-size: 11px;
  margin-bottom: 2px;
  letter-spacing: 0.02em;
  text-transform: none;
  font-weight: 700;
  color: #64748b;
}

.ofv3p-infocol--money .ofv3p-infoval--primary {
  font-size: 19px;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.ofv3p-infocol--money .ofv3p-infoval--muted {
  margin-top: 4px;
  display: inline-flex;
  align-self: flex-start;
  padding: 2px 7px;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #5b21b6;
  background: rgba(139, 124, 255, 0.12);
  border: 1px solid rgba(139, 124, 255, 0.22);
  border-radius: 999px;
  line-height: 1.2;
}

.ofv3-privacy,
.ofv3p-body .ofv3-privacy,
.ofv3p-privacy {
  margin-top: 12px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(219, 234, 254, 0.45);
  border: 1px solid rgba(147, 197, 253, 0.55);
  color: #1e3a8a;
  font-size: 12px;
  line-height: 1.35;
}

.ofv3-privacy i,
.ofv3p-privacy i {
  color: #2563eb;
  margin-top: 2px;
}

.ofv3p-photo {
  position: relative;
  margin-top: 14px;
  border-radius: 20px;
  overflow: hidden;
  background: #f1f5f9;
  border: 1px solid rgba(226, 232, 240, 0.85);
  max-width: 100%;
}

.ofv3p-photo--has-img img {
  width: 100%;
  height: min(220px, 42vw);
  min-height: 160px;
  object-fit: cover;
  display: block;
}

.ofv3p-photo--placeholder {
  min-height: 168px;
  background: linear-gradient(135deg, #eef2ff 0%, #f8fafc 45%, #ede9fe 100%);
  border: 1px dashed rgba(99, 102, 241, 0.25);
}

.ofv3p-photo-ph-inner {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(79, 70, 229, 0.35);
  font-size: 48px;
}

.ofv3p-photo-badge {
  position: absolute;
  bottom: 12px;
  right: 12px;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  backdrop-filter: blur(6px);
}

.ofv3p-photo-badge i {
  font-size: 12px;
}

.ofv3p-lower-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px 8px;
  padding: 8px 0 6px;
  align-items: stretch;
}

.ofv3p-meta-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 40px;
  padding: 5px 8px;
  box-sizing: border-box;
  font-size: 12px;
  font-weight: 700;
  color: var(--text, #0f172a);
  line-height: 1.25;
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid rgba(226, 232, 240, 0.85);
  border-radius: 12px;
}

.ofv3p-meta-chip i {
  font-size: 12px;
  color: #6366f1;
  opacity: 0.85;
  flex-shrink: 0;
}

.ofv3p-meta-chip--muted {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted, #64748b);
}

.ofv3p-lower-meta .ofv3p-meta-chip:nth-of-type(2):last-child,
.ofv3p-lower-meta .ofv3p-meta-chip:last-child {
  grid-column: 1 / -1;
}

.ofv3p-kv {
  background: #fff;
  border: 1px solid rgba(226, 232, 240, 0.95);
  border-radius: 14px;
  padding: 10px 12px;
  min-width: 0;
}

.ofv3p-kv--chip {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 10px;
  min-height: 40px;
  border-radius: 12px;
  box-sizing: border-box;
}

.ofv3p-kv--chip .ofv3p-k {
  margin-bottom: 0;
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: 800;
  color: #94a3b8;
}

.ofv3p-kv--chip .ofv3p-v {
  font-size: 15px;
  font-weight: 900;
  color: var(--text, #0f172a);
}

.ofv3p-k {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted, #94a3b8);
  margin-bottom: 6px;
}

.ofv3p-v {
  font-size: 13px;
  font-weight: 800;
  color: var(--text, #0f172a);
}

.ofv3p-footer {
  padding: 0 0 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  color: var(--muted, #64748b);
  font-size: 10px;
}

.ofv3p-footer--meta {
  padding-bottom: 4px;
}

.ofv3p-foot-item {
  white-space: nowrap;
}

@media (max-width: 720px) {
  .ofv3p-infogrid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
    padding: 6px;
    margin-top: 8px;
  }

  .ofv3p-infocol {
    min-height: 44px;
    padding: 5px 6px;
    border-right: none;
    border-bottom: none;
  }

  .ofv3p-infocol:nth-child(1) {
    border-right: 1px solid rgba(226, 232, 240, 0.85);
  }

  .ofv3p-infocol--money {
    grid-column: 1 / -1;
    margin: 2px 0 0;
    max-height: none;
    min-height: 60px;
    border-top: 1px solid rgba(226, 232, 240, 0.75);
    padding-top: 8px;
  }

  .ofv3p-photo--has-img img {
    min-height: 120px;
    height: min(180px, 38vw);
  }

  .ofv3p-photo--placeholder {
    min-height: 120px;
  }

  .ofv3p-photo-ph-inner {
    font-size: 36px;
  }

  .ofv3p-lower-meta {
    gap: 5px 6px;
    padding: 6px 0 4px;
  }

  .ofv3p-meta-chip,
  .ofv3p-kv--chip {
    min-height: 36px;
    padding: 4px 7px;
    font-size: 11px;
    border-radius: 11px;
  }

  .ofv3-card.ofv3-card--premium {
    border-radius: 22px;
    max-width: 100%;
    margin-left: 0;
    margin-right: 0;
  }
}

.ofv3-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 800;
  margin-left: 8px;
  border: 1px solid transparent;
}

.ofv3-pill--hot {
  background: rgba(239, 68, 68, 0.10);
  color: #b91c1c;
  border-color: rgba(239, 68, 68, 0.18);
}

.ofv3-pill--today {
  background: rgba(245, 158, 11, 0.12);
  color: #92400e;
  border-color: rgba(245, 158, 11, 0.22);
}

.ofv3-btn--accent {
  background: linear-gradient(135deg, #6366f1, #7c3aed);
  border-color: rgba(99, 102, 241, 0.65);
  color: #fff;
}

.ofv3-btn--accent:hover:not(:disabled) {
  background: linear-gradient(135deg, #4f46e5, #6d28d9);
  border-color: rgba(79, 70, 229, 0.75);
}

/* Кнопка «Откликнуться»: стабильная ширина, без дёрганья при смене текста */
.ofv3-btn[data-ofv3-action='respond'] {
  min-width: 11.25rem;
  justify-content: center;
  transition:
    background 0.18s ease,
    border-color 0.18s ease,
    color 0.18s ease,
    opacity 0.18s ease;
}

.ofv3-btn.ofv3-btn--pending:disabled {
  opacity: 1;
  cursor: wait;
}

.ofv3-btn.ofv3-btn--respond-sent:disabled {
  opacity: 1;
  cursor: default;
  background: linear-gradient(135deg, #059669, #0d9488);
  border-color: rgba(5, 150, 105, 0.55);
  color: #fff;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
}

.ofv3-btn.ofv3-btn--respond-sent:disabled:hover {
  background: linear-gradient(135deg, #059669, #0d9488);
  border-color: rgba(5, 150, 105, 0.55);
}

.ofv3-card.ofv3-card--premium .ofv3-card-actions {
  padding: 12px 14px 14px;
  border-top: 1px solid rgba(226, 232, 240, 0.9);
  background: linear-gradient(180deg, rgba(248, 250, 252, 0.92), #fff);
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.ofv3-card.ofv3-card--premium .ofv3-card-actions .ofv3-btn {
  border-radius: 12px;
  padding: 9px 12px;
  font-size: 13px;
}

@media (max-width: 900px) {
  .ofv3p-main {
    grid-template-columns: 1fr 210px;
  }
  .ofv3p-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 600px) {
  .ofv3p-main {
    grid-template-columns: 1fr;
    grid-template-areas:
      "left"
      "right"
      "addr"
      "grid";
  }
  .ofv3p-photo img {
    height: 140px;
  }
  .ofv3p-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.ofv3-empty,
.ofv3-error {
  text-align: center;
  padding: 28px 16px;
  border-radius: 12px;
  border: 1px dashed var(--border, #e2e8f0);
  font-size: 14px;
  color: var(--muted, #64748b);
}

.ofv3-error {
  border-color: #fecaca;
  background: #fef2f2;
  color: #991b1b;
}

.ofv3-error-retry {
  margin-top: 12px;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
}

.ofv3-skel {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ofv3-skel-line {
  height: 14px;
  border-radius: 6px;
  background: linear-gradient(90deg, #f1f5f9 0%, #e2e8f0 50%, #f1f5f9 100%);
  background-size: 200% 100%;
  animation: ofv3-skel 1.2s ease-in-out infinite;
}

.ofv3-skel-line--short {
  width: 40%;
}

.ofv3-skel-line--med {
  width: 70%;
}

@keyframes ofv3-skel {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ofv3-skel-line {
    animation: none;
    background: #f1f5f9;
  }
}

.ofv3-toast-host {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 12000;
  max-width: min(420px, 92vw);
  pointer-events: none;
}

.ofv3-toast {
  pointer-events: auto;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
  border: 1px solid transparent;
}

.ofv3-toast--info {
  background: #f8fafc;
  color: #0f172a;
  border-color: #e2e8f0;
}

.ofv3-toast--success {
  background: #ecfdf5;
  color: #065f46;
  border-color: #a7f3d0;
}

.ofv3-toast--error {
  background: #fef2f2;
  color: #991b1b;
  border-color: #fecaca;
}

@media (max-width: 640px) {
  .ofv3-card-head {
    flex-direction: column;
    align-items: stretch;
  }
}

@media (max-width: 400px) {
  .ofv3-host {
    padding-left: 0;
    padding-right: 0;
    overflow-x: hidden;
  }
  .ofv3-toolbar {
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    padding-bottom: 4px;
  }
  .ofv3-card {
    max-width: 100%;
    box-sizing: border-box;
    overflow-wrap: anywhere;
  }
  .ofv3-card-actions .ofv3-btn {
    flex: 1 1 auto;
    min-width: 0;
    justify-content: center;
  }
}
