/* MarketLek — дизайн-система. Значения здесь, принципы в design.md. */

:root {
  --bg: #F2F2F2;
  --surface: #FFFFFF;
  --surface-2: #F7F7F7;
  --border: #D6D6D6;
  --border-strong: #9A9A9A;
  --text: #1B1B1B;
  --text-muted: #5E5E5E;
  --accent: #1860D0;
  --accent-hover: #1452B5;
  --accent-soft: #E3EDFB;
  --on-accent: #FFFFFF;
  --hot: #D9480F;
  --hot-soft: #FDE8DD;
  --ok: #1E7F3C;
  --ok-soft: #DDF3E3;
  --warn: #9A5B00;
  --warn-soft: #FFEFC7;
  --danger: #C62828;
  --danger-soft: #FBE0E0;
  --focus: #1860D0;

  --font: "Segoe UI", Roboto, system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --fs-xs: 13px;
  --fs-s: 14px;
  --fs-m: 16px;
  --fs-l: 18px;
  --fs-xl: 22px;
  --fs-xxl: 28px;
  --lh: 1.4;

  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 24px;
  --s6: 32px;
  --r: 4px;
  --r-s: 2px;
  --touch: 44px;
  --shadow: 0 8px 24px rgba(0, 0, 0, .18);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1A1A1E;
    --surface: #26262B;
    --surface-2: #2E2E34;
    --border: #3B3B43;
    --border-strong: #6A6A75;
    --text: #ECECEE;
    --text-muted: #A6A6B0;
    --accent: #6AA6FF;
    --accent-hover: #86B6FF;
    --accent-soft: #223654;
    --on-accent: #0E1726;
    --hot: #FF8A4C;
    --hot-soft: #432A1D;
    --ok: #5CCB7A;
    --ok-soft: #1F3A28;
    --warn: #F2B544;
    --warn-soft: #3E3217;
    --danger: #FF6B6B;
    --danger-soft: #45201F;
    --focus: #6AA6FF;
    --shadow: 0 8px 24px rgba(0, 0, 0, .6);
  }
}
:root[data-theme="dark"] {
  --bg: #1A1A1E;
  --surface: #26262B;
  --surface-2: #2E2E34;
  --border: #3B3B43;
  --border-strong: #6A6A75;
  --text: #ECECEE;
  --text-muted: #A6A6B0;
  --accent: #6AA6FF;
  --accent-hover: #86B6FF;
  --accent-soft: #223654;
  --on-accent: #0E1726;
  --hot: #FF8A4C;
  --hot-soft: #432A1D;
  --ok: #5CCB7A;
  --ok-soft: #1F3A28;
  --warn: #F2B544;
  --warn-soft: #3E3217;
  --danger: #FF6B6B;
  --danger-soft: #45201F;
  --focus: #6AA6FF;
  --shadow: 0 8px 24px rgba(0, 0, 0, .6);
}

/* База */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: var(--fs-m)/var(--lh) var(--font);
  font-weight: 200;
  font-variant-numeric: tabular-nums;
}
h1, h2, h3, p { margin: 0; }
h1 { font-size: var(--fs-xxl); font-weight: 300; line-height: 1.2; }
h2 { font-size: var(--fs-xl); font-weight: 300; line-height: 1.25; }
h3 { font-size: var(--fs-l); font-weight: 300; line-height: 1.3; }
.muted { color: var(--text-muted); }
.small { font-size: var(--fs-s); }
.caption { font-size: var(--fs-xs); color: var(--text-muted); }
.num { font-weight: 300; font-variant-numeric: tabular-nums; }
.num-xl { font-size: var(--fs-xxl); font-weight: 300; line-height: 1.1; }
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* Иконки: Lucide, спрайт ui/lucide-sprite.svg */
.i { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: -4px; }
.i-s { width: 16px; height: 16px; vertical-align: -3px; }
.i-l { width: 28px; height: 28px; }

/* Раскладка */
.container { max-width: 1280px; margin: 0 auto; padding: 0 var(--s4); }
.stack > * + * { margin-top: var(--s4); }
.row { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; }
.grid { display: grid; gap: var(--s4); grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }

