/* ============ MONO · чёрно-белый маркет ============ */
:root {
  --bg: #060606;
  --panel: #0e0e0e;
  --panel-2: #141414;
  --line: #232323;
  --line-2: #2f2f2f;
  --text: #f4f4f4;
  --muted: #8b8b8b;
  --dim: #555;
  --white: #ffffff;
  --radius: 16px;
  --tabbar-h: 62px;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "SF Pro Text", "Segoe UI", Roboto, system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  overscroll-behavior: none;
  /* лёгкий шум для фактуры */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='0.035'/%3E%3C/svg%3E");
}

::-webkit-scrollbar { display: none; }

/* ---------- шапка ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  padding: 14px 18px 12px;
  background: rgba(6,6,6,.82);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: baseline; gap: 10px;
}
.brand {
  font-size: 18px; font-weight: 800;
  letter-spacing: .2em; text-transform: uppercase;
  display: flex; align-items: center; gap: 8px;
  white-space: nowrap;
}
.brand-mark { font-size: 16px; letter-spacing: 0; }
.brand-sub { font-size: 11px; color: var(--muted); letter-spacing: .12em; text-transform: uppercase; }

/* ---------- контент ---------- */
.view {
  padding: 16px 16px calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + 24px);
  animation: viewIn .22s ease both;
  max-width: 640px; margin: 0 auto;
}
@keyframes viewIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.view-title {
  font-size: 13px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: .24em;
  margin: 4px 2px 14px;
  display: flex; justify-content: space-between; align-items: center;
}

/* ---------- иконки ---------- */
.icon { width: 22px; height: 22px; display: block; }
.icon-img { width: 26px; height: 26px; display: block; filter: grayscale(1) contrast(1.1); }

/* ---------- каталог ---------- */
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  display: flex; flex-direction: column; gap: 10px;
  transition: border-color .15s ease, transform .1s ease;
  position: relative;
}

.bulk-badge {
  position: absolute; top: 10px; right: 10px;
  background: var(--white); color: #000;
  font-size: 10px; font-weight: 800; letter-spacing: .04em;
  padding: 3px 8px; border-radius: 99px;
  white-space: nowrap;
}
.card:active { transform: scale(.985); border-color: var(--line-2); }

.card-icon {
  width: 52px; height: 52px;
  border: 1px solid var(--line-2);
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  color: var(--white);
}
.card-icon .icon { width: 26px; height: 26px; }

.card-name { font-weight: 650; font-size: 14px; letter-spacing: .01em; }
.card-desc { font-size: 12px; color: var(--muted); min-height: 32px; }

.card-foot { display: flex; align-items: center; justify-content: space-between; margin-top: auto; gap: 8px; }
.price { font-weight: 750; font-variant-numeric: tabular-nums; font-size: 14px; white-space: nowrap; }
.price small { color: var(--muted); font-weight: 500; font-size: 11px; }
.stock-note { font-size: 11px; color: var(--dim); letter-spacing: .04em; }

/* ---------- кнопки ---------- */
.btn {
  border: 1px solid var(--line-2);
  background: transparent; color: var(--text);
  border-radius: 12px;
  font: inherit; font-weight: 650; font-size: 14px;
  padding: 10px 14px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  cursor: pointer; user-select: none;
  transition: transform .1s ease, opacity .15s ease, background .15s ease;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .35; pointer-events: none; }
.btn .icon { width: 17px; height: 17px; }

.btn-primary { background: var(--white); color: #000; border-color: var(--white); }
.btn-block { width: 100%; padding: 15px; font-size: 15px; letter-spacing: .04em; }
.btn-icon { padding: 9px; border-radius: 10px; }
.btn-sm { padding: 7px 11px; font-size: 12.5px; border-radius: 10px; }
.btn-danger { color: #fff; border-color: var(--line-2); }

.btn-add {
  width: 36px; height: 36px; padding: 0;
  border-radius: 10px;
  background: var(--white); color: #000; border: none;
  display: flex; align-items: center; justify-content: center;
  flex: none;
}
.btn-add .icon { width: 18px; height: 18px; }
.btn-add.in-cart { background: transparent; color: var(--white); border: 1px solid var(--line-2); }

/* ---------- корзина ---------- */
.cart-list { display: flex; flex-direction: column; gap: 10px; }
.cart-row {
  display: flex; align-items: center; gap: 12px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 12px;
}
.cart-row .card-icon { width: 44px; height: 44px; flex: none; }
.cart-row .card-icon .icon { width: 22px; height: 22px; }
.cart-info { flex: 1; min-width: 0; }
.cart-name { font-weight: 650; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cart-price { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }

.qty { display: flex; align-items: center; gap: 2px; border: 1px solid var(--line-2); border-radius: 10px; padding: 2px; }
.qty button {
  width: 28px; height: 28px; border: none; background: transparent; color: var(--text);
  display: flex; align-items: center; justify-content: center; cursor: pointer; border-radius: 8px;
}
.qty button:active { background: var(--panel-2); }
.qty button .icon { width: 14px; height: 14px; }
.qty span { min-width: 22px; text-align: center; font-weight: 700; font-size: 13.5px; font-variant-numeric: tabular-nums; }

.total-box {
  margin-top: 16px; padding: 16px;
  border: 1px solid var(--line-2); border-radius: var(--radius);
  background: var(--panel);
}
.total-row { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 14px; }
.total-label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .18em; }
.total-value { font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; }
.pay-note { text-align: center; font-size: 11.5px; color: var(--dim); margin-top: 10px; letter-spacing: .03em; }

/* ---------- заказы ---------- */
.order-card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px; margin-bottom: 10px;
}
.order-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.order-id { font-weight: 750; letter-spacing: .04em; }
.order-date { font-size: 11.5px; color: var(--dim); }
.order-items { font-size: 12.5px; color: var(--muted); margin: 6px 0 10px; }
.order-items div { padding: 1.5px 0; }
.order-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  padding: 4px 9px; border-radius: 99px; border: 1px solid var(--line-2); color: var(--muted);
}
.badge .icon { width: 12px; height: 12px; }
.badge-paid { background: var(--white); color: #000; border-color: var(--white); }
.badge-pending { color: var(--text); }
.badge-expired, .badge-failed { color: var(--dim); border-style: dashed; }

/* ---------- админ ---------- */
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
.stat {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px;
}
.stat-value { font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; }
.stat-label { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .16em; margin-top: 3px; }

.seg {
  display: flex; gap: 6px; margin-bottom: 14px;
  border: 1px solid var(--line); border-radius: 12px; padding: 4px; background: var(--panel);
}
.seg button {
  flex: 1; border: none; background: transparent; color: var(--muted);
  font: inherit; font-size: 12.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  padding: 9px 4px; border-radius: 9px; cursor: pointer;
}
.seg button.on { background: var(--white); color: #000; }

.admin-row {
  display: flex; align-items: center; gap: 12px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 12px; margin-bottom: 8px;
}
.admin-row.inactive { opacity: .45; }
.admin-actions { display: flex; gap: 6px; }

/* ---------- модалка ---------- */
.modal-root:empty { display: none; }
.modal-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0,0,0,.72);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fadeIn .18s ease;
}
@keyframes fadeIn { from { opacity: 0; } }
.sheet {
  width: 100%; max-width: 640px; max-height: 88vh; overflow-y: auto;
  background: var(--bg);
  border: 1px solid var(--line-2); border-bottom: none;
  border-radius: 22px 22px 0 0;
  padding: 18px 18px calc(24px + env(safe-area-inset-bottom, 0px));
  animation: sheetUp .24s cubic-bezier(.2,.9,.3,1) both;
}
@keyframes sheetUp { from { transform: translateY(40px); opacity: .5; } }
.sheet-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.sheet-title { font-size: 14px; font-weight: 800; text-transform: uppercase; letter-spacing: .2em; }

