:root {
  --bg: #08060f;
  --bg-2: #0e0a1c;
  --surface: #130d24;
  --surface-2: #1b1436;
  --line: #2c2050;
  --text: #f1ecff;
  --muted: #a99fc7;
  --muted-2: #706691;

  --neon: #b026ff;      /* фиолетовый неон */
  --neon-2: #e24bff;    /* magenta для градиента */
  --neon-soft: #cf94ff; /* читаемый светлый для текста/цен */
  --danger: #ff4d6d;
  --ok: #37e0a0;

  --grad: linear-gradient(120deg, var(--neon), var(--neon-2));
  --glow: 0 0 18px rgba(176, 38, 255, .5);
  --glow-strong: 0 0 26px rgba(176, 38, 255, .7), 0 0 64px rgba(176, 38, 255, .3);
  --radius: 16px;
  --radius-sm: 12px;
  --shadow: 0 10px 34px rgba(0, 0, 0, .6);
  --tab-h: 68px;
  --top-h: 56px;
}

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

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  overscroll-behavior-y: none;
}

body {
  background:
    radial-gradient(120% 80% at 100% 0%, rgba(176, 38, 255, .14), transparent 55%),
    radial-gradient(120% 80% at 0% 100%, rgba(226, 75, 255, .08), transparent 55%),
    var(--bg);
  background-attachment: fixed;
  padding-top: calc(var(--top-h) + env(safe-area-inset-top));
  padding-bottom: calc(var(--tab-h) + env(safe-area-inset-bottom));
}

h1, h2, h3, .display { font-family: "Space Grotesk", "Inter", sans-serif; letter-spacing: -.01em; }
a { color: inherit; }
img { display: block; max-width: 100%; }
button { font-family: inherit; cursor: pointer; }

/* ---------------- Topbar ---------------- */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 40;
  height: calc(var(--top-h) + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) 16px 0;
  display: flex; align-items: center; justify-content: space-between;
  background: rgba(8, 6, 15, .82);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 0 rgba(176, 38, 255, .18);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 26px; height: 26px; border-radius: 8px;
  background: var(--grad);
  box-shadow: var(--glow);
  position: relative;
}
.brand-mark::after {
  content: ""; position: absolute; inset: 6px 7px auto 7px; height: 3px; border-radius: 3px;
  background: rgba(255, 255, 255, .9);
}
.brand-name { font-family: "Space Grotesk"; font-weight: 700; font-size: 19px; }
.icon-btn {
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  width: 38px; height: 38px; border-radius: 10px; font-size: 17px;
  display: grid; place-items: center; transition: border-color .12s ease, box-shadow .12s ease;
}
.icon-btn:active { border-color: var(--neon); box-shadow: var(--glow); }

/* ---------------- App container ---------------- */
.app { max-width: 640px; margin: 0 auto; padding: 16px; }
.section-title {
  display: flex; align-items: baseline; justify-content: space-between;
  margin: 22px 4px 12px;
}
.section-title h2 { font-size: 17px; margin: 0; }
.section-title .muted { color: var(--neon-soft); font-size: 13px; }

/* ---------------- Category grid ---------------- */
.cat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.cat-card {
  position: relative; border: 1px solid var(--line); border-radius: var(--radius);
  background: linear-gradient(160deg, var(--surface), var(--bg-2));
  padding: 18px 16px; min-height: 96px;
  display: flex; flex-direction: column; justify-content: space-between;
  overflow: hidden; text-align: left; color: var(--text);
  transition: transform .12s ease, border-color .12s ease, box-shadow .12s ease;
}
.cat-card:active { transform: scale(.98); border-color: var(--neon); box-shadow: var(--glow); }
.cat-card .emoji { font-size: 26px; filter: drop-shadow(0 0 10px rgba(176, 38, 255, .35)); }
.cat-card .name { font-family: "Space Grotesk"; font-weight: 600; font-size: 15px; }
.cat-card.is-collection { background: linear-gradient(150deg, rgba(176, 38, 255, .22), rgba(226, 75, 255, .1)), var(--surface); border-color: rgba(176, 38, 255, .4); }
.cat-card.is-collection::before {
  content: ""; position: absolute; right: -30px; top: -30px; width: 90px; height: 90px;
  border-radius: 50%; background: var(--grad); filter: blur(26px); opacity: .5;
}

