:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --ink: #232838;
  --muted: #8a92a6;
  --line: #ecEFF6;
  --line-2: #e3e7f1;
  --accent: #6b7cf6;
  --accent-soft: #eef0ff;
  --btn: #272d47;
  --btn-hover: #333a5c;
  --opt: #2fa36b;
  --opt-soft: #e7f4ec;
  --danger: #e2564d;
  --tint-blue: #e6edfb;
  --tint-pink: #fce9f0;
  --tint-green: #e7f4ec;
  --r: 16px;
  --r-sm: 12px;
  --shadow: 0 1px 2px rgba(20, 30, 60, .05), 0 10px 30px rgba(20, 30, 60, .05);
  --shadow-sm: 0 1px 2px rgba(20, 30, 60, .06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  line-height: 1.45;
}

a { color: inherit; text-decoration: none; }
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 18px; }

/* ---------- Header ---------- */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 50;
}
.header-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 0;
}
.logo {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 800;
  font-size: 19px;
  letter-spacing: -.02em;
  white-space: nowrap;
}
.logo .mark {
  width: 30px; height: 30px; border-radius: 9px;
  background: linear-gradient(135deg, #7c8bf8, #6b7cf6);
  display: grid; place-items: center; color: #fff; font-size: 16px;
}
.search {
  flex: 1;
  min-width: 0;
  position: relative;
}
.search input {
  width: 100%;
  border: 1px solid var(--line-2);
  background: #fafbfe;
  border-radius: 999px;
  padding: 10px 16px 10px 40px;
  font-size: 14px;
  color: var(--ink);
  outline: none;
}
.search input:focus { border-color: var(--accent); background: #fff; }
.search svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); }

.header-actions { display: flex; align-items: center; gap: 10px; }
.icon-btn {
  display: inline-flex; align-items: center; gap: 7px;
  border: 1px solid var(--line-2); background: #fff;
  border-radius: 999px; padding: 8px 14px; cursor: pointer;
  font-size: 13px; font-weight: 600; color: var(--ink);
}
.icon-btn:hover { border-color: var(--accent); }
.badge {
  min-width: 20px; height: 20px; padding: 0 6px;
  background: var(--accent); color: #fff; border-radius: 999px;
  font-size: 12px; font-weight: 700; display: inline-grid; place-items: center;
}
.admin-link { color: var(--muted); font-size: 13px; }