/* Шапка */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.topbar__in { display: flex; align-items: center; gap: var(--s3); min-height: 56px; }
.brand { font-weight: 100; font-size: var(--fs-l); letter-spacing: .01em; text-decoration: none; color: var(--text); display: flex; align-items: center; gap: var(--s2); }
.brand__mark { width: 28px; height: 28px; background: var(--accent); color: var(--on-accent); border-radius: var(--r); display: grid; place-items: center; font-size: 15px; font-weight: 400; }
.topbar__spacer { flex: 1; }

/* Вкладки */
.tabs { display: flex; gap: var(--s1); border-bottom: 1px solid var(--border); }
.tab {
  appearance: none; background: none; border: 0; border-bottom: 3px solid transparent;
  color: var(--text-muted); font: inherit; font-weight: 300; font-size: var(--fs-m);
  min-height: var(--touch); padding: 0 var(--s3); cursor: pointer; display: inline-flex; align-items: center; gap: var(--s2);
  margin-bottom: -1px;
}
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }
.tab .count { font-weight: 200; color: var(--text-muted); }

/* Боковое меню */
.sidenav { display: flex; flex-direction: column; gap: var(--s1); }
.sidenav__item {
  display: flex; align-items: center; gap: var(--s3); min-height: var(--touch); padding: 0 var(--s3);
  border-radius: var(--r); color: var(--text); text-decoration: none; font-weight: 200; border-left: 3px solid transparent;
}
.sidenav__item:hover { background: var(--surface-2); }
.sidenav__item[aria-current="page"] { background: var(--accent-soft); border-left-color: var(--accent); color: var(--text); }

/* Кнопки */
.btn {
  appearance: none; display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  min-height: var(--touch); padding: 0 var(--s4); border-radius: var(--r); border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); font: inherit; font-weight: 300; font-size: var(--fs-s); cursor: pointer; text-decoration: none;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.btn--primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn--primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn--danger { color: var(--danger); border-color: var(--danger); }
.btn--danger:hover { background: var(--danger-soft); }
.btn--ghost { border-color: transparent; background: transparent; }
.btn--ghost:hover { background: var(--surface-2); }
.btn--icon { width: var(--touch); padding: 0; }
.btn--lg { min-height: 48px; font-size: var(--fs-m); padding: 0 var(--s5); }
.btn--block { width: 100%; }

/* Поля */
.field { display: flex; flex-direction: column; gap: var(--s1); }
.label { font-size: var(--fs-s); font-weight: 300; }
.input, .select, .textarea {
  width: 100%; min-height: var(--touch); padding: 0 var(--s3); border: 1px solid var(--border-strong); border-radius: var(--r);
  background: var(--surface); color: var(--text); font: inherit; font-size: var(--fs-m);
}
.textarea { padding: var(--s2) var(--s3); min-height: 88px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--accent); outline: 2px solid var(--focus); outline-offset: 0; }
.input:disabled { background: var(--surface-2); color: var(--text-muted); }
.field--error .input { border-color: var(--danger); }
.hint { font-size: var(--fs-xs); color: var(--text-muted); }
.field--error .hint { color: var(--danger); }
.input-group { display: flex; }
.input-group .input { border-radius: var(--r) 0 0 var(--r); }
.input-group .btn { border-radius: 0 var(--r) var(--r) 0; border-left: 0; }
.search { position: relative; }
.search .i { position: absolute; left: var(--s3); top: 50%; transform: translateY(-50%); color: var(--text-muted); }
.search .input { padding-left: 40px; }

.check { display: flex; align-items: center; gap: var(--s3); min-height: var(--touch); cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); margin: 0; }

.switch { display: inline-flex; align-items: center; gap: var(--s3); min-height: var(--touch); cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch__track { width: 44px; height: 22px; border-radius: 11px; background: var(--border-strong); position: relative; transition: background .15s; flex: none; }
.switch__track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: var(--surface); transition: left .15s; }
.switch input:checked + .switch__track { background: var(--accent); }
.switch input:checked + .switch__track::after { left: 25px; }
.switch input:focus-visible + .switch__track { outline: 2px solid var(--focus); outline-offset: 2px; }

