/* ─── catalog-card ─────────────────────────────────────
 * The catalog's main component (A2 web / B2 TMA / D admin area).
 * Reuses .metric from design-system/components/metric.css.
 * Fixed skeleton: slots are always in place, even when data is absent.
 * Single source of truth — consuming files load this CSS
 * through <link> (shared-component pattern).
 * ───────────────────────────────────────────────────── */

/* Card container */
.catalog-card {
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  gap: 14px;
  padding: 16px;
  background: var(--color-card-surface);
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-lg);
  max-width: 480px;
  transition: border-color var(--duration-fast) var(--ease-out),
              transform var(--duration-fast) var(--ease-out);
}
.catalog-card:hover {
  border-color: var(--color-primary);
  transform: translateY(-1px);
}
.catalog-card:focus-within {
  outline: 2px solid var(--color-amber);
  outline-offset: 2px;
}
/* R2-10: when the card is an <a> (catalog page in production) — focus-visible on the wrapper */
.catalog-card:focus-visible {
  outline: 2px solid var(--color-amber);
  outline-offset: 2px;
}
@media (prefers-reduced-motion: reduce) {
  .catalog-card,
  .catalog-card * {
    transition: none !important;
    animation: none !important;
  }
  .catalog-card:hover { transform: none; }
}

/* Header: avatar + title block + meta (3-row auto-flow grid) */
.catalog-card__header {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: start;
  gap: 6px 12px;
  min-width: 0;
}
/* The avatar is the initials as its own content, with the image laid OVER them (F1a): a null
 * address renders no image, and a failed image leaves the initials visible (F1b). Muted-bg
 * circle — never the success-bg, which is the status chip's colour (catalog-card-spec).
 * (TASK-119: our own overlay mechanism, not the mockup's flex-sibling img — I9.) */
.catalog-card__avatar {
  grid-row: 1 / span 2;
  align-self: center;
  position: relative;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--color-muted-bg, var(--color-surface));
  color: var(--color-ink);
  font: 700 18px/1 var(--font-ui);
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}
.catalog-card__avatar img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}
.catalog-card__title-block {
  grid-column: 2;
  grid-row: 1;
  min-width: 0;
}
.catalog-card__meta {
  grid-column: 2;
  grid-row: 2;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 0;
}
.catalog-card__title-block {
  min-width: 0;
}
.catalog-card__title {
  font: 600 16px/1.3 var(--font-ui);
  color: var(--color-ink);
  letter-spacing: -0.01em;
  margin: 0 0 4px 0;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
  text-overflow: ellipsis;
  word-break: break-word;
}
/* The title's own link (ours — the mockup's card is not an <a>; TASK-119 keeps the class the
 * card has shipped since TASK-098). */
