/*
 * Компоненты страниц: крошки, сводка с переключателем периода, карточки категорий, графики,
 * сводные панели с раскрывающимся списком, бейджи изменений, статус проверки.
 * Только переменные из tokens.css (SITE_DESIGN_SPEC.md, разделы 2–4, 10–12; образец design_reference).
 */

.num {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---------- статус проверки в шапке ---------- */

.run-status {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-width: 0;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  cursor: default;
}

.run-status__text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dot {
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-neutral);
}

.dot--ok {
  background: var(--color-down);
  box-shadow: 0 0 0 3px var(--color-down-bg);
}

.dot--busy {
  background: var(--color-accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-accent) 25%, transparent);
  animation: pulse 1.2s ease-in-out infinite;
}

.dot--bad {
  background: var(--color-up);
  box-shadow: 0 0 0 3px var(--color-up-bg);
}

@keyframes pulse {
  50% {
    opacity: 0.4;
  }
}

@media (prefers-reduced-motion: reduce) {
  .dot--busy {
    animation: none;
  }
}

/* ---------- крошки, разделы ---------- */

.crumbs {
  margin-bottom: var(--space-3);
  color: var(--color-muted);
  font-size: var(--text-sm);
}

.crumbs__here {
  color: var(--color-fg);
}

.section {
  margin-top: 38px;
}

.section__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  flex-wrap: wrap;
  margin-bottom: var(--space-4);
}

.section__title {
  font-size: var(--text-xl);
}

.summary {
  margin-top: var(--space-4);
  max-width: 70ch;
  color: var(--color-muted);
  font-size: var(--text-lg);
}

/* ---------- изменения: стрелка, сумма, процент ---------- */

.delta {
  font-family: var(--font-mono);
  font-weight: var(--weight-bold);
  font-size: var(--text-md);
  white-space: nowrap;
}

.delta--down {
  color: var(--color-down);
}

.delta--up {
  color: var(--color-up);
}

.delta--flat,
.delta--none {
  color: var(--color-muted);
  font-family: var(--font-body);
  font-weight: var(--weight-semibold);
  white-space: normal;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  white-space: nowrap;
}

.pill--down {
  color: var(--color-down);
  background: var(--color-down-bg);
  border: 1px solid color-mix(in srgb, var(--color-down) 18%, transparent);
}

.pill--up {
  color: var(--color-up);
  background: var(--color-up-bg);
  border: 1px solid color-mix(in srgb, var(--color-up) 18%, transparent);
}

.pill--flat {
  color: var(--color-muted);
  background: var(--color-surface-2);
}

/* ---------- сводка ---------- */

.hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-5);
  flex-wrap: wrap;
  padding: clamp(20px, 4vw, 34px) clamp(20px, 4vw, 46px);
  border: 1px solid color-mix(in srgb, var(--color-accent) 16%, var(--color-line));
  border-radius: var(--radius-2xl);
  background: linear-gradient(125deg, color-mix(in srgb, var(--color-accent) 9%, var(--color-surface)), var(--color-surface) 60%);
  box-shadow: var(--shadow-hero);
}

.hero__figures {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  min-width: 0;
}

.hero__title {
  font-family: var(--font-body);
  font-weight: var(--weight-medium);
  font-size: var(--text-xl);
  letter-spacing: 0;
  color: var(--color-muted);
}

.hero__total {
  font-family: var(--font-display);
  font-weight: var(--weight-bold);
  font-size: var(--text-total);
  line-height: 1.05;
  letter-spacing: var(--tracking-total);
  overflow-wrap: anywhere;
}

.hero__delta {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.hero__since {
  color: var(--color-muted);
  font-size: var(--text-md);
}

/* Переключатель периода: подложка едет между равными вариантами (data-active = номер). */
.seg {
  position: relative;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  padding: 4px;
  border: 1px solid var(--color-line);
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--color-bg) 62%, var(--color-surface-2));
  isolation: isolate;
}

.seg__thumb {
  position: absolute;
  z-index: -1;
  top: 4px;
  bottom: 4px;
  left: 4px;
  width: calc((100% - 8px) / 4);
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--color-accent-from), var(--color-accent-to));
  box-shadow: var(--shadow-accent);
  transition: transform var(--duration-segment) var(--ease-segment);
}

.seg[data-active="1"] .seg__thumb {
  transform: translateX(100%);
}

.seg[data-active="2"] .seg__thumb {
  transform: translateX(200%);
}

.seg[data-active="3"] .seg__thumb {
  transform: translateX(300%);
}

.seg__option {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap-min);
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  color: var(--color-muted);
  font-weight: var(--weight-medium);
  text-decoration: none;
  transition: color var(--duration-fast) var(--ease-standard);
}

.seg__option[aria-current="true"] {
  color: var(--color-accent-ink);
  font-weight: var(--weight-semibold);
}

@media (hover: hover) {
  .seg__option:not([aria-current="true"]):hover {
    color: var(--color-fg);
  }
}

/* ---------- карточки категорий ---------- */

.cats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
  gap: 15px;
}

.cat {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  min-width: 0;
  padding: var(--space-5);
  overflow: hidden;
  border: 1px solid var(--color-line);
  border-radius: var(--radius-xl);
  background: linear-gradient(150deg, color-mix(in srgb, var(--color-surface-2) 56%, var(--color-surface)), var(--color-surface) 68%);
  box-shadow: var(--shadow-card);
  transition:
    transform var(--duration-fast) var(--ease-standard),
    border-color var(--duration-fast) var(--ease-standard),
    box-shadow var(--duration-fast) var(--ease-standard);
}

.cat::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: linear-gradient(180deg, var(--color-accent), color-mix(in srgb, var(--color-accent) 10%, transparent));
  opacity: 0.55;
}

@media (hover: hover) {
  .cat:hover {
    transform: translateY(calc(-1 * var(--lift-md)));
    border-color: color-mix(in srgb, var(--color-accent) 58%, var(--color-line));
    box-shadow: var(--shadow-card-hover);
  }

  .cat:hover::before {
    opacity: 1;
  }
}

.cat__top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.cat__name {
  font-size: var(--text-lg);
  letter-spacing: -0.02em;
  overflow-wrap: break-word;
  hyphens: auto;
}

.cat__count {
  color: var(--color-muted);
  font-size: var(--text-sm);
}

/* «8 в итоге · 4 наблюдаю»; на телефоне — две строки без точки. */
.cat__count-part {
  white-space: nowrap;
}