/* Чипы (ключи) */
.chip {
  white-space: nowrap; display: inline-flex; align-items: center; gap: var(--s1); min-height: 32px; padding: 0 var(--s2) 0 var(--s3);
  border: 1px solid var(--border); border-radius: var(--r-s); background: var(--surface-2); font-size: var(--fs-s); font-weight: 200;
}
.chip .btn--icon { width: 28px; min-height: 28px; }
.chip--add { background: none; border-style: dashed; color: var(--accent); cursor: pointer; font: inherit; font-size: var(--fs-s); font-weight: 200; padding: 0 var(--s3); }

/* Бейджи */
.badge { display: inline-flex; align-items: center; gap: var(--s1); height: 24px; padding: 0 var(--s2); border-radius: var(--r-s); font-size: var(--fs-xs); font-weight: 300; white-space: nowrap; }
.badge--ok { background: var(--ok-soft); color: var(--ok); }
.badge--warn { background: var(--warn-soft); color: var(--warn); }
.badge--danger { background: var(--danger-soft); color: var(--danger); }
.badge--hot { background: var(--hot-soft); color: var(--hot); }
.badge--neutral { background: var(--surface-2); color: var(--text-muted); border: 1px solid var(--border); }
.badge--accent { background: var(--accent-soft); color: var(--accent); }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; }
.dot--ok { background: var(--ok); } .dot--warn { background: var(--warn); } .dot--danger { background: var(--danger); }
.t-ok { color: var(--ok); } .t-warn { color: var(--warn); } .t-danger { color: var(--danger); } .t-hot { color: var(--hot); } .t-accent { color: var(--accent); }
.delta { font-size: var(--fs-s); font-weight: 300; display: inline-flex; align-items: center; gap: 2px; }

/* Карточки и плитки */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); padding: var(--s4); }
.card--danger { border-color: var(--danger); box-shadow: inset 4px 0 0 var(--danger); }
.card--warn { border-color: var(--warn); box-shadow: inset 4px 0 0 var(--warn); }
.card--hot { box-shadow: inset 4px 0 0 var(--hot); }
.card__head { display: flex; align-items: flex-start; gap: var(--s3); }
.card__title { font-weight: 300; font-size: var(--fs-m); line-height: 1.3; overflow-wrap: anywhere; }
.card__sub { font-size: var(--fs-xs); color: var(--text-muted); }
.card__thumb { width: 56px; height: 56px; border-radius: var(--r-s); background: var(--surface-2); border: 1px solid var(--border); flex: none; display: grid; place-items: center; color: var(--text-muted); }
.card__thumb--sm { width: 40px; height: 40px; }
.card__body { margin-top: var(--s3); }
.card__foot { margin-top: var(--s3); padding-top: var(--s3); border-top: 1px solid var(--border); display: flex; gap: var(--s2); align-items: center; flex-wrap: wrap; }
.card--clickable { cursor: pointer; }
.card--clickable:hover { border-color: var(--border-strong); }

/* Пары «подпись — значение» */
.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: var(--s3); }
.kv__k { font-size: var(--fs-xs); color: var(--text-muted); }
.kv__v { font-size: var(--fs-l); font-weight: 300; line-height: 1.2; }
.kv--inline { display: flex; flex-wrap: wrap; gap: var(--s2) var(--s5); }

/* Строки списка */
.list { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); }
.listrow { display: flex; align-items: center; gap: var(--s3); min-height: 56px; padding: var(--s2) var(--s4); border-bottom: 1px solid var(--border); text-decoration: none; color: inherit; }
.listrow:last-child { border-bottom: 0; }
.listrow:hover { background: var(--surface-2); }
.listrow__main { flex: 1; min-width: 0; }
.listrow__title { font-weight: 300; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; line-height: 1.3; }
.listrow__sub { font-size: var(--fs-xs); color: var(--text-muted); }
.listrow__val { text-align: right; flex: none; }
.listrow--danger { box-shadow: inset 4px 0 0 var(--danger); }
.listrow--warn { box-shadow: inset 4px 0 0 var(--warn); }
.group-title { display: flex; align-items: center; gap: var(--s2); padding: var(--s4) 0 var(--s2); font-size: var(--fs-s); font-weight: 300; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; }

