/* Светлая тема по умолчанию, тёмная — если так настроена система клиента. */
:root {
  --bg: #f4f5f8;
  --surface: #ffffff;
  --surface-2: #eef0f4;
  --ink: #12141a;
  --ink-2: #3c4150;
  --muted: #767d8f;
  --line: #e0e3ea;
  --line-2: #ccd1dc;
  --accent: #5b4bd6;
  --accent-ink: #ffffff;
  --accent-soft: #ece9fc;
  --ok: #0f7a52;
  --ok-soft: #e2f4ec;
  --danger: #c0392b;
  --danger-soft: #fceceb;
  --shadow: 0 1px 2px rgba(18, 20, 26, .05), 0 8px 24px -12px rgba(18, 20, 26, .18);
  --shadow-lift: 0 2px 4px rgba(18, 20, 26, .06), 0 16px 32px -16px rgba(18, 20, 26, .28);
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --r: 14px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c0e13;
    --surface: #151923;
    --surface-2: #1d2230;
    --ink: #eef0f6;
    --ink-2: #c3c9d8;
    --muted: #8891a5;
    --line: #262c3a;
    --line-2: #343c4e;
    --accent: #7c6cf5;
    --accent-ink: #0c0e13;
    --accent-soft: #221f3d;
    --ok: #35c48d;
    --ok-soft: #12291f;
    --danger: #f0705f;
    --danger-soft: #2b1715;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px -12px rgba(0, 0, 0, .6);
    --shadow-lift: 0 2px 4px rgba(0, 0, 0, .5), 0 16px 32px -16px rgba(0, 0, 0, .8);
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }

/* Цены и номера — моноширинным с табличными цифрами, чтобы не прыгали. */
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; letter-spacing: -.01em; }

/* ---------- каркас ---------- */

header {
  position: sticky; top: 0; z-index: 20;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}

.wrap { max-width: 1100px; margin: 0 auto; padding: 0 20px; }

header .wrap { display: flex; align-items: center; gap: 10px; height: 60px; }

.logo {
  font-weight: 800; font-size: 17px; letter-spacing: -.04em;
  text-decoration: none; margin-right: auto;
  display: inline-flex; align-items: center; gap: 9px;
}
.logo img {
  width: 30px; height: 30px; border-radius: 9px;
  object-fit: cover; display: block;
  border: 1px solid var(--line);
}
.logo span { letter-spacing: .12em; font-weight: 700; }

main { max-width: 1100px; margin: 0 auto; padding: 28px 20px 72px; }

footer { max-width: 1100px; margin: 0 auto; padding: 0 20px 48px; color: var(--muted); font-size: 13px; }

/* ---------- кнопки ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  border: 0; border-radius: 10px; cursor: pointer;
  background: var(--accent); color: var(--accent-ink);
  padding: 10px 16px; min-height: 40px;
  font: inherit; font-size: 14px; font-weight: 600; letter-spacing: -.01em;
  text-decoration: none; white-space: nowrap;
  transition: transform .12s ease, filter .12s ease;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: default; transform: none; filter: none; }
.btn.wide { display: flex; width: 100%; min-height: 50px; font-size: 15px; }

.btn.ghost { background: var(--surface); color: var(--ink); border: 1px solid var(--line-2); }
.btn.ghost:hover { background: var(--surface-2); filter: none; }

.btn.link { background: none; color: var(--muted); padding: 6px 8px; min-height: 32px; font-weight: 500; }
.btn.link:hover { color: var(--danger); filter: none; }

.chip {
  display: inline-flex; align-items: center; gap: 7px;
  border: 1px solid var(--line-2); border-radius: 999px;
  background: var(--surface); color: var(--ink-2);
  padding: 8px 14px; min-height: 38px;
  font-size: 13px; font-weight: 600; text-decoration: none; cursor: pointer;
  white-space: nowrap;
}
.chip:hover { border-color: var(--accent); color: var(--ink); }
.chip.on { background: var(--ink); border-color: var(--ink); color: var(--bg); }

.tag {
  display: inline-flex; align-items: center;
  font-family: var(--mono); font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .06em;
  border-radius: 6px; padding: 4px 8px;
  background: var(--surface-2); color: var(--muted);
}
.tag.paid { background: var(--ok-soft); color: var(--ok); }
.tag.fail { background: var(--danger-soft); color: var(--danger); }

#cart-count.tag.paid { background: var(--accent); color: var(--accent-ink); }

/* ---------- поля ---------- */

input, textarea, select {
  width: 100%; border: 1px solid var(--line-2); border-radius: 10px;
  background: var(--surface); color: var(--ink);
  padding: 12px 14px; font: inherit; font-size: 15px;
  transition: border-color .12s ease;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); outline: none; }
input::placeholder, textarea::placeholder { color: var(--muted); }
textarea { resize: vertical; min-height: 84px; }

label.field { display: block; margin-bottom: 18px; }
label.field > span { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 7px; }
label.field b { font-size: 14px; font-weight: 600; }
label.field em { font-size: 12px; color: var(--muted); font-style: normal; }

label.check { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; font-size: 15px; cursor: pointer; }
label.check input { width: 18px; height: 18px; accent-color: var(--accent); }

/* ---------- блоки ---------- */

.card { border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); box-shadow: var(--shadow); }
.card + .card { margin-top: 14px; }
.pad { padding: 22px; }
.rows > * + * { border-top: 1px solid var(--line); }