.cat__total {
  font-family: var(--font-display);
  font-weight: var(--weight-bold);
  font-size: var(--text-2xl);
  letter-spacing: -0.04em;
  line-height: 1.1;
}

.cat__delta {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
  min-height: 28px;
}

.cat__chart {
  height: 64px;
}

.cat__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  margin-top: auto;
  color: var(--color-muted);
  font-size: var(--text-sm);
}

.cat__mover {
  min-width: 0;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.cat__empty,
.chart-empty {
  color: var(--color-muted);
  font-size: var(--text-sm);
}

.chart-empty {
  display: grid;
  place-items: center start;
  height: 100%;
}

/* ---------- графики ---------- */

.sparkline {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.sparkline__line {
  fill: none;
  stroke: var(--color-accent);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
  filter: drop-shadow(0 4px 7px color-mix(in srgb, var(--color-accent) 18%, transparent));
}

/* ---------- сводные панели ---------- */

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

.stat {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  min-width: 0;
  padding: 20px 22px;
  border: 1px solid var(--color-line);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  color: var(--color-fg);
  text-align: left;
  cursor: pointer;
  transition:
    transform var(--duration-fast) var(--ease-standard),
    background var(--duration-fast) var(--ease-standard),
    border-color var(--duration-fast) var(--ease-standard),
    box-shadow var(--duration-fast) var(--ease-standard);
}

.stat__value {
  font-family: var(--font-mono);
  font-size: 28px;
  line-height: 1.2;
  letter-spacing: -0.035em;
}

.stat--cheaper .stat__value {
  color: var(--color-down);
}

.stat--pricier .stat__value {
  color: var(--color-up);
}

.stat__label {
  color: var(--color-muted);
  font-size: var(--text-sm);
}

.stat[aria-expanded="true"] {
  background: color-mix(in srgb, var(--color-accent) 7%, var(--color-surface));
  border-color: color-mix(in srgb, var(--color-accent) 45%, var(--color-line));
  box-shadow: 0 10px 28px color-mix(in srgb, var(--color-accent) 10%, transparent);
}

.stat:active {
  transform: scale(var(--press-scale));
}

@media (hover: hover) {
  .stat:hover {
    transform: translateY(calc(-1 * var(--lift-sm)));
    background: color-mix(in srgb, var(--color-accent) 5%, var(--color-surface));
    border-color: color-mix(in srgb, var(--color-accent) 42%, var(--color-line));
  }
}

/* Раскрытие по высоте содержимого без замеров: строка сетки 0fr → 1fr. */
.drawer {
  display: grid;
  grid-template-rows: 0fr;
  opacity: 0;
  transform: translateY(-6px);
  transition:
    grid-template-rows var(--duration-panel) var(--ease-panel),
    opacity var(--duration-panel) var(--ease-panel),
    transform var(--duration-panel) var(--ease-panel);
}

.drawer.is-open {
  grid-template-rows: 1fr;
  opacity: 1;
  transform: none;
  margin-top: 10px;
}

.drawer__inner {
  min-height: 0;
  overflow: hidden;
}

.drawer__body {
  padding: var(--space-4) var(--space-5);
  border: 1px solid var(--color-line);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  box-shadow: var(--shadow-card);
}

.drawer:not(.is-open) .drawer__body {
  visibility: hidden;
}

.drawer__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-2);
}

.drawer__title {
  font-size: var(--text-lg);
}

.drawer__empty {
  padding-block: var(--space-3);
  color: var(--color-muted);
}

.changes {
  margin: 0;
  padding: 0;
  list-style: none;
}

.change-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: var(--space-4);
  padding-block: 14px;
  border-top: 1px solid var(--color-line);
}

.change-row:first-child {
  border-top: 0;
}

.change-row__name {
  font-weight: var(--weight-semibold);
  overflow-wrap: anywhere;
}

.change-row__meta {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--color-muted);
  font-size: var(--text-sm);
}

.change-row__prices {
  white-space: nowrap;
}

.change-row__old {
  color: var(--color-muted);
  text-decoration: line-through;
}

.change-row__new {
  font-weight: var(--weight-semibold);
}

.changes__more {
  padding-top: var(--space-3);
}

/* Цвет магазина — только из палитры (номер приходит с сервера). */
.store-dot {
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

/* Магазин с точкой (макрос store_label): точка стоит в левом поле первой строки названия и не отрывается
   от него при переносе (перед встроенным блоком браузер разрешает перенос, поэтому точка — вне потока). */
.store-label {
  position: relative;
  min-width: 0;
  padding-left: 14px;
  overflow-wrap: anywhere;
}

.store-label .store-dot {
  position: absolute;
  left: 0;
  top: calc(0.5lh - 4px);
}

.store-dot--store-1 { background: var(--store-1); }
.store-dot--store-2 { background: var(--store-2); }
.store-dot--store-3 { background: var(--store-3); }
.store-dot--store-4 { background: var(--store-4); }
.store-dot--store-5 { background: var(--store-5); }
.store-dot--store-6 { background: var(--store-6); }
.store-dot--store-7 { background: var(--store-7); }
.store-dot--store-8 { background: var(--store-8); }

/* ---------- пустые состояния ---------- */

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-6) var(--space-5);
  border: 1px dashed color-mix(in srgb, var(--color-accent) 38%, var(--color-line));
  border-radius: var(--radius-xl);
  text-align: center;
}

.empty__title {
  font-size: var(--text-xl);
}

.empty__text {
  max-width: 52ch;
  color: var(--color-muted);
}

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

@media (max-width: 760px) {
  .hero {
    align-items: stretch;
  }

  .seg {
    width: 100%;
  }

  .seg__option {
    padding-inline: 0;
  }

  .summary {
    font-size: var(--text-base);
  }

  .section {
    margin-top: var(--space-5);
  }

  .section__head {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-1);
  }

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

  .cat {
    padding: var(--space-4);
    gap: var(--space-2);
    border-radius: 15px;
  }

  .cat__top {
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
  }

  /* Ровные карточки (NOTES.md): название — две строки с многоточием, под него всегда отведены две строки,
     график — у нижнего края; полное название — на странице категории (решение владельца 12.10.2026). */
  .cat__name {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
    min-height: calc(2 * 1.2em);
    font-size: var(--text-base);
    line-height: 1.2;
  }

  .cat__chart,
  .cat__empty {
    margin-top: auto;
  }

  .cat__count {
    font-size: var(--text-xs);
  }

  .cat__count-part {
    display: block;
  }

  .cat__count-sep {
    display: none;
  }

  .cat__total {
    font-size: var(--text-xl);
  }

  .cat__delta .delta {
    font-size: var(--text-xs);
  }

  .cat__chart {
    height: 44px;
  }

  /* Подробность о самом изменившемся товаре перегружает узкую карточку (NOTES.md). */
  .cat__foot {
    display: none;
  }

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

  .stat {
    padding: var(--space-3) var(--space-4);
  }

  .stat__value {
    font-size: 24px;
  }

  .change-row {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: var(--space-1) var(--space-3);
  }

  .change-row__prices {
    grid-column: 1;
    font-size: var(--text-sm);
  }

  .change-row__badge {
    grid-column: 2;
    grid-row: 1 / span 2;
  }

  .top__user {
    display: none;
  }
}