/* ---------------- Product grid ---------------- */
.prod-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.prod-card {
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface);
  overflow: hidden; display: flex; flex-direction: column; text-align: left; color: var(--text);
  transition: transform .12s ease, border-color .12s ease, box-shadow .12s ease;
}
.prod-card:active { transform: scale(.98); border-color: var(--neon); box-shadow: var(--glow); }
.thumb { aspect-ratio: 1 / 1; width: 100%; object-fit: cover; background: var(--bg-2); }
.thumb-ph {
  aspect-ratio: 1 / 1; display: grid; place-items: center; font-size: 40px;
  background: radial-gradient(120% 120% at 30% 20%, rgba(176, 38, 255, .4), rgba(226, 75, 255, .12)), var(--bg-2);
}
.prod-body { padding: 10px 11px 12px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.prod-title { font-size: 13.5px; font-weight: 500; line-height: 1.3; min-height: 2.6em; }
.price-row { display: flex; align-items: baseline; gap: 8px; margin-top: auto; }
.price { font-family: "Space Grotesk"; font-weight: 700; font-size: 16px; color: var(--neon-soft); }
.price.sale { color: var(--neon-2); text-shadow: 0 0 14px rgba(226, 75, 255, .5); }
.price-old { font-size: 12.5px; color: var(--muted-2); text-decoration: line-through; }
.stock-out { font-size: 12px; color: var(--danger); font-weight: 500; }

.pill {
  position: absolute; top: 8px; left: 8px; z-index: 2;
  font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 999px;
  background: var(--grad); color: #fff; box-shadow: var(--glow);
}
.card-wrap { position: relative; }

/* ---------------- Product detail ---------------- */
.pd-media { position: relative; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); box-shadow: var(--glow); }
.pd-media .thumb, .pd-media .thumb-ph { aspect-ratio: 4 / 3; }
.pd-title { font-size: 21px; margin: 16px 0 8px; }
.pd-price-row { display: flex; align-items: baseline; gap: 12px; margin-bottom: 14px; }
.pd-price { font-family: "Space Grotesk"; font-weight: 700; font-size: 26px; color: var(--neon-soft); }
.pd-price.sale { color: var(--neon-2); text-shadow: 0 0 16px rgba(226, 75, 255, .55); }
.pd-old { font-size: 16px; color: var(--muted-2); text-decoration: line-through; }
.pd-desc { color: var(--muted); white-space: pre-wrap; margin-bottom: 20px; }
.pd-meta { color: var(--muted-2); font-size: 13px; margin-bottom: 18px; }

.buy-bar {
  position: sticky; bottom: 12px; display: flex; gap: 12px; align-items: center;
  padding: 12px; margin-top: 8px; border: 1px solid var(--line); border-radius: var(--radius);
  background: rgba(19, 13, 36, .9); backdrop-filter: blur(10px); box-shadow: var(--shadow);
}