/* ---------- Category chips ---------- */
.chips { display: flex; gap: 9px; flex-wrap: wrap; padding: 18px 0 4px; }
.chip {
  border: 1px solid var(--line-2); background: #fff;
  border-radius: 999px; padding: 8px 16px; cursor: pointer;
  font-size: 13.5px; font-weight: 600; color: var(--ink); white-space: nowrap;
}
.chip:hover { border-color: var(--accent); }
.chip.on { background: var(--btn); color: #fff; border-color: var(--btn); }
.chip .cnt { opacity: .55; margin-left: 5px; font-weight: 600; }

/* ---------- Product grid ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 18px;
  padding: 22px 0 40px;
}
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform .12s ease, box-shadow .12s ease;
}
.card:hover { transform: translateY(-2px); box-shadow: 0 12px 34px rgba(20,30,60,.10); }
.photo {
  aspect-ratio: 3 / 4;
  display: grid; place-items: center;
  color: #aeb6cf; font-size: 13px; font-weight: 600;
}
.photo { background: var(--tint-blue); }
.photo .ico { font-size: 34px; opacity: .5; }
.photo.img { padding: 0; }
.photo.img img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* ---------- Свайп-галерея фото в карточке товара ---------- */
.photo.card-gallery { position: relative; }
.card-gallery-track {
  display: flex; width: 100%; height: 100%; overflow-x: auto;
  scroll-snap-type: x mandatory; -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.card-gallery-track::-webkit-scrollbar { display: none; }
.card-gallery-slide { flex: 0 0 100%; scroll-snap-align: start; }
.card-gallery-slide img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card-gallery-dots {
  position: absolute; left: 0; right: 0; bottom: 8px;
  display: flex; justify-content: center; gap: 5px; pointer-events: none;
}
.card-gallery-dots span {
  width: 5px; height: 5px; border-radius: 50%; background: rgba(255,255,255,.6);
  box-shadow: 0 0 0 1px rgba(20,25,45,.15);
  transition: background .15s, width .15s;
}
.card-gallery-dots span.on { background: #fff; width: 14px; border-radius: 3px; }
.card-body { padding: 14px 15px 16px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.card-title { font-weight: 700; font-size: 15px; letter-spacing: -.01em; }
.card-meta { color: var(--muted); font-size: 12.5px; }
.price-row { display: flex; align-items: baseline; gap: 10px; margin-top: 4px; }
.price { font-size: 20px; font-weight: 800; letter-spacing: -.02em; }
.price.opt { color: var(--opt); }
.price-opt-note { font-size: 12px; color: var(--muted); }
.price-opt-note b { color: var(--opt); }
.card .btn { margin-top: auto; }
.cart-ctl { margin-top: auto; }

@media (max-width: 560px) {
  .grid { grid-template-columns: repeat(2, 1fr); gap: 10px; padding: 16px 0 30px; }
  .card-body { padding: 9px 10px 11px; gap: 4px; }
  .card-title { font-size: 12.5px; }
  .card-meta { font-size: 10.5px; }
  .price-row { gap: 6px; margin-top: 2px; }
  .price { font-size: 15px; }
  .price-opt-note { font-size: 10px; }
  .card .btn, .cart-ctl .btn { padding: 8px 10px; font-size: 12px; }
  .qty.in-cart { height: 34px; }
  .qty.in-cart button { width: 36px; font-size: 16px; }
  .qty.in-cart span { font-size: 13px; }
}

/* ---------- Карточка опта в ленте: ввод количества по размерам ---------- */
.opt-sizes { display: flex; flex-direction: column; gap: 5px; margin: 4px 0; }
.opt-size-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 12.5px; color: var(--muted); font-weight: 600; }
.opt-size-row input {
  width: 54px; border: 1px solid var(--line-2); border-radius: 8px; padding: 6px 4px;
  text-align: center; font-family: inherit; font-size: 13px; outline: none;
}
.opt-size-row input:focus { border-color: var(--accent); }
.opt-card-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; }
.opt-card-total { font-size: 12.5px; font-weight: 700; color: var(--ink); }
.opt-in-cart { font-size: 12px; color: var(--opt); font-weight: 600; }
.qty.in-cart { width: 100%; justify-content: space-between; border-radius: var(--r-sm); height: 42px; }
.qty.in-cart button { width: 46px; height: 100%; font-size: 20px; }
.qty.in-cart span { font-size: 15px; font-weight: 800; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; cursor: pointer; font-weight: 700; font-size: 14px;
  background: var(--btn); color: #fff;
  padding: 11px 18px; border-radius: var(--r-sm); width: 100%;
  transition: background .12s ease;
}
.btn:hover { background: var(--btn-hover); }
.btn.ghost { background: #fff; color: var(--ink); border: 1px solid var(--line-2); }
.btn.ghost:hover { border-color: var(--accent); background: #fff; }
.btn.accent { background: var(--accent); }
.btn.accent:hover { background: #5a6bf0; }
.btn.wide { width: 100%; }
.btn.sm { padding: 8px 13px; font-size: 13px; width: auto; border-radius: 10px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  font-size: 13.5px;
  padding: 20px 0;
  text-align: center;
}
.site-footer a { color: var(--accent); font-weight: 600; }

/* ---------- Generic layout bits ---------- */
.page-title { font-size: 24px; font-weight: 800; letter-spacing: -.02em; margin: 26px 0 4px; }
.breadcrumb { color: var(--muted); font-size: 13px; margin-top: 22px; }
.breadcrumb a:hover { color: var(--accent); }
.muted { color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 60px 0; }

.qty {
  display: inline-flex; align-items: center;
  border: 1px solid var(--line-2); border-radius: 999px; overflow: hidden; background: #fff;
}
.qty button { border: 0; background: transparent; width: 34px; height: 34px; cursor: pointer; font-size: 17px; color: var(--ink); }
.qty button:hover { background: #f3f5fb; }
.qty span { min-width: 34px; text-align: center; font-weight: 700; font-size: 14px; }

.sizes { display: flex; gap: 7px; flex-wrap: wrap; }
.size {
  border: 1px solid var(--line-2); border-radius: 9px; padding: 6px 11px;
  font-size: 13px; font-weight: 600; cursor: pointer; background: #fff;
}
.size.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

.panel {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); box-shadow: var(--shadow); padding: 20px;
}
.notice {
  background: var(--opt-soft); color: #1f7a4d;
  border-radius: var(--r-sm); padding: 11px 15px; font-size: 13.5px; font-weight: 600;
}
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 999px;
  font-size: 14px; font-weight: 600; opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s; z-index: 200; box-shadow: var(--shadow);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 720px) {
  .search { display: none; }
  .logo { font-size: 17px; }
  .header-actions .label { display: none; }
}

/* ---------- Бургер-меню ---------- */
.burger {
  display: inline-flex; flex-direction: column; justify-content: center; gap: 4px;
  width: 40px; height: 40px; border: 1px solid var(--line-2); background: #fff;
  border-radius: 12px; cursor: pointer; padding: 0 10px; margin-left: 6px;
}
.burger span { height: 2px; background: var(--ink); border-radius: 2px; display: block; }
.burger:hover { border-color: var(--accent); }

.drawer-overlay {
  position: fixed; inset: 0; background: rgba(20,25,45,.4);
  opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 90;
}
.drawer-overlay.show { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 0; left: 0; bottom: 0; width: 300px; max-width: 84vw;
  background: var(--surface); border-right: 1px solid var(--line);
  transform: translateX(-102%); transition: transform .24s ease; z-index: 95;
  display: flex; flex-direction: column; box-shadow: 0 20px 50px rgba(20,30,60,.18);
}
.drawer.open { transform: translateX(0); }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 18px; border-bottom: 1px solid var(--line); }
.drawer-close { border: 0; background: none; font-size: 20px; cursor: pointer; color: var(--muted); }
.drawer-nav { padding: 12px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.drawer-link {
  display: flex; align-items: center; gap: 12px; padding: 13px 14px;
  border-radius: 12px; font-weight: 600; font-size: 15px; color: var(--ink);
}
.drawer-link .di { font-size: 18px; width: 22px; text-align: center; }
.drawer-link:hover { background: var(--bg); }
.drawer-link.on { background: var(--accent-soft); color: var(--accent); }
.drawer-foot { padding: 18px; border-top: 1px solid var(--line); }

/* ---------- Лента (feed) ---------- */
.feed { display: flex; flex-direction: column; gap: 14px; padding: 20px 0 40px; max-width: 640px; margin: 0 auto; }
.feed-card {
  display: grid; grid-template-columns: 120px 1fr; gap: 16px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  box-shadow: var(--shadow); overflow: hidden; padding: 14px;
}
.feed-card .photo { border-radius: var(--r-sm); aspect-ratio: 3/4; width: 120px; }
.feed-card .fc-body { display: flex; flex-direction: column; gap: 5px; }
.feed-card .fc-title { font-weight: 700; font-size: 16px; }
.feed-card .fc-meta { color: var(--muted); font-size: 13px; }
.feed-card .fc-foot { margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 8px; }
.feed-card .cart-ctl { margin: 0; width: 150px; }
.feed-tag { display: inline-block; font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 999px; margin: 14px 0 2px; }
.feed-tag.retail { background: var(--accent-soft); color: var(--accent); }
.feed-tag.opt { background: var(--opt-soft); color: var(--opt); }
.fc-sizes { display: flex; flex-wrap: wrap; gap: 5px; margin: 2px 0; }
.fc-size { display: inline-block; font-size: 11.5px; font-weight: 700; color: var(--muted); background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 2px 7px; }
@media (max-width: 560px) {
  .feed-card { grid-template-columns: 84px 1fr; }
  .feed-card .photo { width: 84px; }
  .feed-card .cart-ctl { width: 130px; }
  .feed-card .fc-foot { flex-direction: column; align-items: flex-start; }
}

/* ---------- Оптовая таблица заказа ---------- */
.wtable-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); margin: 18px 0; }
table.wtable { width: 100%; border-collapse: collapse; min-width: 640px; }
table.wtable th, table.wtable td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--line); font-size: 14px; }
table.wtable th { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; background: #fafbfe; position: sticky; top: 0; }
table.wtable td.num, table.wtable th.num { text-align: right; white-space: nowrap; }
table.wtable .w-name { font-weight: 700; }
table.wtable .w-sub { color: var(--muted); font-size: 12px; }
table.wtable input.qty-in {
  width: 74px; border: 1px solid var(--line-2); border-radius: 9px; padding: 8px 10px;
  font-size: 14px; text-align: center; font-family: inherit; outline: none;
}
table.wtable input.qty-in:focus { border-color: var(--accent); }
table.wtable tr.has-qty { background: var(--accent-soft); }
table.wtable tr.has-qty td { border-color: transparent; }
.size-toggle {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line-2);
  background: #fff; border-radius: 9px; padding: 7px 12px; font-size: 13px; font-weight: 600;
  cursor: pointer; font-family: inherit; color: var(--ink);
}
.size-toggle:hover { border-color: var(--accent); }
.size-toggle .car { font-size: 10px; color: var(--muted); }
tr.size-row td { background: #fafbfe; padding: 14px; }
.size-grid { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-start; }
.size-cell { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); font-weight: 600; }
.size-cell input {
  width: 54px; border: 1px solid var(--line-2); border-radius: 8px; padding: 6px 4px;
  text-align: center; font-family: inherit; font-size: 13px; outline: none;
}
.size-cell input:focus { border-color: var(--accent); }
.w-total-bar {
  position: sticky; bottom: 0; display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); box-shadow: var(--shadow); padding: 16px 20px; margin-bottom: 44px;
}
.w-total-bar .t-sum { font-size: 24px; font-weight: 800; letter-spacing: -.02em; }
.w-total-bar .btn { width: auto; padding: 12px 24px; }
.w-channels { display: flex; gap: 8px; flex-wrap: wrap; }
.w-channels .channel { border: 1px solid var(--line-2); background: #fff; border-radius: 999px; padding: 8px 15px; cursor: pointer; font-weight: 600; font-size: 13px; }
.w-channels .channel.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

/* ---------- Сообщения оптовикам (лента объявлений) ---------- */
.msg-feed { display: flex; flex-direction: column; gap: 12px; margin: 8px 0 32px; }
.msg { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow-sm); padding: 16px 18px; }
.msg .msg-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.msg .msg-badge { font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 999px; background: var(--opt-soft); color: var(--opt); }
.msg .msg-date { color: var(--muted); font-size: 12px; margin-left: auto; }
.msg .msg-title { font-weight: 700; font-size: 15px; }
.msg .msg-text { color: var(--muted); font-size: 13.5px; margin-top: 4px; }
/* ---- Отдельный сайт админки ---- */
.admin-header {
  background: var(--surface); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 50;
}
.admin-header .header-row { display: flex; align-items: center; justify-content: space-between; padding: 14px 0; }
.admin-header .badge-admin {
  background: var(--accent-soft); color: var(--accent);
  font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 999px;
}
.admin { display: grid; grid-template-columns: 210px 1fr; gap: 24px; margin: 24px 0 48px; align-items: start; }
.side { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); padding: 10px; position: sticky; top: 82px; }
.side a { display: flex; align-items: center; gap: 9px; padding: 10px 13px; border-radius: 10px; font-weight: 600; font-size: 14px; color: var(--ink); cursor: pointer; }
.side a.on { background: var(--accent-soft); color: var(--accent); }
.side a:hover:not(.on) { background: #f4f6fb; }
.side .logout { color: var(--muted); font-size: 13px; margin-top: 8px; border-top: 1px solid var(--line); padding-top: 12px; }
.content { min-height: 300px; }
.toolbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; gap: 12px; flex-wrap: wrap; }
.toolbar h2 { font-size: 20px; font-weight: 800; margin: 0; }
.row { display: grid; grid-template-columns: 40px 1fr auto auto auto; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); }
.row .thumb { width: 40px; height: 40px; border-radius: 9px; display: grid; place-items: center; font-size: 18px; overflow: hidden; }
.row .thumb img { width: 100%; height: 100%; object-fit: cover; }
.photo-grid { display: flex; flex-wrap: wrap; gap: 10px; }
.photo-grid-item { position: relative; width: 72px; height: 72px; border-radius: 10px; overflow: hidden; border: 1px solid var(--line-2); }
.photo-grid-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-grid-main {
  position: absolute; top: 3px; left: 3px; background: var(--accent); color: #fff;
  font-size: 9.5px; font-weight: 700; padding: 1px 5px; border-radius: 5px; line-height: 1.4;
}
.photo-grid-ctl {
  position: absolute; inset: auto 0 0 0; display: flex; justify-content: space-between;
  background: rgba(20,25,45,.55); opacity: 0; transition: opacity .12s;
}
.photo-grid-item:hover .photo-grid-ctl { opacity: 1; }
.photo-grid-ctl button {
  flex: 1; border: 0; background: none; color: #fff; font-size: 13px; padding: 4px 0; cursor: pointer; line-height: 1;
}
.photo-grid-ctl button:disabled { opacity: .3; cursor: default; }
.photo-grid-ctl button:hover:not(:disabled) { background: rgba(255,255,255,.15); }
.row .nm { font-weight: 700; font-size: 14.5px; }
.row .sub { color: var(--muted); font-size: 12.5px; }
.row .prices { font-size: 13.5px; text-align: right; }
.row .prices b { font-weight: 800; }
.row .prices .o { color: var(--opt); }
.link { color: var(--accent); cursor: pointer; font-weight: 600; font-size: 13px; background: none; border: 0; }
.link.danger { color: var(--danger); }
.toggle { width: 40px; height: 23px; border-radius: 999px; background: #d7dbe8; position: relative; cursor: pointer; border: 0; transition: background .15s; }
.toggle.on { background: var(--opt); }
.toggle::after { content: ""; position: absolute; top: 2px; left: 2px; width: 19px; height: 19px; border-radius: 50%; background: #fff; transition: left .15s; }
.toggle.on::after { left: 19px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.field input, .field select, .field textarea {
  border: 1px solid var(--line-2); border-radius: 10px; padding: 10px 13px; font-size: 14px; font-family: inherit; color: var(--ink); background: #fff; outline: none;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
.modal-bg { position: fixed; inset: 0; background: rgba(20,25,45,.4); display: none; align-items: center; justify-content: center; z-index: 100; padding: 18px; }
.modal-bg.show { display: flex; }
.modal { background: #fff; border-radius: var(--r); width: 100%; max-width: 520px; max-height: 90vh; overflow: auto; padding: 24px; box-shadow: var(--shadow); }
.modal h3 { margin: 0 0 16px; font-size: 18px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 8px; }
.modal-actions .btn { width: auto; }
.login { max-width: 380px; margin: 60px auto; }
.status-pill { font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 999px; }
.st-new { background: #eef0ff; color: var(--accent); }
.st-in_work { background: #fff2e0; color: #c07b1e; }
.st-done { background: var(--opt-soft); color: var(--opt); }
@media (max-width: 720px) { .admin { grid-template-columns: 1fr; } .side { position: static; display: flex; flex-wrap: wrap; } }