@media (max-width: 360px) {
  .cats {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* ---------- ссылки-карточки, крошки ---------- */

a.cat {
  color: inherit;
  text-decoration: none;
}

.crumbs a {
  color: var(--color-muted);
  text-decoration: none;
}

@media (hover: hover) {
  .crumbs a:hover {
    color: var(--color-fg);
  }
}

.hero__name {
  font-size: var(--text-h1);
  overflow-wrap: break-word;
  hyphens: auto;
}

.muted {
  color: var(--color-muted);
}

/* ---------- позиции категории ---------- */

.rows {
  overflow: hidden;
  border: 1px solid var(--color-line);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  box-shadow: var(--shadow-card);
}

.rows__group {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-3) var(--space-5);
  border-top: 1px solid var(--color-line);
  background: var(--color-surface-2);
}

.rows__group:first-child {
  border-top: 0;
}

.rows__group-name {
  flex: 1 1 auto;
  min-width: 0;
  color: var(--color-muted);
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-eyebrow);
  text-transform: uppercase;
}

.rows__group-total {
  color: var(--color-muted);
  font-size: var(--text-sm);
}

.rows__group-link {
  color: var(--color-muted);
  font-size: var(--text-sm);
  text-underline-offset: 3px;
}

@media (hover: hover) {
  .rows__group-link:hover {
    color: var(--color-fg);
  }
}

.rows__empty {
  padding: var(--space-3) var(--space-5);
  border-top: 1px solid var(--color-line);
  color: var(--color-muted);
  font-size: var(--text-sm);
}

.row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto 72px;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--color-line);
}

.row--watching .row__name,
.row--watching .row__line {
  color: var(--color-muted);
}

.row__name {
  font-weight: var(--weight-semibold);
  font-size: var(--text-lg);
  overflow-wrap: break-word;
  hyphens: auto;
}

.row__meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px var(--space-2);
  margin-top: 2px;
  color: var(--color-muted);
  font-size: var(--text-sm);
}

.row__price {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  text-align: right;
}

.row__line {
  font-family: var(--font-display);
  font-weight: var(--weight-bold);
  font-size: var(--text-lg);
  white-space: nowrap;
}

.row__line--none {
  color: var(--color-muted);
}

.row__regular {
  color: var(--color-muted);
  font-size: var(--text-xs);
  white-space: nowrap;
}

.row__change {
  display: flex;
  justify-content: flex-end;
}

.rows__total {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  flex-wrap: wrap;
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--color-line);
  background: var(--color-surface-2);
  font-weight: var(--weight-semibold);
}

.rows__total-sum {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.rows__total-figure {
  font-family: var(--font-display);
  font-size: var(--text-lg);
}

.flag {
  padding: 1px 8px;
  border-radius: var(--radius-pill);
  background: var(--color-surface-2);
  color: var(--color-neutral);
  font-size: var(--text-2xs);
  font-weight: var(--weight-semibold);
  white-space: nowrap;
}

.flag--out_of_stock,
.flag--check_failed {
  color: var(--color-up);
  background: var(--color-up-bg);
}

.flag--review {
  color: var(--color-accent);
  background: color-mix(in srgb, var(--color-accent) 14%, transparent);
}

/* ---------- карточка с графиком ---------- */

.panel-box {
  padding: clamp(var(--space-4), 3vw, var(--space-5));
  border: 1px solid var(--color-line);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  box-shadow: var(--shadow-card);
}

.panel-box__head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
  margin-bottom: var(--space-4);
}

.panel-box__lead {
  margin-top: var(--space-2);
  color: var(--color-muted);
}

.panel-box__figure {
  color: var(--color-fg);
  font-family: var(--font-display);
  font-weight: var(--weight-bold);
  font-size: var(--text-2xl);
  letter-spacing: -0.04em;
}

.panel-box__note {
  margin-top: var(--space-3);
  color: var(--color-muted);
  font-size: var(--text-sm);
}

.seg--small {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.seg--small .seg__thumb {
  width: calc((100% - 8px) / 3);
}

.seg--small .seg__option {
  min-height: 38px;
  padding: 6px 14px;
  font-size: var(--text-sm);
}

.chart-empty--big {
  min-height: 160px;
}

.bigchart {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-rows: 260px auto;
  column-gap: var(--space-3);
  margin: 0;
}

.bigchart__y {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  margin-block: -0.6em;
  color: var(--color-muted);
  font-size: var(--text-xs);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.bigchart__plot {
  position: relative;
  min-width: 0;
}

.bigchart__svg,
.bigchart__marks {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.bigchart__marks {
  pointer-events: none;
}

.bigchart__grid {
  stroke: var(--color-line);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}

.bigchart__area {
  fill: color-mix(in srgb, var(--color-accent) 12%, transparent);
}

.bigchart__line {
  fill: none;
  stroke: var(--color-accent);
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

.bigchart__hit {
  fill: transparent;
}

.bigchart__today {
  fill: var(--color-accent);
}

.bigchart__focus {
  fill: var(--color-bg);
  stroke: var(--color-accent);
  stroke-width: 2.5;
  opacity: 0;
}

.bigchart__focus.is-on {
  opacity: 1;
}

.bigchart__tip {
  position: absolute;
  top: 0;
  transform: translate(-50%, -110%);
  padding: 4px 10px;
  border: 1px solid var(--color-line);
  border-radius: var(--radius-sm);
  background: var(--color-surface-2);
  box-shadow: var(--shadow-popover);
  font-size: var(--text-xs);
  white-space: nowrap;
  pointer-events: none;
}

.bigchart__x {
  grid-column: 2;
  width: 100%;
  height: 22px;
  overflow: visible;
}

.bigchart__x text {
  fill: var(--color-muted);
  font-size: 12px;
  font-family: var(--font-body);
}

/* ---------- таблица группы ---------- */

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--color-line);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  box-shadow: var(--shadow-card);
}

.offers {
  width: 100%;
  border-collapse: collapse;
}

.offers th,
.offers td {
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--color-line);
  text-align: left;
  vertical-align: top;
}

.offers thead th {
  border-top: 0;
  background: var(--color-surface-2);
  color: var(--color-muted);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-eyebrow);
  text-transform: uppercase;
}

