:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --text: #14161a;
  --muted: #7c828c;
  --line: #e6e8ec;
  --accent: #2f6fed;
  --accent-dark: #1f57c9;
  --ok: #16a34a;
  --danger: #dc2626;
  --radius: 14px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { max-width: 100%; overflow-x: hidden; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  padding-bottom: env(safe-area-inset-bottom);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px calc(10px);
  padding-top: calc(10px + env(safe-area-inset-top));
  background: rgba(255, 255, 255, .96);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}

.search { flex: 1; }

.search input {
  width: 100%;
  height: 40px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--bg);
  font-size: 15px;
  outline: none;
}

.search input:focus { border-color: var(--accent); background: #fff; }

.icon-btn {
  position: relative;
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 20px;
  background: var(--bg);
  font-size: 19px;
  line-height: 1;
  cursor: pointer;
}

#btn-back { font-size: 26px; font-weight: 600; padding-bottom: 4px; }

.badge {
  position: absolute;
  top: -2px;
  right: -2px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
}

main { padding: 12px 12px 96px; }

h1 { margin: 4px 0 14px; font-size: 21px; }
h2 { margin: 18px 0 10px; font-size: 16px; }

.muted { color: var(--muted); font-size: 13px; }

.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }

.tile {
  display: flex;
  align-items: center;
  min-height: 62px;
  padding: 12px 14px;
  border: 0;
  border-radius: var(--radius);
  background: var(--card);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  text-align: left;
  overflow-wrap: anywhere;
  box-shadow: 0 1px 2px rgba(20, 22, 26, .05);
  cursor: pointer;
}

.tile:active { transform: scale(.985); }

.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }

.card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: 0 1px 2px rgba(20, 22, 26, .05);
}

.card .thumb {
  position: relative;
  aspect-ratio: 1 / 1;
  background: #fff center/contain no-repeat;
  cursor: pointer;
}

.card .thumb.empty::after {
  content: "нет фото";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 12px;
}

.card .body { display: flex; flex: 1; flex-direction: column; gap: 6px; padding: 10px; }

.card .name {
  font-size: 13px;
  line-height: 1.3;
  height: 51px;
  overflow: hidden;
  cursor: pointer;
}

.card .price { font-size: 16px; font-weight: 700; }

.card .btn { margin-top: auto; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  min-height: 40px;
  padding: 10px 14px;
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.btn:active { background: var(--accent-dark); }
.btn[disabled] { background: #c3cbd8; cursor: default; }
.btn.ghost { background: #fff; color: var(--text); border: 1px solid var(--line); }
.btn.small { min-height: 34px; font-size: 13px; }

.stepper {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  border-radius: 10px;
  background: var(--bg);
  padding: 3px;
}

.stepper button {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 8px;
  background: #fff;
  font-size: 18px;
  cursor: pointer;
}

.stepper span { font-weight: 700; font-size: 14px; }

.product-photo {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: var(--radius);
  background: #fff center/contain no-repeat;
}

.panel {
  margin-top: 12px;
  padding: 14px;
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: 0 1px 2px rgba(20, 22, 26, .05);
}

.price-big { font-size: 26px; font-weight: 800; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }

.chip {
  padding: 5px 10px;
  border-radius: 20px;
  background: var(--bg);
  font-size: 12px;
  color: var(--muted);
}

.chip.ok { background: #e7f7ee; color: var(--ok); }

.spec { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.spec:last-child { border-bottom: 0; }
.spec .k { color: var(--muted); }
.spec .v { text-align: right; font-weight: 600; }

.desc { white-space: pre-wrap; font-size: 14px; line-height: 1.45; }

.cart-row { display: flex; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.cart-row:last-of-type { border-bottom: 0; }
.cart-row .thumb { flex: 0 0 64px; height: 64px; border-radius: 10px; background: #fff center/contain no-repeat; }
.cart-row .info { flex: 1; display: flex; flex-direction: column; gap: 6px; }
.cart-row .nm { font-size: 13px; line-height: 1.3; }
.cart-row .controls { display: flex; align-items: center; justify-content: space-between; gap: 10px; }

.totals { display: flex; justify-content: space-between; padding: 6px 0; font-size: 14px; }
.totals.total { font-size: 17px; font-weight: 800; }

.bottombar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 25;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, .97);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(8px);
}

label.field { display: block; margin-top: 12px; font-size: 13px; color: var(--muted); }

label.field input,
label.field textarea,
label.field select {
  width: 100%;
  margin-top: 5px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  font-size: 15px;
  font-family: inherit;
  outline: none;
}

label.field input:focus, label.field textarea:focus { border-color: var(--accent); }

.options { display: grid; gap: 8px; margin-top: 8px; }

.option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  font-size: 14px;
  cursor: pointer;
}

.option.active { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(47, 111, 237, .12); }
.option small { display: block; color: var(--muted); font-size: 12px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 84px;
  z-index: 40;
  transform: translateX(-50%);
  max-width: 90%;
  padding: 10px 16px;
  border-radius: 20px;
  background: rgba(20, 22, 26, .92);
  color: #fff;
  font-size: 13px;
}

.empty-state { padding: 48px 16px; text-align: center; color: var(--muted); }

.skeleton {
  border-radius: var(--radius);
  background: linear-gradient(90deg, #eceef2 25%, #f6f7f9 50%, #eceef2 75%);
  background-size: 200% 100%;
  animation: sk 1.2s infinite;
  height: 190px;
}

@keyframes sk { from { background-position: 200% 0; } to { background-position: -200% 0; } }