.field { margin-bottom: 13px; }
.field label { display: block; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .16em; margin-bottom: 6px; }
.field input, .field textarea {
  width: 100%; background: var(--panel); border: 1px solid var(--line-2);
  border-radius: 12px; color: var(--text); font: inherit; padding: 12px 13px;
  outline: none;
}
.field input:focus, .field textarea:focus { border-color: #4a4a4a; }
.field textarea { resize: none; min-height: 68px; }
.field-row { display: flex; gap: 10px; }
.field-row .field { flex: 1; }

.icon-pick { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; }
.icon-pick button {
  aspect-ratio: 1; border: 1px solid var(--line-2); border-radius: 10px;
  background: transparent; color: var(--muted); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.icon-pick button .icon { width: 18px; height: 18px; }
.icon-pick button.on { background: var(--white); color: #000; border-color: var(--white); }

.check-row { display: flex; align-items: center; gap: 12px; padding: 4px 2px; cursor: pointer; user-select: none; }
.check-row > span:last-child { font-size: 13.5px; }

/* ЧБ-тумблер */
.switch {
  width: 46px; height: 26px; flex: none;
  border: 1px solid var(--line-2); border-radius: 99px;
  background: var(--panel);
  position: relative;
  transition: background .18s ease, border-color .18s ease;
}
.switch .knob {
  position: absolute; top: 3px; left: 3px;
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--dim);
  transition: transform .18s cubic-bezier(.2,.9,.3,1.2), background .18s ease;
}
.switch.on { background: var(--white); border-color: var(--white); }
.switch.on .knob { transform: translateX(20px); background: #000; }

/* ---------- таббар ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: rgba(6,6,6,.88);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
  display: flex; align-items: stretch; justify-content: space-around;
}
.tab {
  flex: 1; border: none; background: transparent; color: var(--dim);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font: inherit; font-size: 9.5px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  cursor: pointer; position: relative;
  transition: color .15s ease;
}
.tab.on { color: var(--white); }
.tab .icon { width: 21px; height: 21px; }
.tab-badge {
  position: absolute; top: 8px; left: calc(50% + 6px);
  min-width: 16px; height: 16px; padding: 0 4px;
  background: var(--white); color: #000;
  border-radius: 99px; font-size: 10px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
}

/* ---------- скелетоны / пустые состояния / тост ---------- */
.skeleton {
  border-radius: var(--radius);
  background: linear-gradient(100deg, var(--panel) 40%, var(--panel-2) 50%, var(--panel) 60%);
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite linear;
  height: 172px;
}
@keyframes shimmer { to { background-position: -200% 0; } }

.empty {
  text-align: center; padding: 64px 24px; color: var(--dim);
}
.empty .icon { width: 44px; height: 44px; margin: 0 auto 14px; opacity: .5; }
.empty-title { font-weight: 700; color: var(--muted); letter-spacing: .06em; margin-bottom: 4px; }
.empty-sub { font-size: 12.5px; }

.toast {
  position: fixed; top: 64px; left: 50%; transform: translateX(-50%) translateY(-12px); z-index: 200;
  background: var(--white); color: #000;
  font-size: 13px; font-weight: 700; letter-spacing: .02em;
  padding: 11px 18px; border-radius: 12px;
  opacity: 0; pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
  max-width: 86vw; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- экран-заглушка ---------- */
.gate {
  min-height: 70vh; display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center; gap: 12px; padding: 24px;
}
.gate .brand { font-size: 28px; }
.gate p { color: var(--muted); font-size: 13.5px; max-width: 280px; }