.muted { color: var(--muted); }
.err { color: var(--danger); font-size: 14px; margin: 0 0 4px; }
.empty { text-align: center; color: var(--muted); padding: 72px 20px; font-size: 15px; }
.narrow { max-width: 560px; margin: 0 auto; }

h1 { font-size: 22px; font-weight: 700; letter-spacing: -.03em; margin: 0 0 20px; }

/* ---------- витрина ---------- */

.cats { display: flex; gap: 8px; margin-bottom: 24px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.cats::-webkit-scrollbar { display: none; }

.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
@media (min-width: 700px) { .grid { grid-template-columns: repeat(3, 1fr); gap: 18px; } }
@media (min-width: 980px) { .grid { grid-template-columns: repeat(4, 1fr); } }

.item {
  display: flex; flex-direction: column; overflow: hidden;
  border: 1px solid var(--line); border-radius: var(--r);
  background: var(--surface); box-shadow: var(--shadow);
  transition: transform .14s ease, box-shadow .14s ease, border-color .14s ease;
}
.item:hover { transform: translateY(-3px); box-shadow: var(--shadow-lift); border-color: var(--line-2); }

.item .body { display: flex; flex-direction: column; gap: 6px; padding: 14px; flex: 1; }
.item .cat { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--accent); text-decoration: none; }
.item .title { font-size: 15px; font-weight: 600; line-height: 1.3; letter-spacing: -.01em; text-decoration: none; }
.item .title:hover { color: var(--accent); }
.item .foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: auto; padding-top: 12px; }
.item .foot .num { font-size: 17px; font-weight: 700; }
.item .foot .btn { padding: 8px 13px; min-height: 36px; font-size: 13px; }

/* Обложка. Если картинки нет, рисуем цветной блок с инициалами —
   цвет считается из названия, поэтому у каждого товара он свой. */
.thumb { display: block; aspect-ratio: 5 / 4; overflow: hidden; background: var(--surface-2); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ph {
  display: flex; align-items: center; justify-content: center; height: 100%;
  font-size: 34px; font-weight: 800; letter-spacing: -.04em; color: #fff;
  text-shadow: 0 1px 12px rgba(0, 0, 0, .25);
}

/* ---------- страница товара ---------- */

.detail { display: grid; gap: 24px; }
@media (min-width: 800px) { .detail { grid-template-columns: 1.1fr 1fr; gap: 40px; align-items: start; } }
.detail h1 { font-size: 27px; line-height: 1.15; margin: 10px 0 14px; }
.detail .price { font-size: 30px; font-weight: 700; margin: 0 0 14px; }
.detail .desc { color: var(--ink-2); font-size: 15px; white-space: pre-line; margin: 16px 0 0; }
.detail .cover { border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; box-shadow: var(--shadow); }

/* ---------- корзина ---------- */

.line { display: flex; align-items: center; gap: 12px; padding: 14px; }
.line .mini { width: 56px; height: 56px; flex: 0 0 auto; border-radius: 10px; overflow: hidden; background: var(--surface-2); }
.line .mini img { width: 100%; height: 100%; object-fit: cover; display: block; }
.line .mini .ph { font-size: 18px; }
.line .grow { flex: 1; min-width: 0; }
.line .grow a { display: block; font-size: 15px; font-weight: 600; text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.line .grow a:hover { color: var(--accent); }
.line .grow span { font-size: 13px; }
.line .sum { width: 84px; text-align: right; font-weight: 700; }

.qty { display: flex; align-items: center; border: 1px solid var(--line-2); border-radius: 10px; overflow: hidden; }
.qty button { border: 0; background: var(--surface); color: var(--ink); padding: 0; width: 34px; height: 36px; font: inherit; font-size: 17px; cursor: pointer; }
.qty button:hover { background: var(--surface-2); }
.qty span { width: 32px; text-align: center; font-size: 14px; font-weight: 600; }

.total { display: flex; justify-content: space-between; align-items: baseline; margin: 22px 0 16px; }
.total .sum { font-size: 26px; font-weight: 700; }

@media (max-width: 560px) {
  .line { flex-wrap: wrap; row-gap: 10px; }
  .line .grow { flex: 1 1 55%; }
  .line .sum { order: 3; width: auto; margin-left: auto; }
  .line .qty { order: 4; }
}

/* ---------- выдача данных ---------- */

.handover { margin-top: 22px; border: 1px solid var(--ok); border-radius: 12px; background: var(--ok-soft); padding: 16px; }
.handover-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; font-size: 15px; }
.handover pre {
  margin: 0; padding: 14px; border-radius: 9px;
  background: var(--surface); color: var(--ink);
  font-family: var(--mono); font-size: 14px; line-height: 1.6;
  white-space: pre-wrap; word-break: break-word;
}

/* ---------- админка ---------- */

.adminbar { display: flex; gap: 18px; align-items: center; border-bottom: 1px solid var(--line); padding-bottom: 14px; margin-bottom: 24px; font-size: 15px; }
.adminbar a { font-weight: 600; text-decoration: none; }
.adminbar a:hover { color: var(--accent); }
.adminbar .right { margin-left: auto; }

.order-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; font-size: 15px; }
.order-head b { font-size: 16px; }
.order-head .when { margin-left: auto; font-size: 12px; color: var(--muted); }
.order-items { margin: 10px 0 0; padding: 0; list-style: none; color: var(--ink-2); font-size: 14px; }
.order-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.order-actions select { width: auto; min-width: 150px; }
.delivery { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
  .item:hover { transform: none; }
}