/* ---------------- Quantity stepper ---------------- */
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.stepper button {
  width: 40px; height: 44px; background: var(--surface-2); color: var(--text);
  border: none; font-size: 20px; display: grid; place-items: center;
}
.stepper button:active:not(:disabled) { color: var(--neon-soft); }
.stepper button:disabled { opacity: .4; }
.stepper .qty { min-width: 40px; text-align: center; font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------------- Buttons ---------------- */
.btn {
  border: none; border-radius: 12px; padding: 0 18px; height: 48px;
  font-size: 15px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: transform .1s ease, opacity .1s ease, box-shadow .12s ease;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; }
.btn-primary { background: var(--grad); color: #0a0612; flex: 1; box-shadow: var(--glow); }
.btn-primary:active { box-shadow: var(--glow-strong); }
.btn-ghost { background: var(--surface-2); color: var(--text); border: 1px solid var(--line); }
.btn-ghost:active { border-color: var(--neon); }
.btn-danger { background: transparent; color: var(--danger); border: 1px solid var(--danger); }
.btn-block { width: 100%; }
.btn-sm { height: 38px; font-size: 13px; padding: 0 12px; }

/* ---------------- Cart ---------------- */
.cart-item {
  display: grid; grid-template-columns: 64px 1fr auto; gap: 12px; align-items: center;
  padding: 12px 0; border-bottom: 1px solid var(--line);
}
.cart-item .thumb, .cart-item .thumb-ph { width: 64px; height: 64px; border-radius: 12px; aspect-ratio: unset; font-size: 26px; }
.cart-item .ci-title { font-size: 14px; font-weight: 500; }
.cart-item .ci-price { color: var(--muted); font-size: 13px; margin-top: 2px; }
.cart-item .ci-controls { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.ci-remove { background: none; border: none; color: var(--muted-2); font-size: 13px; }

.summary { margin-top: 18px; padding: 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.summary .row { display: flex; justify-content: space-between; margin-bottom: 8px; color: var(--muted); }
.summary .row.total { color: var(--text); font-weight: 700; font-size: 18px; margin: 12px 0 16px; }
.summary .row.total .price { font-size: 20px; }

textarea, input, select {
  width: 100%; background: var(--surface-2); border: 1px solid var(--line); color: var(--text);
  border-radius: 12px; padding: 12px; font-family: inherit; font-size: 15px; outline: none;
  transition: border-color .12s ease, box-shadow .12s ease;
}
textarea:focus, input:focus, select:focus { border-color: var(--neon); box-shadow: 0 0 0 3px rgba(176, 38, 255, .18); }
textarea { resize: vertical; min-height: 70px; }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.field-row { display: flex; gap: 12px; }
.field-row .field { flex: 1; }
.check { display: flex; align-items: center; gap: 10px; }
.check input { width: auto; accent-color: var(--neon); }

/* ---------------- Empty / states ---------------- */
.empty { text-align: center; color: var(--muted); padding: 60px 20px; }
.empty .big { font-size: 46px; margin-bottom: 12px; filter: drop-shadow(0 0 16px rgba(176, 38, 255, .4)); }
.spinner {
  width: 26px; height: 26px; border: 3px solid var(--line); border-top-color: var(--neon);
  border-radius: 50%; margin: 60px auto; animation: spin .8s linear infinite;
  box-shadow: var(--glow);
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------- Tabbar ---------------- */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
  height: calc(var(--tab-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: flex; gap: 10px; padding-left: 16px; padding-right: 16px; padding-top: 8px;
  background: rgba(8, 6, 15, .9); backdrop-filter: blur(14px); border-top: 1px solid var(--line);
  box-shadow: 0 -1px 0 rgba(176, 38, 255, .18);
}
.tab {
  position: relative; flex: 1; background: var(--surface); border: 1px solid var(--line);
  border-radius: 14px; color: var(--text);
  display: flex; align-items: center; justify-content: center; gap: 8px; height: 52px; font-weight: 600;
  transition: transform .1s ease, border-color .12s ease, box-shadow .12s ease;
}
.tab:active { transform: scale(.98); border-color: var(--neon); box-shadow: var(--glow); }
.tab-ico { font-size: 18px; }
.badge {
  position: absolute; top: -7px; right: 14px; min-width: 20px; height: 20px; padding: 0 5px;
  border-radius: 999px; background: var(--grad); color: #fff; font-size: 12px; font-weight: 700;
  display: grid; place-items: center; box-shadow: var(--glow);
}

/* ---------------- Back link ---------------- */
.back { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); background: none; border: none; padding: 4px 0; margin-bottom: 6px; font-size: 14px; }
.back:active { color: var(--neon-soft); }

/* ---------------- Toast ---------------- */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tab-h) + 20px); transform: translateX(-50%);
  background: var(--surface-2); border: 1px solid var(--line); color: var(--text);
  padding: 12px 18px; border-radius: 12px; z-index: 80; box-shadow: var(--shadow), var(--glow);
  font-size: 14px; max-width: 90%; text-align: center;
}

/* ---------------- Admin ---------------- */
.tabs { display: flex; gap: 8px; margin-bottom: 16px; }
.tabs .seg { flex: 1; padding: 10px; border: 1px solid var(--line); background: var(--surface); border-radius: 12px; color: var(--muted); font-weight: 600; font-size: 14px; transition: border-color .12s ease, box-shadow .12s ease, color .12s ease; }
.tabs .seg.active { background: var(--surface-2); color: var(--text); border-color: var(--neon); box-shadow: var(--glow); }
.admin-row {
  display: flex; align-items: center; gap: 12px; padding: 12px; border: 1px solid var(--line);
  border-radius: 12px; background: var(--surface); margin-bottom: 10px;
}
.admin-row .thumb, .admin-row .thumb-ph { width: 48px; height: 48px; border-radius: 10px; aspect-ratio: unset; font-size: 22px; }
.admin-row .ar-main { flex: 1; min-width: 0; }
.admin-row .ar-title { font-size: 14px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.admin-row .ar-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.admin-row .ar-actions { display: flex; gap: 8px; }
.tag { font-size: 11px; padding: 2px 7px; border-radius: 6px; background: var(--surface-2); color: var(--muted); }
.tag.on { color: var(--ok); }
.tag.off { color: var(--danger); }
.status { font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 999px; }
.status.pending { background: rgba(255, 184, 77, .15); color: #ffb84d; }
.status.confirmed { background: rgba(55, 224, 160, .15); color: var(--ok); }
.status.rejected { background: rgba(255, 77, 109, .15); color: var(--danger); }

.card { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); padding: 16px; margin-bottom: 16px; }
.card h3 { margin: 0 0 14px; font-size: 16px; }
.upload-preview { width: 100%; max-height: 160px; object-fit: cover; border-radius: 10px; margin-bottom: 10px; border: 1px solid var(--line); }

/* ---------------- Hover (desktop / browser testing) ---------------- */
@media (hover: hover) {
  .cat-card:hover, .prod-card:hover { border-color: var(--neon); box-shadow: var(--glow); }
  .icon-btn:hover { border-color: var(--neon); }
  .btn-primary:hover { box-shadow: var(--glow-strong); }
  .btn-ghost:hover, .tab:hover { border-color: var(--neon); }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