.offers__name {
  font-weight: var(--weight-semibold);
  min-width: 14ch;
}

.offers__flags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}

.offers__stores {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.offers__stores li {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.offers__price {
  margin-left: auto;
  padding-left: var(--space-3);
}

.offers__store--best .offers__price {
  color: var(--color-down);
  font-weight: var(--weight-bold);
}

.offers__low-hint {
  display: block;
  color: var(--color-muted);
  font-size: var(--text-xs);
}

@media (max-width: 760px) {
  .row {
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: var(--space-1) var(--space-3);
    padding: var(--space-3) var(--space-4);
  }

  .row > .check {
    grid-row: 1 / span 2;
    align-self: start;
    margin-top: 2px;
  }

  .row__name {
    font-size: var(--text-base);
  }

  .row__price {
    grid-column: 2;
    grid-row: 2;
    align-items: flex-start;
    text-align: left;
  }

  .row__change {
    grid-column: 3;
    grid-row: 1 / span 2;
    align-self: center;
  }

  .row__line {
    font-size: var(--text-base);
  }

  .rows__group {
    flex-wrap: wrap;
    gap: var(--space-1) var(--space-3);
    padding: var(--space-3) var(--space-4);
  }

  .rows__group-name {
    flex-basis: 100%;
  }

  .bigchart {
    grid-template-rows: 200px auto;
  }

  .table-wrap {
    overflow: visible;
    border: 0;
    background: none;
    box-shadow: none;
  }

  .offers thead {
    display: none;
  }

  .offers,
  .offers tbody,
  .offers tr,
  .offers th,
  .offers td {
    display: block;
  }

  .offers tr {
    margin-bottom: 10px;
    padding: var(--space-4);
    border: 1px solid var(--color-line);
    border-radius: var(--radius-lg);
    background: var(--color-surface);
  }

  .offers th,
  .offers td {
    padding: 0;
    border: 0;
  }

  .offers td + td,
  .offers th + td {
    margin-top: var(--space-3);
  }

  /* Длинное название магазина переносится, цена остаётся справа и не уезжает за экран. */
  .offers__stores li {
    align-items: flex-start;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .offers__price {
    flex: none;
  }

  .offers__stores .store-dot {
    margin-top: 0.45em;
  }

  .offers td[data-label]::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 4px;
    color: var(--color-muted);
    font-size: var(--text-2xs);
    font-weight: var(--weight-semibold);
    letter-spacing: var(--tracking-eyebrow);
    text-transform: uppercase;
  }
}

/* ---------- элементы изменения товара ---------- */

.check {
  appearance: none;
  flex: none;
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  margin: 0;
  border: 2px solid var(--color-line);
  border-radius: var(--radius-xs);
  background: var(--color-bg);
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease-standard), border-color var(--duration-fast) var(--ease-standard);
}

.check:checked {
  border-color: transparent;
  background: linear-gradient(135deg, var(--color-accent-from), var(--color-accent-to));
}

.check:checked::after {
  content: "";
  width: 10px;
  height: 6px;
  margin-top: -2px;
  border-left: 2px solid var(--color-accent-ink);
  border-bottom: 2px solid var(--color-accent-ink);
  transform: rotate(-45deg);
}

.check:disabled,
.stepper__btn:disabled {
  cursor: progress;
  opacity: 0.6;
}

.check-label {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: var(--tap-min);
  font-weight: var(--weight-semibold);
  cursor: pointer;
}

.stepper {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--color-line);
  border-radius: var(--radius-sm);
  background: var(--color-bg);
}

.stepper__btn {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--color-muted);
  font-size: var(--text-lg);
  cursor: pointer;
}

@media (hover: hover) {
  .stepper__btn:not(:disabled):hover {
    color: var(--color-fg);
    background: var(--color-surface-2);
  }
}

.stepper__value {
  min-width: 2.2ch;
  text-align: center;
  font-weight: var(--weight-semibold);
}

.row__link {
  color: inherit;
  text-decoration: none;
}

@media (hover: hover) {
  .row__link:hover {
    color: var(--color-accent);
  }
}

.alert--warn {
  color: var(--color-fg);
  background: color-mix(in srgb, var(--store-2) 12%, var(--color-surface));
  border-color: color-mix(in srgb, var(--store-2) 35%, var(--color-line));
}

.flag--best {
  color: var(--color-down);
  background: var(--color-down-bg);
}

/* ---------- карточка товара ---------- */

.item-hero {
  display: grid;
  grid-template-columns: minmax(180px, 280px) minmax(0, 1fr);
  gap: var(--space-6);
  padding: clamp(var(--space-4), 3vw, var(--space-6));
  border: 1px solid color-mix(in srgb, var(--color-accent) 16%, var(--color-line));
  border-radius: var(--radius-2xl);
  background: linear-gradient(125deg, color-mix(in srgb, var(--color-accent) 9%, var(--color-surface)), var(--color-surface) 60%);
  box-shadow: var(--shadow-hero);
}

.item-hero__photo {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  overflow: hidden;
  border-radius: var(--radius-xl);
  background: radial-gradient(circle at 50% 40%, var(--color-photo-glow), var(--color-surface-2) 70%);
}

.item-hero__photo img {
  width: 82%;
  height: 82%;
  object-fit: contain;
}

.item-hero__nophoto {
  padding: var(--space-4);
  color: var(--color-muted);
  font-size: var(--text-sm);
  text-align: center;
}

.item-hero__body {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  min-width: 0;
}

.item-hero__full {
  color: var(--color-muted);
}