.catalog-card__title-link {
  color: inherit;
  text-decoration: none;
}
.catalog-card__title-link:hover {
  text-decoration: underline;
}
.catalog-card__handle {
  font: 400 13px/1.3 var(--font-ui);
  color: var(--color-ink-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* username slot — if the username is absent (private channel), show a placeholder with a lock
   icon so the skeleton does not collapse */
.catalog-card__handle--private {
  color: var(--color-ink-3);
  font-style: italic;
  opacity: 0.7;
}
.catalog-card__handle--private i {
  font-size: 12px;
  vertical-align: -1px;
  margin-right: 2px;
}
/* The closed state our card emits (DEBT-238 spells the same predicate in the class) */
.catalog-card__handle--closed {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.catalog-card__handle--closed i {
  font-size: 12px;
  vertical-align: -1px;
}

/* Meta: category · language */
.catalog-card__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  font: 500 11px/1 var(--font-ui);
  color: var(--color-ink-3);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.catalog-card__chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  border: 1px solid var(--color-divider);
  font: 500 11px/1 var(--font-ui);
  color: var(--color-ink-2);
  letter-spacing: 0.02em;
  text-transform: uppercase;
  white-space: nowrap;
}
.catalog-card__chip i {
  font-size: 12px;
}

/* Body: metrics via .metric (reusing the metric block) */
.catalog-card__body {
  display: grid;
  gap: 8px;
  min-width: 0;
}
.catalog-card__body .metric {
  padding: 10px 12px;
  gap: 2px;
}
.catalog-card__body .metric__label {
  font-size: 11px;
  color: var(--color-ink-3);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.catalog-card__body .metric__value {
  font-size: 18px;
  line-height: 1.2;
  font-weight: 600;
}
.catalog-card__body .metric__unit {
  font-size: 12px;
}
.catalog-card__body .metric__sample {
  font-size: 10px;
}
.catalog-card__body .metric__source {
  font-size: 10px;
}

/* Catalog offer zone: price is the action anchor. */
.catalog-card__offer {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0 0;
  margin-top: 4px;
  border-top: 0;
  min-width: 0;
  /* background: var(--color-page) removed — double background under the price
     (milky offer + beige price-zone). Spec: #EFE8DE only for the price-zone,
     the surround stays flat (the card shows through). */
}
.catalog-card__offer-copy { min-width: 0; }
.catalog-card__offer-copy .metric__label { display: block; font: 500 11px/1.2 var(--font-ui); color: var(--color-ink-2); text-transform: uppercase; }
:root[data-theme="dark"] .catalog-card__offer-copy .metric__label { color: var(--color-ink-3); }
.catalog-card__offer-copy .metric__value { display: flex; align-items: baseline; gap: 4px; font: 700 22px/1.1 var(--font-num); color: var(--color-offer-price); }
.catalog-card__offer-copy .metric__value [data-num] { font: inherit; }
.catalog-card__offer-copy .metric__unit { font: 500 12px/1.2 var(--font-ui); color: var(--color-ink-2); }
.catalog-card__offer-copy .metric__footer { margin-top: 3px; font: 400 10px/1.2 var(--font-ui); color: var(--color-ink-3); }
/* TASK-119 — I8 requires an anchor: an <a>'s default display: inline ignores min-height and
   vertical padding, so the CTA is an inline-flex box or it renders wrong at every width. */
.catalog-card__offer-cta { appearance: none; display: inline-flex; align-items: center; flex: 0 0 auto; min-height: 36px; padding: 0 14px; border: 0; border-radius: var(--radius-md); background: var(--color-primary); color: var(--color-primary-fg); font: 600 13px/1 var(--font-ui); cursor: pointer; text-decoration: none; }
.catalog-card__offer-cta:focus-visible { outline: 2px solid var(--color-amber); outline-offset: 2px; }
@media (max-width: 768px) {
  .catalog-card__offer { align-items: flex-start; }
  /* TASK-121 (item 5) — the mockup's ≤768 band is FULL TEXT (a2-catalog.html:1708); this rule
   * used to collapse the CTA to a 36px «›» square, which the band no longer is. The
   * data-view-specific full-text rules below govern the storefront's grids; this is the base
   * for a CTA rendered outside them. */
}

/* Footer: created_at · admin marker */
.catalog-card__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font: 400 11px/1.3 var(--font-ui);
  color: var(--color-ink-3);
  padding-top: 8px;
  border-top: 1px solid var(--color-divider);
  letter-spacing: 0;
}
.catalog-card__footer i {
  font-size: 12px;
  vertical-align: -1px;
  margin-right: 4px;
}
.catalog-card__admin-ok {
  color: var(--color-success);
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

/* ─── TASK-120 — the A2 density system, ported from design/components/a2-catalog.html ───
 *
 * The mockup's page CSS rebuilds the shared card for the catalog's two views. These rules
 * are the CARD half of that port; the `.catalog-grid[data-view=…]` CONTAINER rules, which
 * name no card class, stay in `apps/web/src/public-catalog.css`. The mockup's `.grid` class
 * is our `.catalog-grid`, and the mockup's JS scaffolding (the config popover, the expand
 * caret, the offer actions, the chip-fit scripts) has no shipped counterpart here.
 */

/* Body: a flex column stretching to the card's height, so the offer zone's margin-top:auto
   pins the bottom of every card in a row (ТЗ v5 — long titles and two-line metas no longer
   push one card's price down). */
.catalog-card__body {
  flex: 1 0 auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.catalog-card__body .metric {
  background: transparent;
  border: 0;
  border-radius: 0;
  padding: 0;
}
:root[data-theme="dark"] .catalog-card__body .metric {
  background: transparent;
  border: 0;
}

.catalog-card__body .metric__value {
  font-weight: 700;
}
.catalog-card__body .metric__sample {
  font-size: 12px;
  line-height: 1.4;
}
/* The empty value slot: «—» quietly (ink-2), no eye, no bold explanation — the mockup's own
   reference cards render this state (ТЗ v4). */
.catalog-card__body .metric--insufficient .metric__value {
  color: var(--color-ink-2);
}

.catalog-card__footer {
  font: 400 12px/1.3 var(--font-ui);
}

/* The grid card: a flex column filling its row. The base `.catalog-card` is a grid with
   `max-width: 480`; the mockup's tile/list overrides set max-width none and flex. */
.catalog-grid > .catalog-card-wrap {
  display: contents;
}
.catalog-grid .catalog-card {
  max-width: none;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.catalog-grid .catalog-card__offer {
  margin-top: auto;
  background: transparent;
}

/* The ERR | on-time | reliability split (TASK-237): one block instead of three metrics,
   three equal columns with 1px dividers, empty state «—» quietly with the threshold in the
   sample. */
.catalog-card__split {
  display: flex;
  align-items: stretch;
  min-width: 0;
}
.catalog-card__split-col {
  /* TASK-237 / ADR-177 — three equal shares (the mockup's `flex: 1 1 0`). */
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 0;
}
.catalog-card__split-divider {
  flex: none;
  width: 1px;
  background: var(--color-divider);
  margin: 10px 8px;
}
:root[data-theme="dark"] .catalog-card__split-divider {
  background: var(--color-divider-dark);
}
.catalog-card__split .metric__header {
  display: flex;
  align-items: center;
  gap: 6px;
  justify-content: space-between;
  /* Both columns on one height: the left has the info icon (18px), the right does not —
     without a min-height the headers sit at different heights and the values drift. */
  min-height: 18px;
}
.catalog-card__split .metric__label {
  font-size: 9px;
  color: var(--color-ink-3);
  letter-spacing: 0.01em;
  text-transform: uppercase;
  display: inline-flex;
  align-items: baseline;
  gap: 2px;
  /* «ERR» always on one line: the split columns share a horizontal height. */
  white-space: nowrap;
}
.catalog-card__split .metric__label .metric__specifier {
  margin-left: 0;
}
.catalog-card__split .metric__value {
  font: 700 18px/1.2 var(--font-num);
  color: var(--color-ink);
  min-height: 24px;
}
.catalog-card__split .metric__footer {
  font: 400 12px/1.4 var(--font-ui);
  color: var(--color-ink-3);
}
/* TASK-237 — in a third of the card «47 из 49 размещений» and the threshold line do not fit on
   one line: wrap by words instead of metric.css's ellipsis (the mockups' unscoped rule). */
.catalog-card__split .metric__sample { white-space: normal; }
.catalog-card__split .metric__info {
  margin-left: 4px;
  font-size: 13px;
  color: var(--color-ink-3);
  display: inline-flex;
  align-items: center;
}
.catalog-card__split-col--empty .metric__value {
  color: var(--color-ink-2);
}

/* The offer zone: the price stack the card authors, then the caller's CTA. */
.catalog-card__offer-stack {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}
.catalog-card__offer-copy {
  min-width: 0;
}
.catalog-card__offer-line {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}
/* The beige plate — ONE rule for both views and all breakpoints (ТЗ v5): the price copy's
   only filled background. */
.price-zone {
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: var(--color-muted-bg);
  border-radius: 8px;
  padding: 12px 16px;
  /* A flex item of the offer-stack: without the floor removed, `min-width: auto` refuses to
     shrink the plate below its content, and the long ADR-099 price label forces it past the
     card edge at 320px (I6). The ≤768 `width: 100%` rule then sizes the plate to the stack. */
  min-width: 0;
}
.catalog-card__offer-copy .metric__label {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font: 500 11px/1.2 var(--font-ui);
  color: var(--color-ink-2);
  letter-spacing: 0.02em;
  text-transform: uppercase;
  min-height: 13px;
  /* The compact label's margin-bottom would push the trigger out of the plate. */
  margin-bottom: 0;
}
.catalog-card__offer-copy .metric__value {
  display: flex;
  align-items: baseline;
  gap: 4px;
  font: 700 24px/1 var(--font-num);
  color: var(--color-offer-price);
  white-space: nowrap;
  min-height: 24px;
}
.catalog-card__offer-copy .metric__unit {
  font: 500 13px/1.2 var(--font-ui);
}
/* The static MVP format string — the mockup's config trigger rendered as a plain span
   (ADR-085): no popover, so no button chrome. */
.catalog-card__config-trigger {
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  font: 600 13px/1 var(--font-ui);
  color: var(--color-ink);
}

/* ─── TASK-150 / ADR-124 — the offer zone's second row: the «Последние посты» control ───────
 * Ported from design/components/a2-catalog.html (the control `:1861-1890`, the row `:2585-2591`,
 * the hidden icon `:2594`). The mockup's `:1885-1886` selector list names the CAT-09 expander
 * beside `.catalog-card__posts`; the expander's half is DROPPED here — it is not built and its
 * class is forbidden in this stylesheet. The compact list's ≥769px hide is already above
 * (`:577`). */
.catalog-card__offer-actions > * {
  min-width: 0;
  overflow: hidden;
}
.catalog-card__posts {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid var(--color-divider);
  border-radius: 8px;
  background: var(--color-surface);
  color: var(--color-ink-2);
  font: 500 13px/1 var(--font-ui);
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition: color var(--duration-fast) var(--ease-out),
              border-color var(--duration-fast) var(--ease-out);
}
.catalog-card__posts:hover { color: var(--color-primary); border-color: var(--color-primary); }
.catalog-card__posts .ph { font-size: 16px; }
/* The mockup's `:1885-1889` secondary row — 50/50 with «Подробнее», ghost 1px. The `__more`
 * sibling is not built, so the row holds this one child and it takes half the track. */
.catalog-card__posts {
  flex: 1 1 50%;
  min-height: 40px;
}
.catalog-grid[data-view="comfortable"] .catalog-card__posts { width: auto; }
/* The mockup's `:2585-2591`: the secondary row is a 1fr 1fr grid inside the card's paddings. */
.catalog-card__offer-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  width: 100%;
}
/* The mockup's `:2594`: the icon stays in the DOM and is hidden at these densities. */
.catalog-card__posts i { display: none; }

/* ─── Comfortable (tile) ─────────────────────────────────────────────────── */

/* Chips — strictly one line; what does not fit collapses into «+N» (the card's own meta
   row, not the category bar). */
.catalog-grid[data-view="comfortable"] .catalog-card__meta {
  flex-wrap: nowrap;
  overflow: hidden;
}
.catalog-grid[data-view="comfortable"] .catalog-card__chip[hidden] {
  display: none;
}
/* The CTA «Добавить в медиаплан» is longer than «Выбрать» and does not fit beside the
   price on a 280px tile: the offer stacks — price on top, button full-width below. */
.catalog-grid[data-view="comfortable"] .catalog-card__offer {
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
}
.catalog-grid[data-view="comfortable"] .catalog-card__offer-copy {
  width: 100%;
  box-sizing: border-box;
}
.catalog-grid[data-view="comfortable"] .catalog-card__offer-copy .metric__value {
  font: 700 24px/1.1 var(--font-num);
  color: var(--color-offer-price);
}
.catalog-grid[data-view="comfortable"] .catalog-card__offer-copy .metric__unit {
  font: 500 13px/1.2 var(--font-ui);
  color: var(--color-ink-2);
}
/* The format string sits under the price, inside the beige zone (ТЗ v4). */
.catalog-grid[data-view="comfortable"] .catalog-card__offer-line {
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  justify-content: flex-start;
}
.catalog-grid[data-view="comfortable"] .catalog-card__offer-cta {
  width: 100%;
  justify-content: center;
  min-height: 44px;
  border-radius: 10px;
}
.catalog-grid[data-view="comfortable"] .catalog-card__offer-cta .ph-plus {
  display: none;
}
.catalog-grid[data-view="comfortable"] .catalog-card__expand-caret {
  display: none;
}
.catalog-grid[data-view="comfortable"] .catalog-card__body .metric__footer {
  margin-top: 2px;
}

/* ─── Compact (list) — desktop only ──────────────────────────────────────── */

@media (min-width: 769px) {
  .catalog-grid[data-view="compact"] {
    display: block;
  }
  .catalog-grid[data-view="compact"] .catalog-card__footer {
    display: none;
  }
  .catalog-grid[data-view="compact"] .metric__info {
    display: none;
  }
  .catalog-grid[data-view="compact"] .catalog-card__split .metric__info {
    display: none;
  }
  .catalog-grid[data-view="compact"] .metric__specifier {
    margin-left: 4px;
    color: var(--color-ink-3);
  }
  .catalog-grid[data-view="compact"] .catalog-card__body .metric__value {
    font: 700 18px/1.2 var(--font-num);
    min-height: 28px;
  }
  .catalog-grid[data-view="compact"] [data-num] {
    word-spacing: 0.15em;
  }
  .catalog-grid[data-view="compact"] .metric__footer {
    display: flex;
    flex-wrap: wrap;
    column-gap: 6px;
    margin-top: 2px;
    font: 400 12px/1.3 var(--font-ui);
    color: var(--color-ink-3);
    letter-spacing: 0;
    min-height: 14px;
  }
  .catalog-grid[data-view="compact"] .metric__mid {
    display: block;
    min-width: 0;
    white-space: normal;
  }
  .catalog-grid[data-view="compact"] .metric__source {
    display: none;
  }
  .catalog-grid[data-view="compact"] .catalog-card__offer-copy .metric__footer {
    display: none;
  }
  .catalog-grid[data-view="compact"] .catalog-card__body .metric--insufficient .metric__value {
    font: 700 18px/1.2 var(--font-num);
    color: var(--color-ink-2);
    min-height: 28px;
  }
  .catalog-grid[data-view="compact"] .catalog-card__body .metric--absent .metric__value {
    font: 400 13px/1.3 var(--font-ui);
    color: var(--color-ink-3);
    display: block;
    min-height: 28px;
  }
  .catalog-grid[data-view="compact"] .catalog-card__offer-actions {
    display: none;
  }

  /* «Карточка на боку»: 9 tracks (TASK-237) — name, subscribers, reach, ERR, on-time,
     reliability, price, CTA, caret. Constant height 108, overflow hidden, the row never
     drifts (long names, three chips, all «—» values, an eight-figure price alike). */
  .catalog-grid[data-view="compact"] .catalog-card {
    display: grid;
    grid-template-columns: minmax(200px, 280px) minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr) auto auto auto;
    align-items: center;
    column-gap: 12px;
    row-gap: 0;
    padding: 8px 12px;
    border: 1px solid var(--color-divider);
    border-radius: 10px;
    background: var(--color-card-surface);
    max-width: 1600px;
    width: 100%;
    margin: 0 auto;
    height: 108px;
    overflow: hidden;
    position: relative;
  }
  .catalog-grid[data-view="compact"] .catalog-card-wrap {
    margin-top: 8px;
    display: block;
  }
  .catalog-grid[data-view="compact"] .catalog-card-wrap:first-child {
    margin-top: 0;
  }
  .catalog-grid[data-view="compact"] .catalog-card:hover {
    border-color: var(--color-ink-2);
    background-color: var(--color-page);
  }
  .catalog-grid[data-view="compact"] .catalog-card:focus-within,
  .catalog-grid[data-view="compact"] .catalog-card:focus-visible {
    outline: 2px solid var(--color-amber);
    outline-offset: 2px;
  }

  /* Header (name block) — column 1. */
  .catalog-grid[data-view="compact"] .catalog-card__header {
    grid-column: 1;
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: center;
    column-gap: 10px;
    row-gap: 4px;
    min-width: 0;
  }
  .catalog-grid[data-view="compact"] .catalog-card__header > .catalog-card__avatar {
    grid-row: 1 / span 2;
    align-self: center;
    width: 36px;
    height: 36px;
    font-size: 13px;
  }
  .catalog-grid[data-view="compact"] .catalog-card__header > .catalog-card__title-block {
    grid-column: 2;
    grid-row: 1;
    min-width: 0;
  }
  .catalog-grid[data-view="compact"] .catalog-card__title {
    font-size: 15px;
    margin-bottom: 2px;
    -webkit-line-clamp: 1;
    line-clamp: 1;
  }
  .catalog-grid[data-view="compact"] .catalog-card__handle {
    font-size: 12px;
  }
  .catalog-grid[data-view="compact"] .catalog-card__header > .catalog-card__meta {
    grid-column: 2;
    grid-row: 2;
    display: flex;
    flex-wrap: nowrap;
    overflow: hidden;
    gap: 4px;
    min-width: 0;
  }
  .catalog-grid[data-view="compact"] .catalog-card__chip {
    padding: 3px 6px;
    font-size: 10px;
  }
  .catalog-grid[data-view="compact"] .catalog-card__chip[hidden] {
    display: none;
  }

  /* Body (metrics) — columns 2..5. display:contents makes the metrics direct children of
     the row grid; nth-child places them. */
  .catalog-grid[data-view="compact"] .catalog-card__body {
    grid-column: 2 / span 4;
    display: contents;
  }
  .catalog-grid[data-view="compact"] .catalog-card__body > .metric {
    min-width: 0;
    padding: 0;
    border: 0;
    background: transparent;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
  }
  .catalog-grid[data-view="compact"] .catalog-card__body .metric__header {
    align-items: start;
    gap: 0;
  }
  .catalog-grid[data-view="compact"] .catalog-card__body .metric__label {
    display: flex;
    align-items: baseline;
    gap: 6px;
    margin-bottom: 14px;
    min-height: 16px;
  }
  .catalog-grid[data-view="compact"] .catalog-card__body > .metric:nth-child(1) {
    grid-column: 2;
  }
  .catalog-grid[data-view="compact"] .catalog-card__body > .metric:nth-child(2) {
    grid-column: 3;
  }
  /* The split: its columns become tracks 4, 5 and 6 (TASK-237). The dividers are display:none
     but still count in nth-child — on-time is child 3, reliability child 5, not 2 and 4. */
  .catalog-grid[data-view="compact"] .catalog-card__body > .catalog-card__split {
    display: contents;
  }
  .catalog-grid[data-view="compact"] .catalog-card__body > .catalog-card__split .catalog-card__split-col {
    padding: 0;
    min-width: 0;
  }
  .catalog-grid[data-view="compact"] .catalog-card__body > .catalog-card__split .catalog-card__split-col:nth-child(1) {
    grid-column: 4;
  }
  .catalog-grid[data-view="compact"] .catalog-card__body > .catalog-card__split .catalog-card__split-col:nth-child(3) {
    grid-column: 5;
  }
  .catalog-grid[data-view="compact"] .catalog-card__body > .catalog-card__split .catalog-card__split-col:nth-child(5) {
    grid-column: 6;
  }
  .catalog-grid[data-view="compact"] .catalog-card__body > .catalog-card__split .catalog-card__split-divider {
    display: none;
  }
  .catalog-grid[data-view="compact"] .catalog-card__body > .catalog-card__split .metric__label {
    margin-bottom: 14px;
    min-height: 16px;
  }
  .catalog-grid[data-view="compact"] .catalog-card__split .metric__sample {
    white-space: normal;
  }

  /* The offer zone: display:contents — the price stack and the CTA become tracks 7 and 8
     (TASK-237 moved them from 6/7 when the reliability column took track 6). */
  .catalog-grid[data-view="compact"] .catalog-card__body > .catalog-card__offer {
    display: contents;
  }
  .catalog-grid[data-view="compact"] .catalog-card__body > .catalog-card__offer > .catalog-card__offer-stack {
    grid-column: 7;
    justify-content: center;
  }
  .catalog-grid[data-view="compact"] .catalog-card__body > .catalog-card__offer > .catalog-card__offer-cta {
    grid-column: 8;
  }
  .catalog-grid[data-view="compact"] .catalog-card__body > .catalog-card__offer > .catalog-card__expand-caret {
    display: none;
  }
  /* The plate in the list is fixed-width so the row never drifts with long UZ sums.
   * The mockup's 200px (a2-catalog.html:1516-1517) holds the mockup's UNTAILED number.
   * TASK-121 shipped 240px because the then-current figure carried the `,00` tail (DEBT-318):
   * the tail made the 24px value row ~190px wide in RU and ~197px in UZ — wider than a 200px
   * plate's 168px content box, so the currency escaped the beige plate. The tail is gone
   * (DEBT-318, ruled 2026-09-05 — `trimZeroTiyinTail` at the C15 call sites), so the 240px
   * compensation is compensation for a figure that no longer exists: the plate returns to the
   * mockup's 200px and the design-diff map's plate row measures that again (the map row now
   * declares only the absent expand-caret track). */
  .catalog-grid[data-view="compact"] .price-zone {
    width: 200px;
    box-sizing: border-box;
  }
  /* The storefront's CTA in the list. */
  .catalog-grid[data-view="compact"] .catalog-card__offer-cta {
    min-height: 44px;
    padding: 0 12px;
    font-size: 12px;
    flex: 0 0 auto;
    border-radius: 10px;
  }
  .catalog-grid[data-view="compact"] .catalog-card__offer-cta .ph-plus {
    display: none;
  }
  .catalog-grid[data-view="compact"] .catalog-card__expand-caret {
    display: none;
  }
  /* Compact labels carry no «медиана»-specifier — the short ERR/ОН-ТАЙМ style. */
  .catalog-grid[data-view="compact"] .catalog-card__body .metric__specifier {
    display: none;
  }
}
/* DEBT-463 — the mockup's compact-view offer price (a2-catalog.html:1575-1605) sits OUTSIDE
 * any @media block: line-height 1 for the price plate is constant at every width, only the
 * surrounding row layout changes at 769/768. This port had nested it inside the desktop-only
 * `@media (min-width: 769px)` block above, so below 769px nothing here matched and the generic
 * mobile ≤480 rule further down (line-height 1.2, sized for the comfortable view) won instead —
 * 28.8px computed against the mockup's 24px. Unscoped to match, the same way the sibling
 * `.catalog-card__offer-line` rule below was already unscoped for the identical reason. */
.catalog-grid[data-view="compact"] .catalog-card__body > .catalog-card__offer > .catalog-card__offer-stack > .catalog-card__offer-copy .metric__value {
  display: flex;
  align-items: baseline;
  gap: 4px;
  font: 700 24px/1 var(--font-num);
  color: var(--color-offer-price);
  white-space: nowrap;
  min-height: 24px;
}
.catalog-grid[data-view="compact"] .catalog-card__body > .catalog-card__offer > .catalog-card__offer-stack > .catalog-card__offer-copy .metric__unit {
  font: 500 13px/1.2 var(--font-ui);
}
.catalog-grid[data-view="compact"] .catalog-card__body > .catalog-card__offer > .catalog-card__offer-stack > .catalog-card__offer-copy .metric__label {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font: 500 11px/1.2 var(--font-ui);
  color: var(--color-ink-2);
  letter-spacing: 0.02em;
  text-transform: uppercase;
  min-height: 13px;
  margin-bottom: 0;
}
:root[data-theme="dark"] .catalog-grid[data-view="compact"] .catalog-card__body > .catalog-card__offer > .catalog-card__offer-stack > .catalog-card__offer-copy .metric__label {
  color: var(--color-ink-3);
}

/* ─── TASK-121 (item 5) — the compact CTA's THREE desktop width bands, the discriminator the
 * viewport, not the view (a2-catalog.html:1604-1621, :1357-1364). The rules sit after the
 * desktop block above so they beat its `.catalog-card__offer-cta` base in the cascade; the
 * ≤768 full-text band lives in the mobile block below, and the comfortable view's own
 * full-text rule is unscoped to any width. The control stays an anchor to the caller's href
 * with the same accessible name (the `aria-label` the storefront authors); the «+» is a
 * pseudo-element because no plus glyph exists on this text-only control. */

@media (min-width: 769px) and (max-width: 1280px) {
  .catalog-grid[data-view="compact"] .catalog-card__offer-cta {
    width: 44px;
    min-width: 44px;
    height: 44px;
    padding: 0;
    font-size: 0;
    justify-content: center;
    border-radius: 10px;
  }
  .catalog-grid[data-view="compact"] .catalog-card__offer-cta::before {
    content: "+";
    font: 700 20px/1 var(--font-ui);
  }
}

@media (min-width: 1281px) {
  .catalog-grid[data-view="compact"] .catalog-card__offer-cta {
    min-width: 166px;
    justify-content: center;
  }
}

/* The format string stacks UNDER the price in the plate, at every width — the mockup's
   compact rule (a2-catalog.html:1582) is global, not desktop-only: a row would overflow a
   320px viewport (price + «1 пост · 24 ч» are together wider than the card). */
.catalog-grid[data-view="compact"] .catalog-card__offer-line {
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
}
.catalog-grid[data-view="compact"] .catalog-card__config-trigger {
  font-size: 12px;
}

/* ─── Mobile ≤768px — the compact view is a stack, like comfortable ──────── */

@media (max-width: 768px) {
  .catalog-grid[data-view="compact"] {
    display: block;
  }
  .catalog-grid[data-view="compact"] .catalog-card {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    padding: 16px;
    border: 1px solid var(--color-divider);
    border-radius: var(--radius-md);
    background: var(--color-card-surface);
    margin-top: 10px;
    height: auto;
  }
  .catalog-grid[data-view="compact"] .catalog-card:first-of-type {
    margin-top: 0;
  }
  .catalog-grid[data-view="compact"] .catalog-card__header,
  .catalog-grid[data-view="compact"] .catalog-card__meta,
  .catalog-grid[data-view="compact"] .catalog-card__body {
    flex: initial;
  }
  .catalog-grid[data-view="compact"] .catalog-card__meta {
    padding: 0;
  }
  .catalog-grid[data-view="compact"] .catalog-card__body {
    display: flex;
    flex-direction: column;
    gap: 8px;
  }
  .catalog-grid[data-view="compact"] .catalog-card__body > .metric {
    border: 0;
    background: transparent;
    padding: 0;
  }
  /* The offer cell stacks: the plate on top, the button full-width below. */
  .catalog-grid[data-view="compact"] .catalog-card__body > .catalog-card__offer {
    grid-column: auto;
    border-top: 1px solid var(--color-divider);
    padding-top: 12px;
    margin-top: 4px;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding-left: 0;
    border-left: 0;
  }
  .catalog-grid[data-view="compact"] .catalog-card-wrap {
    margin-top: 0;
  }
  /* The plate fills the stack's width on mobile (the mockup's own ≤768 rule,
     a2-catalog.html:1520): without it the plate keeps its content width and sticks out
     past the card edge under the long ADR-099 price label. */
  .catalog-grid[data-view="compact"] .price-zone {
    width: 100%;
    box-sizing: border-box;
  }
  .catalog-grid[data-view="compact"] .catalog-card__body > .catalog-card__offer > .catalog-card__offer-stack > .catalog-card__offer-copy {
    align-self: flex-start;
  }
  /* A real full-width primary button on mobile, not the chevron square. */
  .catalog-grid[data-view="compact"] .catalog-card__offer-cta {
    width: 100%;
    min-height: 40px;
    padding: 0 16px;
    font: 600 13px/1 var(--font-ui);
    color: var(--color-primary-fg);
    background: var(--color-primary);
    border: 0;
    border-radius: 8px;
  }
  .catalog-grid[data-view="compact"] .catalog-card__offer-cta::after {
    content: none;
  }
  .catalog-grid[data-view="compact"] .catalog-card__offer-cta .ph-plus {
    display: none;
  }
  .catalog-grid[data-view="compact"] .catalog-card__expand-caret {
    display: none;
  }
  .catalog-grid[data-view="comfortable"] .catalog-card__offer-cta {
    width: auto;
    min-height: 40px;
    padding: 0 16px;
    font-size: 13px;
    color: var(--color-primary-fg);
    background: var(--color-primary);
    border-radius: 8px;
  }
  .catalog-grid[data-view="comfortable"] .catalog-card__offer-cta::after {
    content: none;
  }
}
/* Mobile ≤480px: tighter padding, smaller avatar/value */
@media (max-width: 480px) {
  .catalog-card { padding: 14px; gap: 12px; max-width: none; }
  .catalog-card__avatar { width: 40px; height: 40px; font-size: 15px; }
  .catalog-card__title { font-size: 15px; }
  .catalog-card__body .metric__value { font-size: 16px; }
  .catalog-card__body .metric__label { font-size: 10px; }
  /* Offer zone on mobile: larger price with breathing room from the label */
  .catalog-card__offer { padding-top: 14px; gap: 14px; }
  .catalog-card__offer-copy .metric__label { font-size: 10px; }
  /* DEBT-463 — this rule is view-agnostic (`data-view` unscoped) and every consumer sets a
   * view, so the compact/comfortable rules above win at every width and this is never the
   * declaration a browser actually paints. Kept as the fallback for a card rendered outside a
   * `.catalog-grid[data-view]`; line-height matches the mockup's own view-agnostic constant
   * (1.0, a2-catalog.html:1582) rather than the 1.2 this carried before — a stray value with
   * no mockup source. */
  .catalog-card__offer-copy .metric__value { font-size: 24px; line-height: 1; margin-top: 6px; gap: 5px; }
  .catalog-card__offer-copy .metric__unit { font-size: 13px; }
  .catalog-card__offer-copy .metric__footer { font-size: 11px; margin-top: 6px; }
}

