@font-face {
  font-family: "Manrope";
  font-style: normal;
  font-display: swap;
  font-weight: 200 800;
  src: url(fonts/manrope-cyrillic-wght-normal.woff2) format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "Manrope";
  font-style: normal;
  font-display: swap;
  font-weight: 200 800;
  src: url(fonts/manrope-latin-wght-normal.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --red: #C01506;
  --red-dark: #9F072C;
  --red-tint: #FCEBEA;
  --ink: #111111;
  --text: #3F434B;
  --muted: #5B5F69;
  --line: #DDE1EA;
  --line-strong: #A9AFBA;
  --bg: #F1F3F8;
  --white: #FFFFFF;
  --ok: #16794A;
  --ok-tint: #E4F4EC;
  --warn: #8A5A00;
  --warn-tint: #FFF3D6;
  --panel: #1F3A68;
  --radius: 14px;
  --tabbar: 62px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body {
  background: #E4E7EE;
  color: var(--ink);
  font-family: Manrope, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea, a { font-family: inherit; font-size: inherit; }
button { color: inherit; cursor: pointer; }
[hidden] { display: none !important; }
h2 { font-size: 17px; margin: 0 0 10px; font-weight: 800; }
h3 { font-size: 13px; margin: 16px 0 8px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.hint { color: var(--muted); font-size: 13px; margin: 8px 0 0; line-height: 1.4; }

.app {
  position: relative;
  max-width: 600px;
  margin: 0 auto;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  overflow: hidden;
}
@media (min-width: 640px) { .app { box-shadow: 0 0 40px rgba(0,0,0,.08); } }

/* ---------- Горна лента ---------- */
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: calc(8px + env(safe-area-inset-top)) 12px 8px;
  background: var(--ink); color: #fff;
  flex: none;
}
.brand { display: flex; align-items: center; gap: 9px; min-width: 0; }
.brand svg { flex: none; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; min-width: 0; }
.brand-text b { font-size: 16px; font-weight: 800; }
.brand-text span { font-size: 11.5px; color: #C9CCD3; white-space: nowrap; }
.sync {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(255,255,255,.1); color: #fff; border: 0; border-radius: 999px;
  padding: 7px 11px; font-size: 12px; font-weight: 600; white-space: nowrap; min-width: 0;
}
.sync span { overflow: hidden; text-overflow: ellipsis; }
.sync.loading .sync-ico { animation: spin 1s linear infinite; }
.sync.err { background: rgba(192,21,6,.35); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Раздели ---------- */
.tabs-main { position: relative; flex: 1; min-height: 0; }
.tab {
  position: absolute; inset: 0;
  overflow-y: auto; overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 24px;
  overscroll-behavior: contain;
}
.tabbar {
  flex: none; display: flex;
  background: #fff; border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar button {
  flex: 1; border: 0; background: none; height: var(--tabbar);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font-size: 12px; font-weight: 700; color: var(--muted);
}
.tabbar button.on { color: var(--red); }
.ico-wrap { position: relative; display: inline-flex; }
.badge {
  position: absolute; top: -6px; right: -12px;
  min-width: 19px; height: 19px; padding: 0 5px; border-radius: 10px;
  background: var(--red); color: #fff; font-size: 11px; font-weight: 800;
  display: inline-flex; align-items: center; justify-content: center;
  border: 2px solid #fff;
}

/* ---------- Каталог ---------- */
.cat-top {
  position: sticky; top: 0; z-index: 5;
  background: var(--bg);
  padding: 10px 12px 4px;
  border-bottom: 1px solid transparent;
}
.cat-top.stuck { border-bottom-color: var(--line); box-shadow: 0 6px 12px -10px rgba(0,0,0,.25); }
.search {
  display: flex; align-items: center; gap: 8px;
  background: #fff; border: 1.5px solid var(--line); border-radius: 12px;
  padding: 0 6px 0 12px; height: 46px; color: var(--muted);
}
.search:focus-within { border-color: var(--ink); }
.search input {
  flex: 1; min-width: 0; border: 0; outline: 0; background: none; height: 100%;
  font-size: 16px; color: var(--ink);
}
.search input::-webkit-search-cancel-button { display: none; }
.q-clear { border: 0; background: var(--bg); width: 32px; height: 32px; border-radius: 50%; font-size: 20px; line-height: 1; color: var(--muted); }

.cat-rows { margin-top: 8px; }
.chip-row {
  display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 8px;
  scrollbar-width: none;
}
.chip-row::-webkit-scrollbar { display: none; }
.chip-row.sub { padding-top: 0; }
.chip {
  flex: none; border: 1.5px solid var(--line); background: #fff;
  border-radius: 999px; padding: 7px 12px; font-size: 13.5px; font-weight: 600; white-space: nowrap;
}
.chip small { color: var(--muted); font-weight: 600; margin-left: 4px; }
.chip.on { background: var(--ink); border-color: var(--ink); color: #fff; }
.chip.on small { color: #C9CCD3; }
.chip-row.sub .chip { background: transparent; font-size: 13px; padding: 5px 10px; }
.chip-row.sub .chip.on { background: var(--red); border-color: var(--red); color: #fff; }
.chip-row.sub .chip.on small { color: #FFD9D5; }

.list-tools {
  display: flex; align-items: center; gap: 10px; padding: 4px 12px 8px; font-size: 13px;
}
.list-tools #listCount { flex: 1; min-width: 0; }
.tool-check { display: inline-flex; align-items: center; gap: 5px; color: var(--muted); white-space: nowrap; }
.tool-check input { width: 16px; height: 16px; accent-color: var(--red); margin: 0; }
.list-tools select {
  border: 1.5px solid var(--line); background: #fff; border-radius: 9px; padding: 5px 8px; font-weight: 600; color: var(--ink);
}

.plist { padding: 0 12px; display: flex; flex-direction: column; gap: 8px; }
.pi {
  display: flex; gap: 11px; align-items: stretch;
  background: #fff; border-radius: var(--radius); padding: 10px;
  border: 1.5px solid transparent;
  cursor: pointer;
}
.pi.in-cart { border-color: var(--red); }
.pi.oos { opacity: .72; }
.pi-img {
  flex: none; width: 64px; height: 64px; border-radius: 10px; background: var(--bg);
  object-fit: contain; align-self: center;
}
.pi-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.pi-name {
  font-size: 14px; font-weight: 700; line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.pi-meta { display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; font-size: 12px; color: var(--muted); }
.sku { font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.stock { font-weight: 700; padding: 1px 7px; border-radius: 6px; font-size: 11.5px; white-space: nowrap; }
.stock.ok { background: var(--ok-tint); color: var(--ok); }
.stock.low { background: var(--warn-tint); color: var(--warn); }
.stock.no { background: #EEE; color: #666; }
.pi-bottom { display: flex; align-items: flex-end; justify-content: space-between; gap: 8px; margin-top: auto; }
.price { display: flex; flex-direction: column; line-height: 1.15; }
.price b { font-size: 16px; font-weight: 800; white-space: nowrap; }
.price b s { font-size: 12px; color: var(--muted); font-weight: 600; margin-left: 5px; }
.price small { font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.add-btn {
  flex: none; width: 40px; height: 40px; border-radius: 12px; border: 0;
  background: var(--red); color: #fff; font-size: 24px; font-weight: 600; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
}
.add-btn:disabled { background: #D6D9E0; }

.qty {
  flex: none; display: inline-flex; align-items: center;
  border: 1.5px solid var(--ink); border-radius: 12px; height: 40px; overflow: hidden; background: #fff;
}
.qty button { width: 36px; height: 100%; border: 0; background: none; font-size: 20px; font-weight: 700; }
.qty input {
  width: 44px; height: 100%; border: 0; text-align: center; font-weight: 800; font-size: 15px;
  background: none; outline: 0; padding: 0; color: var(--ink);
}
.qty.big { height: 48px; }
.qty.big button { width: 48px; }
.qty.big input { width: 60px; font-size: 17px; }

.list-more { padding: 14px 12px; text-align: center; color: var(--muted); font-size: 13px; }
.empty { text-align: center; padding: 48px 24px; color: var(--muted); }
.empty svg { color: var(--line-strong); }
.empty p { margin: 6px 0; }
.skel { background: #fff; border-radius: var(--radius); height: 86px; position: relative; overflow: hidden; }
.skel::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(0,0,0,.04), transparent);
  animation: sh 1.2s infinite;
}
@keyframes sh { from { transform: translateX(-100%); } to { transform: translateX(100%); } }

/* ---------- Бутони, карти ---------- */
.card { background: #fff; border-radius: var(--radius); padding: 16px; margin: 12px; }
.btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  width: 100%; min-height: 50px; border-radius: 13px; border: 1.5px solid var(--ink);
  background: var(--ink); color: #fff; font-weight: 800; font-size: 15px; text-decoration: none;
  padding: 10px 14px; text-align: center;
}
.btn small { font-weight: 600; font-size: 11.5px; opacity: .85; }
.btn.primary { background: var(--red); border-color: var(--red); }
.btn.ghost { background: #fff; color: var(--ink); }
.btn.viber { background: #7360F2; border-color: #7360F2; flex-direction: row; gap: 8px; }
.btn:disabled { opacity: .5; }
.btn-row { display: flex; gap: 8px; }
.link-btn { border: 0; background: none; text-decoration: underline; font-weight: 600; padding: 8px; }
.link-btn.danger { color: var(--red-dark); display: block; margin: 4px auto 16px; }

/* ---------- Калкулатор ---------- */
.dims { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.dim { min-width: 0; }
.dim label { display: block; font-size: 12.5px; font-weight: 700; color: var(--muted); margin-bottom: 5px; }
.stepper {
  display: grid; grid-template-columns: 40px minmax(0,1fr) 40px; height: 48px;
  border: 1.5px solid var(--line-strong); border-radius: 12px; overflow: hidden; background: #fff;
}
.stepper button { border: 0; background: var(--bg); font-size: 22px; font-weight: 700; }
.stepper input {
  min-width: 0; width: 100%; border: 0; text-align: center; font-size: 18px; font-weight: 800; outline: 0; padding: 0; color: var(--ink);
}
.seg { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; background: var(--bg); padding: 4px; border-radius: 12px; }
.seg button { border: 0; background: none; border-radius: 9px; padding: 9px 2px; font-weight: 700; font-size: 13.5px; color: var(--muted); }
.seg button.on { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button { border: 1.5px solid var(--line); background: #fff; border-radius: 999px; padding: 7px 12px; font-size: 13.5px; font-weight: 600; }
.chips button.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.chips.small button { padding: 5px 10px; font-size: 12.5px; }
.res-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 14px 4px; flex-wrap: wrap; }
.res-head h2 { margin: 0; }
.calc-list { padding: 6px 12px 0; display: flex; flex-direction: column; gap: 8px; }
.cp { background: #fff; border-radius: var(--radius); border: 1.5px solid transparent; overflow: hidden; }
.cp.open { border-color: var(--ink); }
.cp-head { display: flex; gap: 11px; padding: 11px; align-items: center; width: 100%; border: 0; background: none; text-align: left; }
.cp-head img { width: 52px; height: 52px; border-radius: 9px; background: var(--bg); object-fit: contain; flex: none; }
.cp-main { flex: 1; min-width: 0; }
.cp-name { font-weight: 700; font-size: 14px; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cp-spec { font-size: 12px; color: var(--muted); margin-top: 2px; }
.cp-tags { display: flex; gap: 4px; margin-top: 4px; flex-wrap: wrap; }
.tag { font-size: 11px; font-weight: 800; padding: 2px 6px; border-radius: 6px; background: var(--red-tint); color: var(--red-dark); }
.tag.dark { background: #E6E9F0; color: var(--ink); }
.cp-fig { text-align: right; flex: none; }
.cp-fig b { display: block; font-size: 18px; font-weight: 800; white-space: nowrap; }
.cp-fig span { font-size: 12px; color: var(--muted); white-space: nowrap; }
.cp-body { padding: 0 12px 14px; border-top: 1px solid var(--line); }
.cp-draw { margin: 12px 0 4px; background: var(--bg); border-radius: 10px; padding: 8px; }
.cp-draw svg { display: block; width: 100%; height: auto; max-height: 260px; }
.cp-n { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 12px 0; }
.cp-n .lbl { font-weight: 700; }
.cp-n .lbl small { display: block; font-weight: 600; color: var(--muted); font-size: 12px; }
.grp { border-top: 1px solid var(--line); padding: 10px 0 4px; }
.grp-head { display: flex; align-items: center; gap: 8px; font-weight: 800; }
.grp-head label { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; }
.grp-head input { width: 19px; height: 19px; accent-color: var(--red); margin: 0; }
.grp-head .sum { white-space: nowrap; }
.grp.off .ln, .grp.off .grp-head .sum { opacity: .4; }
.ln { display: flex; gap: 8px; font-size: 13px; padding: 5px 0 5px 27px; align-items: baseline; }
.ln .nm { flex: 1; min-width: 0; }
.ln .nm small { color: var(--muted); display: block; font-size: 11.5px; }
.ln .q { white-space: nowrap; color: var(--muted); }
.ln .t { white-space: nowrap; font-weight: 700; min-width: 70px; text-align: right; }
.ln.warn .nm { color: var(--warn); }
.note { font-size: 12px; color: var(--muted); padding: 4px 0 4px 27px; line-height: 1.4; margin: 0; }
.inv-sel { margin: 4px 0 6px 27px; width: calc(100% - 27px); border: 1.5px solid var(--line-strong); border-radius: 10px; padding: 8px; background: #fff; font-weight: 600; color: var(--ink); }
.cp-total { display: flex; justify-content: space-between; align-items: baseline; margin: 12px 0 10px; font-weight: 800; }
.cp-total b { font-size: 20px; }
.foot-note { font-size: 12px; color: var(--muted); padding: 10px 16px; line-height: 1.45; margin: 0; }

/* ---------- Количка ---------- */
.cart-sticky {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--bg); padding: 10px 12px; border-bottom: 1px solid var(--line);
}
.cart-sticky b { font-size: 16px; font-weight: 800; min-width: 0; }
.cart-sticky .btn { width: auto; min-height: 40px; padding: 6px 16px; font-size: 14px; flex: none; }
.cart-lines { padding: 12px 12px 0; display: flex; flex-direction: column; gap: 8px; }
.cl { background: #fff; border-radius: var(--radius); padding: 10px; display: flex; gap: 10px; }
.cl img { width: 52px; height: 52px; border-radius: 9px; background: var(--bg); object-fit: contain; flex: none; }
.cl-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.cl-name { font-weight: 700; font-size: 13.5px; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.cl-sub { font-size: 12px; color: var(--muted); }
.cl-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 4px; }
.cl-row b { font-size: 15px; white-space: nowrap; }
.cl-warn { font-size: 12px; font-weight: 700; color: var(--warn); }
.totals { margin-top: 12px; }
.tot-row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; padding: 2px 0; }
.tot-row b { font-size: 22px; font-weight: 800; }
.order-form { scroll-margin-top: 64px; }
.order-form label { display: block; font-size: 13px; font-weight: 700; color: var(--muted); margin-top: 10px; }
.order-form input:not([type=radio]), .order-form textarea {
  display: block; width: 100%; margin-top: 4px; border: 1.5px solid var(--line-strong); border-radius: 10px;
  padding: 11px 12px; font-size: 16px; color: var(--ink); background: #fff; font-weight: 600; resize: vertical;
}
.order-form input:focus, .order-form textarea:focus { outline: 0; border-color: var(--ink); }
.order-form .bad { border-color: var(--red) !important; background: var(--red-tint) !important; }
.radio-row { border: 0; padding: 0; margin: 12px 0 0; }
.radio-row legend { font-size: 13px; font-weight: 700; color: var(--muted); padding: 0; }
.radio-row label { display: flex; gap: 9px; align-items: flex-start; color: var(--ink); font-weight: 600; margin-top: 8px; line-height: 1.3; }
.radio-row input { width: 19px; height: 19px; accent-color: var(--red); margin: 0; flex: none; }
.order-actions { padding: 0 12px; display: flex; flex-direction: column; gap: 8px; }
.import-bar p { margin: 0 0 10px; font-weight: 700; }
.import-bar .btn-row .btn { min-height: 44px; font-size: 14px; }

/* ---------- Лист с продукт ---------- */
.backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.45); z-index: 30; }
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 31;
  max-height: 92%; overflow-y: auto; overscroll-behavior: contain;
  background: #fff; border-radius: 20px 20px 0 0;
  padding: 8px 16px calc(18px + env(safe-area-inset-bottom));
  animation: up .2s ease-out;
}
@keyframes up { from { transform: translateY(40px); opacity: .4; } }
.sheet-grab { width: 42px; height: 5px; border-radius: 3px; background: var(--line); margin: 2px auto 8px; }
.sheet-x { position: absolute; top: 8px; right: 10px; width: 38px; height: 38px; border-radius: 50%; border: 0; background: var(--bg); font-size: 24px; line-height: 1; z-index: 2; }
.pd-img { width: 100%; aspect-ratio: 4 / 3; max-height: 40vh; object-fit: contain; background: var(--bg); border-radius: 14px; display: block; }
.pd-thumbs { display: flex; gap: 6px; margin-top: 6px; overflow-x: auto; }
.pd-thumbs img { width: 54px; height: 54px; border-radius: 8px; object-fit: contain; background: var(--bg); border: 2px solid transparent; flex: none; }
.pd-thumbs img.on { border-color: var(--ink); }
.pd h2 { font-size: 17px; margin: 12px 40px 4px 0; line-height: 1.3; }
.pd .pi-meta { margin-bottom: 10px; }
.pd .price b { font-size: 24px; }
.pd .price small { font-size: 13px; }
.pd-buy { display: flex; gap: 10px; align-items: center; margin: 14px 0 8px; }
.pd-buy .btn { flex: 1; min-height: 48px; }
.pd-links { display: flex; gap: 8px; margin: 8px 0 4px; }
.pd-links a { flex: 1; font-size: 13px; min-height: 42px; }
.pd-desc { white-space: pre-line; font-size: 14px; line-height: 1.5; color: var(--text); margin: 14px 0 0; }
.pd-attrs { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 12px; }
.pd-attrs td { padding: 6px 0; border-top: 1px solid var(--line); vertical-align: top; }
.pd-attrs td:first-child { color: var(--muted); padding-right: 10px; width: 42%; }

/* ---------- Известие ---------- */
.toast {
  position: absolute; left: 12px; right: 12px; bottom: calc(var(--tabbar) + 12px + env(safe-area-inset-bottom)); z-index: 40;
  background: var(--ink); color: #fff; border-radius: 12px; padding: 12px 14px; font-weight: 600; font-size: 14px;
  display: flex; align-items: center; gap: 10px;
  transform: translateY(20px); opacity: 0; pointer-events: none; transition: .18s;
}
.toast.show { transform: none; opacity: 1; pointer-events: auto; }
.toast span { flex: 1; min-width: 0; }
.toast button { border: 0; background: none; color: #FF9C93; font-weight: 800; padding: 4px; white-space: nowrap; }