.item-hero__price {
  display: flex;
  align-items: baseline;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.item-hero__figure {
  font-family: var(--font-display);
  font-weight: var(--weight-bold);
  font-size: var(--text-price);
  letter-spacing: -0.04em;
  line-height: 1.05;
}

.item-hero__figure--none {
  color: var(--color-muted);
  font-size: var(--text-2xl);
}

.item-hero__failure {
  color: var(--color-muted);
  font-size: var(--text-sm);
}

.item-hero__controls {
  display: flex;
  align-items: center;
  gap: var(--space-3) var(--space-4);
  flex-wrap: wrap;
  margin-top: var(--space-2);
}

.item-hero__line {
  color: var(--color-muted);
}

.menu {
  position: relative;
}

.menu > summary {
  list-style: none;
  cursor: pointer;
}

.menu > summary::-webkit-details-marker {
  display: none;
}

.menu__list {
  position: absolute;
  z-index: var(--z-popover);
  top: calc(100% + 6px);
  right: 0;
  min-width: 240px;
  margin: 0;
  padding: 6px;
  list-style: none;
  border: 1px solid var(--color-line);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  box-shadow: var(--shadow-popover);
}

.menu__item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-height: var(--tap-min);
  padding: 0 var(--space-3);
  border-radius: var(--radius-sm);
  color: inherit;
  text-decoration: none;
}

@media (hover: hover) {
  .menu__item:hover {
    background: var(--color-surface-2);
  }
}

.menu__price {
  margin-left: auto;
  color: var(--color-muted);
}

.chart-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  flex-wrap: wrap;
  margin-block: var(--space-3) var(--space-4);
}

.chips {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 6px 12px;
  border: 1px solid var(--color-line);
  border-radius: var(--radius-pill);
  color: var(--color-muted);
  font-size: var(--text-sm);
  text-decoration: none;
}

.chip[aria-current="true"] {
  color: var(--color-fg);
  border-color: var(--color-accent);
  background: color-mix(in srgb, var(--color-accent) 10%, var(--color-surface));
}

.item-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 15px;
  margin-top: 15px;
}

.offer-list,
.history {
  margin: var(--space-3) 0 0;
  padding: 0;
  list-style: none;
}

.offer-list__row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 2px var(--space-3);
  padding-block: var(--space-3);
  border-top: 1px solid var(--color-line);
}

.offer-list__row:first-child {
  border-top: 0;
}

.offer-list__store {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: var(--weight-semibold);
}

.offer-list__price {
  text-align: right;
  white-space: nowrap;
}

.offer-list__row--best .offer-list__price {
  color: var(--color-down);
  font-weight: var(--weight-bold);
}

.offer-list__state {
  grid-column: 1 / -1;
  color: var(--color-muted);
  font-size: var(--text-xs);
}

.history__row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 2px var(--space-3);
  padding-block: var(--space-3);
  border-top: 1px solid var(--color-line);
}

.history__row:first-child {
  border-top: 0;
}

.history__time {
  color: var(--color-muted);
  font-size: var(--text-xs);
  white-space: nowrap;
}

.history__store {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--color-muted);
  font-size: var(--text-xs);
}

.history__text {
  grid-column: 1 / -1;
}

.history__row--check_failed .history__text {
  color: var(--color-muted);
}

@media (max-width: 760px) {
  .item-hero {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-4);
  }

  .item-hero__photo {
    max-width: 240px;
    width: 100%;
    margin-inline: auto;
  }

  .item-columns {
    grid-template-columns: minmax(0, 1fr);
  }

  .stepper__btn {
    width: var(--tap-min);
    height: 38px;
  }

  .menu__list {
    left: 0;
    right: auto;
  }
}

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

.page-title {
  font-size: var(--text-h1);
  margin-bottom: var(--space-2);
}

.gear {
  display: inline-grid;
  place-items: center;
  width: var(--tap-min);
  height: var(--tap-min);
  border: 1px solid var(--color-line);
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--color-surface) 90%, transparent);
  color: var(--color-muted);
  transition: color var(--duration-fast) var(--ease-standard), border-color var(--duration-fast) var(--ease-standard);
}

.gear svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* «Покупки» в шапке: значок с подписью, на телефоне — только значок (подпись остаётся в aria-label). */
.gear--labelled {
  width: auto;
  grid-auto-flow: column;
  gap: var(--space-2);
  padding-inline: var(--space-3);
}

.gear__text {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  text-decoration: none;
}

.gear--labelled {
  text-decoration: none;
}

.tabs + .hero {
  margin-top: var(--space-4);
}

@media (max-width: 600px) {
  .gear--labelled {
    width: var(--tap-min);
    padding-inline: 0;
  }

  .gear__text {
    display: none;
  }
}

@media (hover: hover) {
  .gear:hover {
    color: var(--color-fg);
    border-color: var(--color-accent);
  }
}

.tabs {
  display: inline-flex;
  gap: 4px;
  margin-top: var(--space-5);
  padding: 4px;
  border: 1px solid var(--color-line);
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--color-bg) 62%, var(--color-surface-2));
  max-width: 100%;
  overflow-x: auto;
}

.tabs__tab {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  color: var(--color-muted);
  font-weight: var(--weight-medium);
  text-decoration: none;
  white-space: nowrap;
}

.tabs__tab[aria-current="page"] {
  background: linear-gradient(135deg, var(--color-accent-from), var(--color-accent-to));
  color: var(--color-accent-ink);
  font-weight: var(--weight-semibold);
}

.add-form {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-block: var(--space-5) var(--space-4);
  max-width: 560px;
}

.add-form__row {
  display: flex;
  gap: var(--space-2);
}

.add-form--inline {
  margin: var(--space-3) 0 0;
}

.btn--danger {
  color: var(--color-up);
  background: color-mix(in srgb, var(--color-up) 12%, var(--color-surface));
  border-color: color-mix(in srgb, var(--color-up) 32%, var(--color-line));
}

@media (hover: hover) {
  .btn--danger:hover {
    border-color: var(--color-up);
  }
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--color-line);
  border-radius: var(--radius-sm);
  background: var(--color-surface-2);
  color: var(--color-fg);
  cursor: pointer;
}

.icon-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

.edit-list {
  margin: 0;
  padding: 0;
  list-style: none;
  border: 1px solid var(--color-line);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.edit-list--nested {
  margin-top: var(--space-3);
  border-radius: var(--radius-md);
  box-shadow: none;
}

.edit-row {
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--color-line);
  background: var(--color-surface);
}

.edit-row:first-child {
  border-top: 0;
}