/* Таблица */
.table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); font-size: var(--fs-s); }
.table th, .table td { padding: var(--s2) var(--s3); border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
.table th { font-size: var(--fs-xs); color: var(--text-muted); font-weight: 300; text-transform: uppercase; letter-spacing: .04em; background: var(--surface-2); }
.table td.r, .table th.r { text-align: right; }

/* Сообщения */
.banner { display: flex; gap: var(--s3); align-items: flex-start; padding: var(--s3) var(--s4); border-radius: var(--r); border: 1px solid; font-size: var(--fs-s); }
.banner--danger { background: var(--danger-soft); border-color: var(--danger); color: var(--text); }
.banner--danger .i { color: var(--danger); }
.banner--warn { background: var(--warn-soft); border-color: var(--warn); }
.banner--warn .i { color: var(--warn); }
.banner--ok { background: var(--ok-soft); border-color: var(--ok); }
.banner--ok .i { color: var(--ok); }
.banner--info { background: var(--accent-soft); border-color: var(--accent); }
.banner--info .i { color: var(--accent); }
.banner__title { font-weight: 300; }
.banner__body { flex: 1; }
.banner--loud { font-size: var(--fs-m); padding: var(--s4); }
.banner--loud .banner__title { font-size: var(--fs-l); }

.empty { text-align: center; padding: var(--s6) var(--s4); color: var(--text-muted); border: 1px dashed var(--border-strong); border-radius: var(--r); }
.empty .i-l { color: var(--text-muted); margin-bottom: var(--s2); }
.empty__title { font-weight: 300; color: var(--text); margin-bottom: var(--s1); }
.skeleton { background: linear-gradient(90deg, var(--surface-2), var(--border), var(--surface-2)); background-size: 200% 100%; border-radius: var(--r-s); height: 16px; }

/* Боковая панель подробностей */
.panel { background: var(--surface); border-left: 1px solid var(--border); display: flex; flex-direction: column; }
.panel__head { display: flex; align-items: center; gap: var(--s3); padding: var(--s3) var(--s4); border-bottom: 1px solid var(--border); }
.panel__body { padding: var(--s4); overflow: auto; flex: 1; min-height: 0; }
.panel__foot { padding: var(--s3) var(--s4); border-top: 1px solid var(--border); display: flex; gap: var(--s2); }
.section-title { font-size: var(--fs-xs); font-weight: 300; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: var(--s2); }

/* Диалог */
.dialog { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); box-shadow: var(--shadow); max-width: 440px; width: 100%; }
.dialog__head { padding: var(--s4); border-bottom: 1px solid var(--border); }
.dialog__body { padding: var(--s4); }
.dialog__foot { padding: var(--s3) var(--s4); border-top: 1px solid var(--border); display: flex; gap: var(--s2); justify-content: flex-end; }

