:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --fg: #14161a;
  --muted: #6b7280;
  --line: #e3e5ea;
  --brand: #0b5cff;
  --brand-dark: #0846c9;
  --sale: #e21b45;
  --ok: #0f8a4d;
  --shadow: 0 1px 2px rgba(16,20,28,.06), 0 6px 20px rgba(16,20,28,.05);
  --radius: 14px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c0e12;
    --surface: #14171d;
    --fg: #eceef2;
    --muted: #9aa2b1;
    --line: #262b34;
    --brand: #5b8bff;
    --brand-dark: #7ba1ff;
    --sale: #ff5c7c;
    --ok: #3ecf8e;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.3);
  }
}

* { box-sizing: border-box; }

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

a { color: inherit; }
main { min-height: 70vh; padding-bottom: 56px; }

.wrap { max-width: 1140px; margin: 0 auto; padding: 0 20px; }
.wrap.narrow { max-width: 680px; }

/* Шапка */
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.topbar__inner { display: flex; align-items: center; gap: 24px; padding: 14px 20px; }
.logo { font-size: 19px; font-weight: 700; letter-spacing: -.02em; text-decoration: none; }
.logo span { color: var(--brand); }
.topnav { display: flex; gap: 20px; font-size: 14px; margin-right: auto; }
.topnav a { color: var(--muted); text-decoration: none; }
.topnav a:hover { color: var(--fg); }
@media (max-width: 620px) { .topnav { display: none; } }

.cartlink { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 500; text-decoration: none; }
.badge {
  min-width: 22px; height: 22px; padding: 0 6px; border-radius: 999px; background: var(--brand);
  color: #fff; font-size: 12px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center;
}
.badge--empty { background: var(--line); color: var(--muted); }
.topbar--admin .logo span { color: var(--muted); }

/* Витрина */
.hero-strip { background: linear-gradient(120deg, var(--brand), #7b3ff2); color: #fff; padding: 40px 0; margin-bottom: 28px; }
.hero-strip h1 { margin: 0 0 6px; font-size: clamp(24px, 4vw, 36px); letter-spacing: -.02em; }
.hero-strip p { margin: 0; opacity: .9; font-size: 15px; }

.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 22px; }
.filters--admin { margin-bottom: 18px; }
.search {
  flex: 1 1 260px; min-width: 0; padding: 11px 14px; border: 1px solid var(--line);
  border-radius: 10px; background: var(--surface); color: var(--fg); font: inherit;
}
.search:focus, .select:focus, .field input:focus, .field textarea:focus {
  outline: 2px solid var(--brand); outline-offset: -1px; border-color: transparent;
}
.select {
  padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); color: var(--fg); font: inherit;
}
.select--sm { padding: 6px 10px; font-size: 13px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; width: 100%; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); font-size: 13px; cursor: pointer; user-select: none;
}
.chip input { display: none; }
.chip:hover { border-color: var(--brand); }
.chip--on { background: var(--brand); border-color: var(--brand); color: #fff; }

.spin { font-size: 13px; color: var(--muted); opacity: 0; transition: opacity .2s; }
.htmx-request.spin, .htmx-request .spin { opacity: 1; }

.pgrid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }

.pcard {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; display: flex; flex-direction: column; transition: box-shadow .18s, transform .18s;
}
.pcard:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.pcard__media {
  position: relative; display: flex; align-items: center; justify-content: center;
  aspect-ratio: 4 / 3; background: linear-gradient(160deg, rgba(11,92,255,.07), rgba(123,63,242,.07));
  text-decoration: none;
}
.pcard__emoji { font-size: 56px; line-height: 1; }
.tag {
  position: absolute; top: 10px; left: 10px; padding: 3px 8px; border-radius: 7px;
  font-size: 12px; font-weight: 600; color: #fff; background: var(--sale);
}
.tag--out { background: #6b7280; left: auto; right: 10px; }

.pcard__body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.price { display: flex; align-items: baseline; gap: 8px; }
.price b { font-size: 18px; letter-spacing: -.02em; }
.price s { color: var(--muted); font-size: 13px; }
.price--lg b { font-size: 30px; }
.pcard__title { font-size: 14px; text-decoration: none; line-height: 1.35; }
.pcard__title:hover { color: var(--brand); }
.rating { font-size: 12px; color: var(--muted); }
.rating__stars { color: #f5a524; letter-spacing: 1px; }
.pcard__foot { margin-top: auto; padding-top: 8px; }

/* Кнопки */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 18px; border-radius: 10px; border: 1px solid transparent;
  font: 500 14px/1 inherit; cursor: pointer; text-decoration: none; transition: background .15s, border-color .15s, opacity .15s;
}
.btn--primary { background: var(--brand); color: #fff; }
.btn--primary:hover { background: var(--brand-dark); }
.btn--ghost { border-color: var(--line); background: var(--surface); color: var(--fg); }
.btn--ghost:hover { border-color: var(--fg); }
.btn--danger { background: transparent; border-color: var(--line); color: var(--sale); }
.btn--danger:hover { border-color: var(--sale); }
.btn--full { width: 100%; }
.btn--sm { padding: 6px 12px; font-size: 13px; }
.btn--lg { padding: 14px 26px; font-size: 15px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.htmx-request { opacity: .6; pointer-events: none; }

.added {
  display: block; text-align: center; padding: 10px 14px; border-radius: 10px;
  background: rgba(15,138,77,.12); color: var(--ok); font-size: 13px; font-weight: 500; text-decoration: none;
}
.added--err { background: rgba(226,27,69,.12); color: var(--sale); }

/* Карточка товара */
.crumbs { font-size: 13px; color: var(--muted); padding: 18px 0; display: flex; gap: 8px; }
.crumbs a { text-decoration: none; }
.crumbs a:hover { color: var(--brand); }

.pdetail { display: grid; grid-template-columns: 1fr 1fr; gap: 32px; align-items: start; }
@media (max-width: 780px) { .pdetail { grid-template-columns: 1fr; } }
.pdetail__media {
  position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  aspect-ratio: 1; display: flex; align-items: center; justify-content: center;
}
.pdetail__emoji { font-size: 120px; }
.pdetail__info h1 { margin: 0 0 8px; font-size: clamp(22px, 3.4vw, 30px); letter-spacing: -.02em; }
.pdetail__desc { color: var(--muted); margin: 16px 0 0; }
.pdetail__buy { margin-top: 26px; padding: 20px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.stock { font-size: 13px; margin: 8px 0 16px; }
.stock--in { color: var(--ok); }
.stock--out { color: var(--sale); }
.section-h { font-size: 20px; letter-spacing: -.02em; margin: 44px 0 16px; }
.page-h { font-size: clamp(22px, 3.4vw, 30px); letter-spacing: -.02em; margin: 24px 0 20px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }

/* Корзина */
.cart { display: grid; grid-template-columns: 1fr 320px; gap: 24px; align-items: start; }
@media (max-width: 860px) { .cart { grid-template-columns: 1fr; } }
.cart__lines { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.cline { display: grid; grid-template-columns: 52px 1fr auto auto 32px; gap: 14px; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.cline:last-child { border-bottom: 0; }
.cline__emoji { font-size: 32px; text-align: center; }
.cline__info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.cline__title { font-size: 14px; text-decoration: none; }
.cline__unit { font-size: 12px; color: var(--muted); }
.cline__sum { font-weight: 600; white-space: nowrap; }
.cline__del { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 15px; padding: 4px; }
.cline__del:hover { color: var(--sale); }
@media (max-width: 560px) {
  .cline { grid-template-columns: 40px 1fr 32px; row-gap: 10px; }
  .cline__sum, .qty { grid-column: 2; justify-self: start; }
}
.qty { display: inline-flex; align-items: center; gap: 4px; border: 1px solid var(--line); border-radius: 9px; padding: 2px; }
.qty__btn { width: 28px; height: 28px; border: 0; background: none; color: var(--fg); font-size: 16px; cursor: pointer; border-radius: 7px; }
.qty__btn:hover:not(:disabled) { background: var(--bg); }
.qty__btn:disabled { opacity: .35; cursor: not-allowed; }
.qty__n { min-width: 26px; text-align: center; font-size: 14px; font-variant-numeric: tabular-nums; }

.summary { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; display: flex; flex-direction: column; gap: 10px; }
.summary__h { margin: 0 0 4px; font-size: 16px; }
.summary__row { display: flex; justify-content: space-between; gap: 14px; font-size: 14px; color: var(--muted); }
.summary__row b { color: var(--fg); font-weight: 600; }
.summary__row--total { border-top: 1px solid var(--line); padding-top: 10px; margin-top: 4px; font-size: 16px; }
.summary__more { font-size: 13px; color: var(--muted); text-align: center; text-decoration: none; }
.summary__more:hover { color: var(--brand); }

/* Формы */
.checkout { display: grid; grid-template-columns: 1fr 320px; gap: 24px; align-items: start; }
@media (max-width: 860px) { .checkout { grid-template-columns: 1fr; } }
.form { display: flex; flex-direction: column; gap: 16px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; }
.panel--login { margin-top: 40px; }
.field { display: flex; flex-direction: column; gap: 6px; flex: 1; }
.field > span { font-size: 13px; color: var(--muted); }
.field input, .field textarea {
  padding: 11px 13px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--bg); color: var(--fg); font: inherit; resize: vertical;
}
.field-row { display: flex; gap: 14px; flex-wrap: wrap; }
.field--narrow { flex: 0 0 110px; }
.check { display: flex; align-items: center; gap: 9px; font-size: 14px; cursor: pointer; }
.form__actions { display: flex; gap: 10px; flex-wrap: wrap; }
.hint { font-size: 13px; color: var(--muted); margin: 0; text-decoration: none; display: inline-block; }

.notice { border-radius: 10px; padding: 12px 15px; font-size: 14px; margin: 0 0 18px; }
.notice--err { background: rgba(226,27,69,.1); color: var(--sale); }

.empty { color: var(--muted); padding: 30px 0; }
.empty--big { text-align: center; padding: 60px 20px; display: flex; flex-direction: column; align-items: center; gap: 18px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }

.done { text-align: center; padding: 44px 0 26px; }
.done__mark { display: inline-flex; align-items: center; justify-content: center; width: 56px; height: 56px; border-radius: 50%; background: rgba(15,138,77,.14); color: var(--ok); font-size: 26px; margin-bottom: 14px; }
.done h1 { margin: 0 0 8px; font-size: 24px; }
.done p { color: var(--muted); margin: 0; }
.narrow .panel { margin-bottom: 20px; display: flex; flex-direction: column; gap: 9px; }

/* Админка */
.stats { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); margin-bottom: 10px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; display: flex; flex-direction: column; gap: 4px; }
.stat span { font-size: 13px; color: var(--muted); }
.stat b { font-size: 24px; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat--wide b { color: var(--ok); }

.tablewrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.table { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 680px; }
.table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.table td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table a { text-decoration: none; }
.table a:hover { color: var(--brand); }
.td-emoji { font-size: 22px; }
.td-warn { color: var(--sale); font-weight: 600; }
.td-actions { display: flex; gap: 8px; justify-content: flex-end; }

.pill { display: inline-block; padding: 3px 10px; border-radius: 999px; background: var(--bg); border: 1px solid var(--line); font-size: 12px; }
.pill--ok { color: var(--ok); border-color: rgba(15,138,77,.4); }

.orders { display: flex; flex-direction: column; gap: 14px; }
.ocard { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.ocard__head { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.ocard__date { color: var(--muted); font-size: 13px; margin-left: 10px; }
.ocard__grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; padding-top: 14px; }
@media (max-width: 720px) { .ocard__grid { grid-template-columns: 1fr; } }
.lbl { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.ocard__grid p { margin: 4px 0 14px; font-size: 14px; }

.footer { border-top: 1px solid var(--line); background: var(--surface); }
.footer .wrap { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding-top: 22px; padding-bottom: 22px; font-size: 13px; color: var(--muted); }