.edit-row__main {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.drag-handle {
  flex: none;
  padding: 6px 2px;
  color: var(--color-muted);
  letter-spacing: -0.2em;
  cursor: grab;
  user-select: none;
  touch-action: none;
}

.edit-row__text {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.edit-row__name {
  font-weight: var(--weight-semibold);
  font-size: var(--text-lg);
  color: inherit;
  text-decoration: none;
  overflow-wrap: break-word;
  hyphens: auto;
}

.edit-row__meta {
  color: var(--color-muted);
  font-size: var(--text-sm);
}

.edit-row__actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
  justify-content: flex-end;
}

.edit-row__order {
  display: inline-flex;
  gap: var(--space-2);
}

/* Телефон: действия строки — сетка равных колонок; при переносе кнопка встаёт в колонку той же ширины,
   «Удалить» не остаётся одна в новой строке (NOTES.md). Стрелки порядка — одна ячейка на две строки. */
@media (max-width: 760px) {
  .edit-row__actions {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 112px), 1fr));
    width: 100%;
  }

  .edit-row__actions > .btn {
    justify-content: center;
  }

  .edit-row__order {
    grid-row: span 2;
    align-self: start;
  }
}

.edit-row.is-ghost {
  opacity: 0.4;
  background: color-mix(in srgb, var(--color-accent) 10%, var(--color-surface));
}

.edit-row.is-chosen,
.cat.is-chosen {
  box-shadow: var(--shadow-popover);
}

.cat.is-ghost {
  opacity: 0.45;
  outline: 2px dashed var(--color-accent);
  outline-offset: -2px;
}

.cat.is-chosen {
  transform: scale(0.97);
}

.groups {
  margin: var(--space-3) 0 0 calc(var(--space-4) + 12px);
}

.groups__summary {
  color: var(--color-muted);
  font-size: var(--text-sm);
  cursor: pointer;
}

.rename-form {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.input--inline {
  max-width: 320px;
  min-height: 38px;
  padding-block: 6px;
}

/* ---------- окно подтверждения ---------- */

.dialog {
  width: min(480px, calc(100% - 2 * var(--gutter)));
  padding: 0;
  border: 1px solid var(--color-line);
  border-radius: var(--radius-xl);
  background: var(--color-surface);
  color: var(--color-fg);
  box-shadow: var(--shadow-dialog);
}

.dialog::backdrop {
  background: var(--color-backdrop);
}

.dialog__body {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-5);
}

.dialog__title {
  font-size: var(--text-xl);
}

.dialog__text {
  color: var(--color-muted);
}

.dialog__actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
  margin-top: var(--space-2);
}

.radio {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-height: var(--tap-min);
}

/* ---------- сообщение с «Отменить» ---------- */

.toast {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  overflow: hidden;
  border: 1px solid var(--color-line);
  border-radius: var(--radius-md);
  background: var(--color-surface-2);
  box-shadow: var(--shadow-toast);
  animation: toast-in var(--duration-toast) var(--ease-toast);
}

.toast__undo {
  min-height: 36px;
  padding: 6px 12px;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--color-accent);
  font-weight: var(--weight-bold);
  cursor: pointer;
}

.toast__bar {
  position: absolute;
  left: 0;
  bottom: 0;
  height: 3px;
  width: 100%;
  background: var(--color-accent);
  transform-origin: left;
  animation: toast-time 3s linear forwards;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

@keyframes toast-time {
  to {
    transform: scaleX(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .toast {
    animation: none;
  }
}

@media (max-width: 760px) {
  .edit-row__main {
    flex-wrap: wrap;
  }

  .edit-row__text {
    flex-basis: calc(100% - 40px);
  }

  .edit-row__actions {
    width: 100%;
    justify-content: flex-start;
  }

  .edit-row__actions .icon-btn {
    width: var(--tap-min);
    height: var(--tap-min);
  }

  .groups {
    margin-left: 0;
  }

  .add-form__row {
    flex-direction: column;
  }
}

/* ---------- настройки товаров и окно товара ---------- */

.chips--filter {
  margin-block: var(--space-5) var(--space-3);
}

.item-list {
  margin-top: var(--space-4);
}

.dialog--wide {
  width: min(640px, calc(100% - 2 * var(--gutter)));
  max-height: calc(100dvh - 2 * var(--space-4));
}

.dialog__section {
  margin-bottom: var(--space-2);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--color-muted);
  letter-spacing: var(--tracking-eyebrow);
  text-transform: uppercase;
}

.input--area {
  min-height: 84px;
  resize: vertical;
}

.form__row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 110px;
  gap: var(--space-3);
}

.links {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.links__list {
  margin: 0;
  padding: 0;
  list-style: none;
  border: 1px solid var(--color-line);
  border-radius: var(--radius-md);
}

.links__row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 2px var(--space-3);
  align-items: center;
  padding: var(--space-3);
  border-top: 1px solid var(--color-line);
}

.links__row:first-child {
  border-top: 0;
}

.links__store {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: var(--weight-semibold);
}

.links__state {
  grid-column: 1;
  color: var(--color-muted);
  font-size: var(--text-sm);
}

.links__row--found .links__state {
  color: var(--color-down);
}

.links__row--not_found .links__state,
.links__row--store_disabled .links__state {
  color: var(--color-up);
}

.links__url {
  grid-column: 1;
  min-width: 0;
  overflow: hidden;
  color: var(--color-muted);
  font-size: var(--text-xs);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.links__remove {
  grid-column: 2;
  grid-row: 1 / span 3;
}

.links__error .links__url {
  display: inline;
}

.links__add {
  display: flex;
  gap: var(--space-2);
}

.panel-head-link {
  color: var(--color-muted);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  text-decoration: none;
}

@media (max-width: 760px) {
  .form__row {
    grid-template-columns: minmax(0, 1fr);
  }

  .links__add {
    flex-direction: column;
  }

  .dialog--wide {
    width: 100%;
    max-width: none;
    max-height: 100dvh;
    margin: auto 0 0;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  }
}

/* ---------- покупка и архив ---------- */

.flag--bought {
  color: var(--color-down);
  background: var(--color-down-bg);
}

.purchase-box {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-top: var(--space-4);
  padding: var(--space-4);
  border: 1px solid var(--color-line);
  border-radius: var(--radius-lg);
  background: var(--color-surface-2);
}

.purchase-box__title {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2);
  color: var(--color-muted);
}

.purchase-box__sum {
  color: var(--color-fg);
  font-family: var(--font-display);
  font-weight: var(--weight-bold);
  font-size: var(--text-xl);
  letter-spacing: -0.02em;
}

.purchase-box__cheaper {
  color: var(--color-down);
  font-weight: var(--weight-semibold);
}

.purchase-box .item-hero__controls {
  margin-top: var(--space-2);
}

.purchased {
  padding-block: var(--space-3);
}

.purchased__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
  min-height: 44px;
  align-content: center;
  flex-wrap: wrap;
  cursor: pointer;
  list-style: none;
}