/* Мини-график (спарклайн) */
.spark { width: 100%; height: 40px; display: block; }
.spark path { fill: none; stroke: var(--accent); stroke-width: 1.25; vector-effect: non-scaling-stroke; }
.spark .tick { stroke: var(--border-strong); stroke-width: 1; vector-effect: non-scaling-stroke; }
.spark--tall { height: 150px; }
.spark-wrap { position: relative; touch-action: none; overscroll-behavior: contain; }
.spark-day, .spark-day[data-tip] { position: absolute; top: 0; bottom: 0; width: 9%; transform: translateX(-50%); }
.spark-day:hover { background: rgba(24, 96, 208, .12); }
.spark-day.is-active { background: rgba(24, 96, 208, .12); }
.spark-wrap .spark-day.is-active[data-tip]::after, .spark-wrap .spark-day[data-tip]:hover::after { left: 50%; transform: translateX(-50%); top: 0; bottom: auto; }
.spark-wrap .spark-day--l.is-active[data-tip]::after, .spark-wrap .spark-day--l[data-tip]:hover::after { left: 0; transform: none; }
.spark-wrap .spark-day--r.is-active[data-tip]::after, .spark-wrap .spark-day--r[data-tip]:hover::after { left: auto; right: 0; transform: none; }
.spark-day { cursor: crosshair; }
.price-grid > div:nth-child(2) .section-title { text-align: right; }
.price-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--s3); align-items: start; }
.table--keys { font-size: 12px; table-layout: fixed; }
.table--keys th, .table--keys td { padding: var(--s1) var(--s2); overflow-wrap: normal; word-break: normal; }
.table--keys th { letter-spacing: 0; }

/* Нижняя навигация на телефоне */
.bottomnav { position: fixed; left: 0; right: 0; bottom: 0; display: flex; background: var(--surface); border-top: 1px solid var(--border); z-index: 10; }
.bottomnav__item { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 56px; font-size: 11px; white-space: nowrap; font-weight: 300; color: var(--text-muted); text-decoration: none; }
.bottomnav__item[aria-current="page"] { color: var(--accent); }

@media (max-width: 767px) {
  .hide-m { display: none !important; }
}
@media (min-width: 768px) {
  .hide-d { display: none !important; }
}

