/* Layout: dark header band with search and cart; content in a 1240px column; product grid auto-fills */
:root {
  --bg: #f3f4f6;
  --surface: #ffffff;
  --ink: #15171a;
  --muted: #5f6670;
  --line: #e1e4e8;
  --accent: #ffd02b;        /* кнопки дій */
  --accent-hover: #f5c400;
  --accent-ink: #15171a;
  --link: #1d4fd8;
  --head-bg: #15171a;
  --head-fg: #f3f4f6;
  --head-muted: #a3a9b2;
  --ok: #1f7a46;
  --warn: #a15c00;
  --bad: #c0352b;
  --info: #1d4fd8;
  --violet: #6b3fd1;
  --shadow: 0 1px 2px rgb(21 23 26 / .06), 0 10px 30px rgb(21 23 26 / .08);
  --f-display: "Unbounded", "Arial Black", system-ui, sans-serif;
  --f-body: "Golos Text", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --f-mono: "JetBrains Mono", ui-monospace, Consolas, monospace;
  --r: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111316; --surface: #1a1d21; --ink: #eceef1; --muted: #9aa1ab; --line: #2a2e34;
    --accent: #ffd23f; --accent-hover: #ffdc66; --accent-ink: #15171a; --link: #82a8ff;
    --head-bg: #0a0b0d; --head-fg: #eceef1; --head-muted: #8a919b;
    --ok: #5fcf8e; --warn: #f0a94a; --bad: #ff7b70; --info: #82a8ff; --violet: #b49bff;
    --shadow: 0 1px 2px rgb(0 0 0 / .4), 0 10px 30px rgb(0 0 0 / .3);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #111316; --surface: #1a1d21; --ink: #eceef1; --muted: #9aa1ab; --line: #2a2e34;
  --accent: #ffd23f; --accent-hover: #ffdc66; --accent-ink: #15171a; --link: #82a8ff;
  --head-bg: #0a0b0d; --head-fg: #eceef1; --head-muted: #8a919b;
  --ok: #5fcf8e; --warn: #f0a94a; --bad: #ff7b70; --info: #82a8ff; --violet: #b49bff;
  --shadow: 0 1px 2px rgb(0 0 0 / .4), 0 10px 30px rgb(0 0 0 / .3);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 var(--f-body); }