.purchased__head::-webkit-details-marker {
  display: none;
}

.purchased__head .section__title::after {
  content: " ▾";
  color: var(--color-muted);
  font-size: var(--text-sm);
}

.purchased[open] .purchased__head .section__title::after {
  content: " ▴";
}

.purchased__list {
  display: flex;
  flex-direction: column;
  margin: var(--space-2) 0 0;
  padding: 0;
  list-style: none;
}

.purchased__row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: baseline;
  gap: var(--space-4);
  padding: var(--space-3) 0;
  border-top: 1px solid var(--color-line);
}

.purchased__name {
  min-width: 0;
  overflow-wrap: anywhere;
}

.purchased__meta {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0 var(--space-1);
  color: var(--color-muted);
  font-size: var(--text-sm);
  white-space: nowrap;
}

.purchased__sum {
  color: var(--color-fg);
  font-weight: var(--weight-semibold);
  text-align: right;
  white-space: nowrap;
}

@media (max-width: 640px) {
  .purchased__row {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: var(--space-1) var(--space-3);
  }

  .purchased__meta {
    grid-row: 2;
    white-space: normal;
  }

  .purchased__sum {
    grid-row: 1 / span 2;
    grid-column: 2;
    align-self: center;
  }
}

.purchased__row--wide {
  grid-template-columns: minmax(0, 1fr) auto auto minmax(150px, auto);
}

.purchased__savings {
  text-align: right;
  font-size: var(--text-sm);
}

.purchased__action {
  justify-self: end;
}

.spend-list {
  display: flex;
  flex-direction: column;
  margin: var(--space-2) 0 0;
  padding: 0;
  list-style: none;
}

.spend-list__row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto minmax(150px, auto);
  align-items: baseline;
  gap: var(--space-4);
  padding: var(--space-3) 0;
  border-top: 1px solid var(--color-line);
}

.spend-list__row:first-child {
  border-top: 0;
}

.spend-list__name {
  min-width: 0;
  overflow-wrap: anywhere;
}

.spend-list__count {
  color: var(--color-muted);
  font-size: var(--text-sm);
  white-space: nowrap;
}

.spend-list__sum {
  color: var(--color-fg);
  font-weight: var(--weight-semibold);
  white-space: nowrap;
}

.spend-list__savings {
  text-align: right;
  font-size: var(--text-sm);
}

@media (max-width: 640px) {
  .purchased__row--wide,
  .spend-list__row {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: var(--space-1) var(--space-3);
  }

  .spend-list__count {
    grid-row: 2;
  }

  .spend-list__sum {
    grid-column: 2;
    grid-row: 1;
    text-align: right;
  }

  .spend-list__savings,
  .purchased__savings {
    grid-column: 2;
    grid-row: 2;
  }

  .purchased__row--wide .purchased__sum {
    grid-row: 1;
  }

  .purchased__action {
    grid-column: 1 / -1;
    justify-self: start;
  }

  .purchased__row--wide .purchased__name {
    white-space: normal;
  }
}

/* ---------- проверка цен (администратор) ---------- */

.run-panel {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin-top: var(--space-5);
}

.run-panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-3);
}

.run-panel__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.run-panel__line {
  color: var(--color-fg);
  font-weight: var(--weight-semibold);
}

.run-panel__bar {
  width: 100%;
  height: 8px;
  border: 0;
  border-radius: var(--radius-pill);
  background: var(--color-surface-2);
  overflow: hidden;
  appearance: none;
}

.run-panel__bar::-webkit-progress-bar {
  background: var(--color-surface-2);
  border-radius: var(--radius-pill);
}

.run-panel__bar::-webkit-progress-value {
  background: var(--color-accent);
  border-radius: var(--radius-pill);
  transition: width var(--duration-panel) var(--ease-standard);
}

.run-panel__bar::-moz-progress-bar {
  background: var(--color-accent);
  border-radius: var(--radius-pill);
}

.run-panel__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
  color: var(--color-muted);
  font-size: var(--text-sm);
}

/* ---------- настройки «Проверка» ---------- */

.check-form {
  margin-top: var(--space-4);
  max-width: 760px;
}

.check-form__group {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.check-form__group + .check-form__group {
  padding-top: var(--space-4);
  border-top: 1px solid var(--color-line);
}

.check-form__actions {
  display: flex;
  justify-content: flex-end;
}

.check-saved {
  margin-top: var(--space-4);
}

.input--time,
.input--short {
  max-width: 180px;
}

/* ---------- «Требует решения» ---------- */

.reviews {
  margin-bottom: var(--space-6);
}

.count-pill {
  display: inline-grid;
  place-items: center;
  min-width: 26px;
  height: 26px;
  margin-left: var(--space-2);
  padding: 0 8px;
  border-radius: var(--radius-pill);
  background: color-mix(in srgb, var(--color-accent) 18%, transparent);
  color: var(--color-accent);
  font-size: var(--text-sm);
  vertical-align: middle;
}

.review-list {
  display: grid;
  /* Одна карточка — во всю ширину, две — пополам: без пустой половины справа. */
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr));
  gap: var(--space-4);
  margin: 0;
  padding: 0;
  list-style: none;
}

.review-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-4);
  border: 1px solid color-mix(in srgb, var(--color-accent) 35%, var(--color-line));
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  box-shadow: var(--shadow-card);
}

.review-card__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}

.review-card__when {
  margin-left: auto;
  color: var(--color-muted);
  font-size: var(--text-xs);
}

.review-card__item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-1) var(--space-3);
  font-weight: var(--weight-semibold);
}

.review-card__store {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--color-muted);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
}

.review-card__open {
  color: var(--color-muted);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
}

.review-card__change {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--space-2);
  font-size: var(--text-lg);
}

.review-card__before {
  color: var(--color-muted);
  text-decoration: line-through;
}

.review-card__titles {
  display: grid;
  gap: var(--space-2);
  margin: 0;
  font-size: var(--text-sm);
}

.review-card__titles div {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr);
  gap: var(--space-2);
}

.review-card__titles dt {
  color: var(--color-muted);
}