/* Подсказка при наведении: data-tip на любом элементе */
[data-tip] { position: relative; }
[data-tip]:hover::after, [data-tip]:focus-visible::after, .is-active[data-tip]::after {
  content: attr(data-tip); position: absolute; left: 50%; top: calc(100% + 6px); transform: translateX(-50%);
  background: var(--text); color: var(--bg); font-size: var(--fs-xs); font-weight: 200; line-height: 1.3;
  padding: var(--s1) var(--s2); border-radius: var(--r-s); white-space: nowrap; z-index: 30; pointer-events: none;
}
.tip-top[data-tip]::after { top: auto; bottom: calc(100% + 6px); }
.st[data-tip]::after, .sq[data-tip]::after, .wh[data-tip]::after { left: 0; transform: none; }
.tip-right[data-tip]::after { left: auto; right: 0; transform: none; }
/* Порог остатка — микротекстом индексом сверху */
.sup-min { font-size: 11px; font-weight: 200; color: var(--text-muted); vertical-align: super; margin-left: 2px; line-height: 1; }
/* Склады: продавца с человечком, WB фиолетовый с буквами */
.wh { display: inline-flex; align-items: center; gap: 3px; font-weight: 300; font-size: var(--fs-s); }
.wh svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.wh .wh__house { stroke-width: 1.5; opacity: .75; }
.wh--wb { color: #CB11AB; }
.wh--wb text { fill: currentColor; stroke: none; font-size: 6.5px; font-weight: 700; letter-spacing: -.2px; font-family: var(--font); }
body.no-scroll { overflow: hidden; position: fixed; left: 0; right: 0; overscroll-behavior: none; }
.sheet .panel__body { overscroll-behavior: contain; }
/* Иконка состояния: цвет по смыслу, подпись в подсказке */
.st { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: var(--r-s); flex: none; }
.st--danger { color: var(--danger); background: var(--danger-soft); }
.st--warn { color: var(--warn); background: var(--warn-soft); }
.st--ok { color: var(--ok); background: var(--ok-soft); }
.st--muted { color: var(--text-muted); background: var(--surface-2); }
.st-row { display: flex; gap: var(--s1); align-items: center; flex-wrap: wrap; }
.st-row .pos { font-size: var(--fs-s); font-weight: 300; margin-left: 2px; }

/* Квадратная плитка сводки: иконка и число, подпись в подсказке */
.sq { width: 52px; height: 52px; border: 1px solid var(--border); border-radius: var(--r); background: var(--surface); display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: var(--fs-xs); font-weight: 300; color: var(--text); cursor: default; }
.sq .i { width: 18px; height: 18px; }
.sq--danger { border-color: var(--danger); color: var(--danger); }
.sq--warn { border-color: var(--warn); color: var(--warn); }
.sq-row { display: flex; gap: var(--s2); }

/* Шторка снизу на телефоне */
.sheet { position: fixed; left: 0; right: 0; bottom: 0; max-height: 86vh; background: var(--surface); border-top: 1px solid var(--border); border-radius: var(--r) var(--r) 0 0; transform: translateY(100%); transition: transform .15s; z-index: 20; display: flex; flex-direction: column; box-shadow: var(--shadow); }
.sheet.open { transform: none; }
/* ручка — полоса во всю ширину под палец, сама чёрточка внутри */
.sheet__handle { flex: none; padding: var(--s3) 0 var(--s2); touch-action: none; }
.sheet__handle::before { content: ""; display: block; width: 40px; height: 4px; border-radius: 2px; background: var(--border-strong); margin: 0 auto; }

/* Тихая прокрутка: дорожка прозрачная, ползунок виден при наведении и во время прокрутки */
.scroll-quiet { overflow: auto; scrollbar-width: thin; scrollbar-color: transparent transparent; }
.scroll-quiet:hover, .scroll-quiet.scrolling { scrollbar-color: rgba(0, 0, 0, .35) transparent; }
.scroll-quiet::-webkit-scrollbar { width: 6px; }
.scroll-quiet::-webkit-scrollbar-track { background: transparent; }
.scroll-quiet::-webkit-scrollbar-thumb { background: transparent; border-radius: 3px; }
.scroll-quiet:hover::-webkit-scrollbar-thumb, .scroll-quiet.scrolling::-webkit-scrollbar-thumb { background: rgba(0, 0, 0, .35); }
:root[data-theme="dark"] .scroll-quiet:hover, :root[data-theme="dark"] .scroll-quiet.scrolling { scrollbar-color: rgba(255, 255, 255, .35) transparent; }

/* Атрибут hidden сильнее display у элементов */
[hidden] { display: none !important; }

/* Плавность: переходы у всего интерактивного, появление панелей и подсказок */
a, button, .btn, .tab, .sidenav__item, .listrow, .d-row, .card, .chip, .sq, .st, .input, .select, .switch__track, .bottomnav__item, .spark-day { transition: background-color .18s ease, border-color .18s ease, color .18s ease, box-shadow .18s ease, opacity .18s ease, transform .18s ease; }
.btn:active, .sq:active, .st:active { transform: scale(.97); }
@keyframes fade-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
[data-tip]:hover::after, [data-tip]:focus-visible::after { animation: fade-in .15s ease; }
.panel__body > * { animation: fade-in .25s ease; }
.panel.fading .panel__body > * { opacity: 0; transition: opacity .12s ease; }
.list, .card { animation: fade-in .3s ease; }
.sheet { transition: transform .25s cubic-bezier(.2, .8, .2, 1); }
.scrim { transition: opacity .2s ease; opacity: 0; }
.scrim.open { opacity: 1; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* Миниатюра с фото и всплывающее увеличение */
.card__thumb--img { overflow: hidden; padding: 0; background: var(--surface); cursor: pointer; }
.card__thumb--img[data-tip]::after { left: 0; transform: none; }
.d-nm { font-size: 11px; }
@media (max-width: 1100px) { .d-nm { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; } }
.card__thumb--img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.zoom { position: fixed; z-index: 40; width: 258px; height: 344px; border: 1px solid var(--border); border-radius: var(--r); background: var(--surface); box-shadow: var(--shadow); overflow: hidden; opacity: 0; pointer-events: none; transform: scale(.96); transition: opacity .15s ease, transform .15s ease; }
.zoom.open { opacity: 1; transform: none; }
.zoom img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* Свайп строки влево: действие под строкой */
.swipe { position: relative; overflow: hidden; }
.swipe .d-row { position: relative; background: var(--surface); transition: transform .2s ease; }
.swipe__action { position: absolute; top: 0; bottom: 0; right: 0; width: 120px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: #fff; font-size: 11px; font-weight: 400; }
.swipe__action--danger { background: var(--danger); } .swipe__action--hot { background: var(--hot); }
.swipe.gone { max-height: 0; opacity: 0; transition: max-height .3s ease, opacity .25s ease; }
/* Модальное подтверждение */
.modal { position: fixed; inset: 0; z-index: 45; display: flex; align-items: center; justify-content: center; padding: var(--s4); background: rgba(0, 0, 0, .35); opacity: 0; pointer-events: none; transition: opacity .2s ease; }
.modal.open { opacity: 1; pointer-events: auto; }
.modal .dialog { animation: fade-in .2s ease; }

/* Кнопка периода в шапке и всплывающее меню */
.period-btn { appearance: none; display: inline-flex; align-items: center; gap: var(--s1); min-height: 36px; padding: 0 var(--s2); border: 1px solid var(--border); border-radius: var(--r); background: var(--surface); color: var(--text); font: inherit; font-size: var(--fs-s); cursor: pointer; margin-left: var(--s2); white-space: nowrap; }
.period-btn:hover { background: var(--surface-2); border-color: var(--border-strong); }
.popover { position: absolute; top: 52px; left: var(--s4); z-index: 30; width: min(360px, calc(100vw - 32px)); background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); box-shadow: var(--shadow); padding: var(--s4); opacity: 0; pointer-events: none; transform: translateY(-4px); transition: opacity .15s ease, transform .15s ease; }
.popover.open { opacity: 1; pointer-events: auto; transform: none; }
.popover .chip { cursor: pointer; }
.popover .chip[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

/* Календарь: один месяц, выбор дня */
.popover--cal { width: 320px; }
.cal__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--s2); }
.cal__title { font-weight: 400; text-transform: capitalize; }
.cal__grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.cal__dow { font-size: var(--fs-xs); color: var(--text-muted); text-align: center; padding: var(--s1) 0; }
.cal__day { appearance: none; border: 0; background: none; font: inherit; font-size: var(--fs-s); color: var(--text); height: 38px; border-radius: var(--r); cursor: pointer; }
.cal__day:hover { background: var(--surface-2); }
.cal__day[disabled] { color: var(--border-strong); cursor: default; background: none; }
.cal__day.is-last { box-shadow: inset 0 0 0 1px var(--accent); }
.cal__day.is-sel { background: var(--accent); color: var(--on-accent); }

@media (max-width: 1100px) { html, body { overflow-x: clip; } } /* clip, не hidden: hidden делает body прокручиваемым контейнером и ломает sticky у шапки */

/* На тач-экранах подсказки по наведению не живут: касание «залипает» в :hover и накладывается на подсветку пальцем */
@media (hover: none) { [data-tip]:hover:not(.is-active):not(:focus-visible)::after { display: none; } .spark-day:hover:not(.is-active) { background: none; } }

/* Строка карточки: артикул продавца крупно, название товара микротекстом в одну строку */
.d-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* Артикул продавца целиком, перенос только по словам */
.d-row .listrow__title, .panel .card__title, .dialog .small b { display: block; -webkit-line-clamp: unset; overflow: visible; white-space: normal; overflow-wrap: normal; word-break: normal; hyphens: none; }

/* Теги в строке поиска: иконка со счётчиком, список по клику, выбранные — чипами под полем */
.searchbox { position: relative; }
.search--tags .input { padding-right: 48px; }
.search__tags { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 40px; height: 36px; border: 0; background: none; border-radius: var(--r); color: var(--text-muted); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 2px; }
.search__tags:hover { background: var(--surface-2); color: var(--text); }
.search__count { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--accent); color: var(--on-accent); font-size: 11px; font-weight: 400; display: inline-flex; align-items: center; justify-content: center; }
.tagbar { display: flex; gap: var(--s2); flex-wrap: wrap; }
.tagbar:not(:empty) { margin-top: var(--s2); }
.chip--tag { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.chip--tag .btn--icon { color: var(--accent); }
.chip--mode { cursor: pointer; font-size: var(--fs-xs); min-height: 32px; }
.popover--tags { top: calc(100% + 6px); left: auto; right: 0; width: min(420px, calc(100vw - 32px)); }
.taglist { display: flex; flex-direction: column; max-height: 300px; overflow: auto; }
.tagrow { display: flex; align-items: center; gap: var(--s2); min-height: 40px; padding: 0 var(--s1); border-radius: var(--r-s); cursor: pointer; }
.tagrow:hover { background: var(--surface-2); }
.tagrow input { width: 18px; height: 18px; accent-color: var(--accent); margin: 0; flex: none; }
.tagrow__name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tagrow .caption { max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tagrow__n { font-size: var(--fs-xs); color: var(--text-muted); min-width: 28px; text-align: right; }
.tagrow .btn--icon { width: 32px; min-height: 32px; opacity: 0; }
.tagrow:hover .btn--icon, .tagrow .btn--icon:focus-visible { opacity: 1; }
@media (hover: none) { .tagrow .btn--icon { opacity: 1; } }
.tagnew { margin-top: var(--s3); padding-top: var(--s3); border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: var(--s3); }
@media (max-width: 1100px) {
  .popover--tags { position: fixed; top: auto; left: 0; right: 0; bottom: 56px; width: auto; border-bottom: 1px solid var(--border); border-radius: var(--r) var(--r) 0 0; max-height: 80vh; overflow: auto; transform: translateY(100%); }
  .popover--tags.open { transform: none; }
}

/* Телефон: поиск, сводка и теги — в шторке по кнопке «Поиск» нижнего меню (решение 16.10.2026) */
.fbadge { position: relative; }
.fbadge.is-on::after { content: ''; position: absolute; top: 9px; right: 9px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 2px var(--surface); }
.bottomnav__item.fbadge.is-on::after { top: 8px; right: calc(50% - 16px); }
.msheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 21; max-height: 86vh; overflow: hidden; background: var(--surface); border-top: 1px solid var(--border); border-radius: var(--r) var(--r) 0 0; box-shadow: var(--shadow); transform: translateY(110%); transition: transform .25s cubic-bezier(.2, .8, .2, 1); padding: 0 var(--s4) var(--s4); display: flex; flex-direction: column; gap: var(--s3); }
.msheet.open { transform: none; }
.msheet__head { display: flex; align-items: center; gap: var(--s2); }
.msheet__head .searchbox { flex: 1; }
.msheet .sq { flex: 1; width: auto; }
.msheet__tags { flex: 1; min-height: 0; overflow: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.msheet__tags .taglist { max-height: none; }
/* форма тега на телефоне: одна в шторке, вверху, чтобы клавиатура её не закрывала */
.msheet.is-form > :not(.sheet__handle):not(.msheet__tags), .msheet.is-form .msheet__tags > :not(.tagnew) { display: none; }
.msheet.is-form .tagnew { margin-top: 0; padding-top: 0; border-top: 0; }
/* на время формы шторка прилипает к верху экрана: там клавиатуры не бывает */
.msheet.is-form { top: 0; bottom: auto; max-height: none; border-top: 0; border-bottom: 1px solid var(--border); border-radius: 0 0 var(--r) var(--r); padding-top: calc(var(--s4) + env(safe-area-inset-top)); }
.msheet.is-form .sheet__handle { display: none; }
/* невидимая зона под палец вокруг маленькой кнопки (крестик шторки) */
.btn--hit { position: relative; }
.btn--hit::after { content: ""; position: absolute; inset: -12px; }
/* Активный фильтр: слово поиска и теги чипами над нижним меню */
.mfilt { display: flex; gap: var(--s2); flex-wrap: wrap; }
.mfilt:empty { display: none; }
.mfilter { position: fixed; left: 0; right: 0; bottom: 56px; z-index: 11; background: var(--surface); border-top: 1px solid var(--border); padding: var(--s2) var(--s4); }
.mfilter:empty { display: none; }
body.has-filter .d-main { padding-bottom: 152px; }