img { max-width: 100%; }
[hidden] { display: none !important; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; }
h1, h2, h3 { text-wrap: balance; }
h1 { font: 700 clamp(22px, 3.2vw, 30px)/1.15 var(--f-display); letter-spacing: -0.02em; margin: 0; }
.mono { font-family: var(--f-mono); font-size: .92em; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.nowrap { white-space: nowrap; }

.wrap {
  max-width: 1240px; margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.page { padding-block: 20px 56px; display: grid; gap: 24px; }
.page > * { min-width: 0; }

/* ---------- Шапка ---------- */
.top { background: var(--head-bg); color: var(--head-fg); position: sticky; top: 0; z-index: 20; }
.top-in { display: flex; align-items: center; gap: 12px 16px; padding-block: 12px; flex-wrap: wrap; }
.logo { font: 700 22px/1 var(--f-display); color: var(--head-fg); letter-spacing: -0.03em; }
.logo:hover { text-decoration: none; }
.logo small { font: 500 12px var(--f-body); color: var(--head-muted); letter-spacing: 0; margin-left: 4px; }
.menu-btn {
  display: inline-flex; align-items: center; gap: 10px; border: none; border-radius: var(--r);
  background: var(--accent); color: var(--accent-ink); font-weight: 600; padding: 10px 16px; cursor: pointer;
}
.menu-btn:hover { background: var(--accent-hover); }
.burger, .burger::before, .burger::after { display: block; width: 16px; height: 2px; background: currentColor; border-radius: 1px; position: relative; }
.burger::before, .burger::after { content: ""; position: absolute; left: 0; }
.burger::before { top: -5px; } .burger::after { top: 5px; }
.search { flex: 1 1 320px; display: flex; min-width: 0; }
.search input {
  flex: 1; min-width: 0; border: 1px solid transparent; border-radius: var(--r) 0 0 var(--r);
  background: #fff; color: #15171a; padding: 10px 14px;
}
.search input::placeholder { color: #6b717a; }
.search button { border: none; border-radius: 0 var(--r) var(--r) 0; background: #2b2f35; color: #f3f4f6; padding: 0 16px; cursor: pointer; }
.search button:hover { background: #3a3f46; }
.head-contact { display: grid; justify-items: end; line-height: 1.25; }
.head-phone { color: var(--head-fg); font: 500 15px var(--f-mono); white-space: nowrap; }
.head-msg { display: flex; gap: 10px; font-size: 12px; }
.head-msg .msg { color: var(--head-muted); }
.msg { white-space: nowrap; }
.msg + .msg { margin-left: 10px; }
.head-msg .msg + .msg { margin-left: 0; }
.msg::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 5px; vertical-align: 1px; }
.msg.viber::before { background: #7360f2; }
.msg.tg::before { background: #229ed9; }
.ask { display: grid; gap: 4px; padding: 12px 14px; border: 1px dashed var(--line); border-radius: var(--r); font-size: 14px; }
.cart-link { color: var(--head-fg); display: inline-flex; align-items: center; gap: 8px; font-weight: 500; padding: 8px 4px; }
.cart-count {
  min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px; display: inline-grid; place-items: center;
  background: var(--accent); color: var(--accent-ink); font: 600 12px/1 var(--f-mono);
}
.menu { background: var(--surface); color: var(--ink); border-bottom: 1px solid var(--line); box-shadow: var(--shadow); max-height: 70vh; overflow-y: auto; }
.menu-in { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 20px 24px; padding-block: 20px; }
.menu-col { display: grid; gap: 4px; align-content: start; font-size: 14px; }
.menu-col a { color: var(--ink); }
.menu-col .menu-root { font-weight: 600; margin-bottom: 2px; }
.menu-root span { font: 12px var(--f-mono); color: var(--muted); }
.menu-col .more { color: var(--link); }

/* ---------- Загальне ---------- */
.crumbs { font-size: 13px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 6px; }
.crumbs a { color: var(--muted); }
.sec { font: 600 18px/1.2 var(--f-display); letter-spacing: -0.01em; margin: 0 0 14px; }
.intro { display: grid; gap: 8px; padding-block: 8px 4px; }
.intro h1 { font-size: clamp(24px, 4vw, 38px); max-width: 22ch; }
.intro p { margin: 0; color: var(--muted); max-width: 65ch; }
.empty { padding: 40px 16px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: var(--r); margin: 0; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); border-radius: var(--r); padding: 11px 18px; font-weight: 600; cursor: pointer;
}
.btn:hover { text-decoration: none; border-color: var(--ink); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.ghost { background: transparent; }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .6; cursor: default; }

/* Категорії на головній */
.cats { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.cat {
  display: grid; grid-template-columns: 92px minmax(0, 1fr); gap: 14px; align-items: center; padding: 12px; border-radius: var(--r);
  background: var(--surface); border: 1px solid var(--line); color: var(--ink);
}
.cat:hover { text-decoration: none; border-color: var(--ink); }
.cat-img, .subcat-img { display: grid; place-items: center; aspect-ratio: 1; background: #fff; border-radius: 8px; padding: 6px; overflow: hidden; }
.cat-img img, .subcat-img img { width: 100%; height: 100%; object-fit: contain; }
.cat-text { display: grid; gap: 4px; min-width: 0; }
.noimg { color: #9aa1ab; font-size: 13px; text-align: center; }
.cat-img .noimg, .subcat-img .noimg { font: 700 24px var(--f-display); }
.cat-name { font-weight: 600; font-size: 16px; line-height: 1.3; }
.cat-sub { font-size: 13px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.cat-n { font: 12px var(--f-mono); color: var(--muted); }

/* Сітка товарів */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; }
.card {
  display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); overflow: hidden; transition: box-shadow .15s, border-color .15s;
}
.card:hover { box-shadow: var(--shadow); border-color: transparent; }
.card-img { display: grid; place-items: center; aspect-ratio: 1; max-width: 100%; background: #fff; padding: 14px; }
.card-img img { width: 100%; height: 100%; object-fit: contain; }
.card-body { display: flex; flex-direction: column; gap: 8px; padding: 12px 14px 14px; flex: 1; border-top: 1px solid var(--line); }
.card-name {
  color: var(--ink); font-size: 14px; line-height: 1.35; min-height: calc(1.35em * 3);
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.card-foot { margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.price { font: 500 18px/1 var(--f-mono); font-variant-numeric: tabular-nums; white-space: nowrap; letter-spacing: -0.02em; }
.add {
  border: none; border-radius: 8px; background: var(--accent); color: var(--accent-ink);
  font-weight: 600; font-size: 13px; padding: 8px 12px; cursor: pointer;
}
.add:hover { background: var(--accent-hover); }
.add.in { background: transparent; color: var(--ok); box-shadow: inset 0 0 0 1px var(--ok); }
.stock { font-size: 12px; display: inline-flex; align-items: center; gap: 6px; font-weight: 500; }
.stock::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.stock.ok { color: var(--ok); } .stock.low { color: var(--warn); } .stock.off { color: var(--muted); }

/* Список */
.list-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 12px 24px; }
.count { font: 400 14px var(--f-body); color: var(--muted); letter-spacing: 0; margin-left: 6px; white-space: nowrap; }
.sort { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); }
select, .field input, .field textarea, .admin-filter input {
  border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 9px 12px;
}
.subcats { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px; }
.subcat {
  display: grid; grid-template-columns: 56px minmax(0, 1fr); grid-template-rows: auto auto; column-gap: 12px; align-items: center;
  padding: 8px 12px 8px 8px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); color: var(--ink);
}
.subcat:hover { text-decoration: none; border-color: var(--ink); }
.subcat-img { grid-row: 1 / 3; }
.subcat-name { font-size: 14px; font-weight: 500; line-height: 1.3; align-self: end; }
.subcat-n { font: 12px var(--f-mono); color: var(--muted); align-self: start; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 999px; padding: 6px 12px; font-size: 14px; }
.chip:hover { text-decoration: none; border-color: var(--ink); }
.chip span { font: 12px var(--f-mono); color: var(--muted); margin-left: 2px; }
.pager { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; font-variant-numeric: tabular-nums; }
.pager a, .pager .cur, .pager .gap { min-width: 40px; height: 40px; display: grid; place-items: center; border-radius: 8px; padding: 0 10px; }
.pager a { background: var(--surface); border: 1px solid var(--line); color: var(--ink); }
.pager a:hover { text-decoration: none; border-color: var(--ink); }
.pager .cur { background: var(--ink); color: var(--bg); font-weight: 600; }

/* Сторінка товару */
.product { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 32px; align-items: start; }
.gallery { display: grid; gap: 10px; min-width: 0; }
.main-img { background: #fff; border: 1px solid var(--line); border-radius: var(--r); aspect-ratio: 1; max-width: 100%; display: grid; place-items: center; padding: 24px; }
.main-img img { width: 100%; height: 100%; object-fit: contain; }
.thumbs { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.thumbs button { flex: none; width: 68px; height: 68px; padding: 6px; background: #fff; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; }
.thumbs button[aria-current="true"] { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.thumbs img { width: 100%; height: 100%; object-fit: contain; }
.buy { display: grid; gap: 14px; position: sticky; top: 90px; min-width: 0; }
.buy h1 { font: 600 clamp(20px, 2.4vw, 26px)/1.25 var(--f-body); letter-spacing: -0.01em; }
.ids { display: grid; grid-template-columns: auto 1fr; gap: 4px 16px; margin: 0; font-size: 14px; }
.ids dt { color: var(--muted); } .ids dd { margin: 0; }
.buy-price { font: 500 34px/1 var(--f-mono); letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.buy-row { display: flex; gap: 10px; flex-wrap: wrap; }
.buy-row .btn { flex: 1 1 180px; }
.qty { display: inline-flex; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); overflow: hidden; }
.qty button { width: 40px; border: none; background: transparent; cursor: pointer; font-size: 18px; }
.qty button:hover { background: var(--bg); }
.qty input { width: 48px; border: none; background: transparent; text-align: center; font-family: var(--f-mono); -moz-appearance: textfield; }
.qty input::-webkit-inner-spin-button, .qty input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.desc { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 20px 24px; }
.desc-body { max-width: 75ch; overflow-wrap: anywhere; }
.desc-body p { margin: 0 0 .8em; }
.desc-body h3, .desc-body h4 { font-size: 16px; margin: 1.2em 0 .5em; }
.desc-body ul, .desc-body ol { padding-left: 1.3em; margin: 0 0 .8em; }
.desc-body table { border-collapse: collapse; display: block; overflow-x: auto; max-width: 100%; }
.desc-body td, .desc-body th { border: 1px solid var(--line); padding: 6px 10px; text-align: left; vertical-align: top; }

/* Кошик */
.cart { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 24px; align-items: start; }
.cart-items { display: grid; gap: 10px; }
.line {
  display: grid; grid-template-columns: 72px minmax(0, 1fr) auto auto 32px; gap: 14px; align-items: center;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 10px 14px;
}
.line img { width: 72px; height: 72px; object-fit: contain; background: #fff; border-radius: 6px; }
.line-name { color: var(--ink); font-size: 14px; line-height: 1.35; }
.line-name small { display: block; color: var(--muted); font: 12px var(--f-mono); margin-top: 2px; }
.line .price { font-size: 16px; text-align: right; min-width: 100px; }
.line.gone { opacity: .55; }
.rm { width: 32px; height: 32px; border: none; background: transparent; color: var(--muted); border-radius: 50%; cursor: pointer; font-size: 18px; }
.rm:hover { background: var(--bg); color: var(--bad); }
.checkout { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 20px; display: grid; gap: 12px; position: sticky; top: 90px; }
.checkout h2, .panel h2 { font: 600 16px/1.2 var(--f-display); margin: 0; }
.field { display: grid; gap: 4px; }
.field label { font-size: 13px; color: var(--muted); }
.field input, .field textarea, .field select { width: 100%; }
.field textarea { resize: vertical; }
.field.invalid input { border-color: var(--bad); }
.total-row { display: flex; justify-content: space-between; align-items: baseline; border-top: 1px solid var(--line); padding-top: 12px; }
.total-row b { font: 500 24px var(--f-mono); }
.form-error { color: var(--bad); margin: 0; font-size: 14px; }
.done { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 40px 24px; text-align: center; display: grid; gap: 12px; justify-items: center; }
.done h1, .done h2 { font: 600 22px/1.25 var(--f-display); margin: 0; }
.done p { margin: 0; color: var(--muted); max-width: 50ch; }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 50;
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: var(--r); font-size: 14px; box-shadow: var(--shadow);
  max-width: calc(100% - 32px);
}
.toast a { color: var(--accent); font-weight: 600; margin-left: 8px; }

.foot { border-top: 1px solid var(--line); background: var(--surface); font-size: 14px; }
.foot-in { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; padding-block: 24px; }

/* ---------- Адмінка ---------- */
.admin-nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.admin-nav a { color: var(--head-muted); padding: 8px 12px; border-radius: 8px; }
.admin-nav a:hover { color: var(--head-fg); text-decoration: none; }
.admin-nav a[aria-current="page"] { color: var(--head-fg); background: rgb(255 255 255 / .08); }
.admin-site { color: var(--head-muted); font-size: 14px; }
.linkish { border: none; background: none; color: var(--head-muted); cursor: pointer; font-size: 14px; padding: 8px 4px; }
.linkish:hover { color: var(--head-fg); }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tabs a { padding: 7px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font-size: 14px; }
.tabs a:hover { text-decoration: none; border-color: var(--ink); }
.tabs a[aria-current="page"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.tabs span { font: 12px var(--f-mono); opacity: .7; margin-left: 2px; }
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); }
.panel .table-wrap { border: none; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-weight: 500; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; }
.table th, .table td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr[data-href] { cursor: pointer; }
.table tbody tr:hover { background: var(--bg); }
.table tfoot td { font-weight: 600; border-top: 1px solid var(--line); border-bottom: none; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table th.num { text-align: right; }
.neg { color: var(--bad); }
.src { font: 11px var(--f-mono); color: var(--muted); margin-left: 4px; }
.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font: 600 12px/1.6 var(--f-body); white-space: nowrap; vertical-align: middle; border: 1px solid currentColor; }
.s-new { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.s-processing { color: var(--info); } .s-shipped { color: var(--violet); } .s-done { color: var(--ok); } .s-cancelled { color: var(--muted); }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 18px 20px; display: grid; gap: 12px; align-content: start; min-width: 0; }
.order-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 16px; }
.kv { display: grid; grid-template-columns: 120px 1fr; gap: 8px 16px; margin: 0; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; overflow-wrap: anywhere; }
.notice { background: var(--surface); border: 1px solid var(--ok); color: var(--ok); padding: 10px 14px; border-radius: var(--r); margin: 0; }
.import { grid-template-columns: minmax(0, 1fr) auto; align-items: center; }
.import p { margin: 6px 0 0; }
.admin-filter { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.admin-filter input { flex: 1 1 260px; min-width: 0; }
.login main { min-height: 100vh; display: grid; place-items: center; }
.login-box { width: min(380px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 28px; display: grid; gap: 14px; box-shadow: var(--shadow); }
.login-box h1 { font-size: 22px; }
.login-box small { font: 500 13px var(--f-body); color: var(--muted); letter-spacing: 0; }

/* ---------- Адаптив ---------- */
@media (max-width: 1000px) { .head-contact { display: none; } }
@media (max-width: 900px) {
  .product, .cart, .order-grid { grid-template-columns: minmax(0, 1fr); }
  .buy, .checkout { position: static; }
}
@media (max-width: 640px) {
  .top-in { gap: 10px; }
  .search { order: 5; flex-basis: 100%; }
  .chips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin-inline: -16px; padding-inline: 16px; }
  .chips::-webkit-scrollbar { display: none; }
  .chip { flex: none; white-space: nowrap; }
  .subcats { display: flex; overflow-x: auto; scrollbar-width: none; margin-inline: -16px; padding-inline: 16px; }
  .subcats::-webkit-scrollbar { display: none; }
  .subcat { flex: none; width: 210px; }
  .cat { grid-template-columns: 72px minmax(0, 1fr); }
  .cart-link { margin-left: auto; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .card-body { padding: 10px; }
  .price { font-size: 16px; }
  .add { width: 100%; }
  .line { grid-template-columns: 56px minmax(0, 1fr) 32px; }
  .line img { width: 56px; height: 56px; }
  .line .qty, .line .price { grid-column: 2; }
  .line .price { text-align: left; }
  .line .rm { grid-row: 1; grid-column: 3; }
  .import { grid-template-columns: minmax(0, 1fr); }
  .kv { grid-template-columns: 100px 1fr; }
  .buy-price { font-size: 28px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