.review-card__titles dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.review-card__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: auto;
}

/* ---------- настройки «Магазины» ---------- */

.store-row__dot {
  width: 12px;
  height: 12px;
  margin-top: 6px;
}

/* Точка магазина — у первой строки названия, а не посередине блока из нескольких строк. */
.store-row .edit-row__main {
  align-items: flex-start;
}

.store-row--off .edit-row__name {
  color: var(--color-muted);
}

.store-row__flags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1) var(--space-2);
  margin-top: var(--space-1);
}

.store-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}

.swatches {
  display: flex;
  gap: var(--space-1);
  margin: 0;
  padding: 0;
  border: 0;
}

.swatch {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 2px solid transparent;
  border-radius: 50%;
  cursor: pointer;
}

.swatch:has(input:checked) {
  border-color: var(--color-fg);
}

.swatch:has(input:focus-visible) {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

.swatch__dot {
  width: 18px;
  height: 18px;
}

.store-list {
  margin-top: var(--space-4);
}

/* ---------- настройки «Пользователи» ---------- */

.users-notice {
  margin-top: var(--space-4);
}

.invite-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
  margin-top: var(--space-3);
}

.invite-issued {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-top: var(--space-4);
  padding: var(--space-4);
  border: 1px solid color-mix(in srgb, var(--color-accent) 40%, var(--color-line));
  border-radius: var(--radius-lg);
  background: color-mix(in srgb, var(--color-accent) 8%, var(--color-surface));
}

.invite-issued__title {
  font-weight: var(--weight-semibold);
}

.invite-issued__row {
  display: flex;
  gap: var(--space-2);
}

.invite-issued__row .input {
  flex: 1 1 auto;
  min-width: 0;
  font-size: var(--text-sm);
}

.invite-list {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-3);
  margin-top: var(--space-4);
}

.invite-list .edit-list {
  align-self: stretch;
}

.invite-row--expired {
  color: var(--color-muted);
}

/* ---------- колокольчик администратора ---------- */

.bell-slot {
  width: var(--tap-min);
  height: var(--tap-min);
}

.bell__button {
  position: relative;
}

.bell__badge {
  position: absolute;
  top: -6px;
  right: -6px;
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: var(--radius-pill);
  background: var(--color-accent);
  color: var(--color-accent-ink);
  font-size: var(--text-2xs);
  font-weight: var(--weight-bold);
}

.bell__panel {
  width: min(380px, calc(100vw - 2 * var(--gutter)));
  max-height: min(70vh, 520px);
  overflow-y: auto;
  padding: var(--space-3);
}

.bell__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
}

.bell__title {
  color: var(--color-fg);
  font-weight: var(--weight-semibold);
}

.bell__list {
  display: flex;
  flex-direction: column;
  margin: 0;
  padding: 0;
  list-style: none;
}

.bell__item {
  padding: var(--space-2) var(--space-2) var(--space-2) var(--space-3);
  border-top: 1px solid var(--color-line);
  color: var(--color-muted);
}

.bell__item--unread {
  border-left: 3px solid var(--color-accent);
  color: var(--color-fg);
}

.bell__text {
  font-size: var(--text-sm);
  overflow-wrap: anywhere;
}

.bell__meta {
  margin-top: 4px;
  color: var(--color-muted);
  font-size: var(--text-xs);
}

.bell__empty {
  padding: var(--space-3) 0;
  color: var(--color-muted);
}

@media (max-width: 600px) {
  /* На телефоне список — во всю ширину с полями экрана, сразу под значком. */
  .bell__panel {
    position: fixed;
    top: auto;
    right: var(--gutter);
    left: var(--gutter);
    width: auto;
    margin-top: 6px;
  }
}

/* ---------- настройки «Профиль» ---------- */

.profile-block {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin-top: var(--space-4);
}

.pairing {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-2);
}

.pairing__code {
  color: var(--color-fg);
  font-family: var(--font-display);
  font-size: clamp(2rem, 8vw, 3rem);
  font-weight: var(--weight-bold);
  letter-spacing: 0.12em;
}

.pairing__hint {
  color: var(--color-muted);
}

.pairing--expired .pairing__code {
  color: var(--color-muted);
  text-decoration: line-through;
}

.password-form {
  max-width: 420px;
}

/* ---------- шапка на телефоне: одна строка (SITE_DESIGN_SPEC.md, раздел 3; решение владельца 12.10.2026) ---------- */

.account-menu {
  display: none;
}

.top__account {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-width: 0;
}

.account-menu__list {
  display: grid;
  gap: var(--space-2);
  min-width: 200px;
  padding: var(--space-3);
}

.account-menu__name {
  color: var(--color-fg);
  font-weight: var(--weight-semibold);
  overflow-wrap: anywhere;
}

@media (max-width: 600px) {
  .top__row {
    flex-wrap: nowrap;
    min-height: 56px;
    padding-block: 6px;
    gap: 6px;
  }

  .brand__name {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }

  .top__meta {
    gap: 6px;
  }

  /* Статус — точка; полный текст — подпись кнопки и подсказка под шапкой по нажатию. */
  .run-status {
    justify-content: center;
    width: 32px;
    min-height: var(--tap-min);
    margin-right: auto;
    cursor: pointer;
  }

  .run-status__text {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }

  .run-status[data-open] .run-status__text {
    top: calc(100% + 6px);
    left: var(--gutter);
    right: var(--gutter);
    width: auto;
    height: auto;
    clip: auto;
    padding: var(--space-3);
    border: 1px solid var(--color-line);
    border-radius: var(--radius-md);
    background: var(--color-surface);
    box-shadow: var(--shadow-popover);
    color: var(--color-fg);
    white-space: normal;
    text-align: left;
  }

  .top__account {
    display: none;
  }

  .account-menu {
    display: block;
  }

  .account-menu .menu__list {
    right: 0;
    left: auto;
  }
}

/* Цели нажатия на телефоне — не меньше 24×24 (WCAG 2.5.8): тонкие ссылки и раскрытия получают отступы.
   Названия в «Покупках» переносятся, а не обрезаются: полного текста иначе не прочитать. */
@media (max-width: 760px) {
  .crumbs a,
  .panel-head-link,
  .rows__group-link {
    display: inline-block;
    padding-block: 6px;
  }

  .groups__summary {
    padding-block: 6px;
  }

  .purchased__name,
  .spend-list__name {
    padding-block: 3px;
  }
}
