/* Structural styles for shared pages. Every visual decision comes from tokens set in theme.css. */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: var(--font-body); font-size: var(--fs-body, 16px); line-height: 1.55;
  min-height: 100vh; display: flex; flex-direction: column;
}
main { flex: 1; }
img { max-width: 100%; display: block; }
a { color: var(--link, var(--accent)); }
:focus-visible { outline: 2px solid var(--focus, var(--accent)); outline-offset: 2px; }
h1, h2, h3 { font-family: var(--font-display); line-height: 1.15; margin: 0; }
p { margin: 0 0 1em; }
.container { width: 100%; max-width: var(--maxw, 1200px); margin: 0 auto; padding: 0 var(--gutter, 20px); }
.muted { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* buttons & inputs */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-weight: var(--btn-weight, 600); font-size: .95rem; line-height: 1;
  padding: 13px 20px; border-radius: var(--radius-btn, var(--radius)); border: 1px solid transparent;
  cursor: pointer; text-decoration: none; transition: background .15s, color .15s, border-color .15s;
}
.btn:disabled { opacity: .55; cursor: progress; }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent-hover, var(--accent)); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--line); }
.btn-ghost:hover { border-color: var(--text); }
.btn-link { background: none; border: 0; color: var(--muted); padding: 12px 0; text-decoration: underline; }
.btn-block { width: 100%; }
.btn-sm { padding: 8px 12px; font-size: .85rem; }
.input {
  width: 100%; font: inherit; font-size: 16px; color: var(--text); background: var(--input-bg, var(--surface));
  border: 1px solid var(--line); border-radius: var(--radius-input, var(--radius)); padding: 12px 14px;
}
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring, rgba(0,0,0,.08)); }
textarea.input { resize: vertical; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }
.field { display: grid; gap: 6px; margin-bottom: 16px; }
.field > span { font-size: .875rem; font-weight: 600; }
.field small { color: var(--muted); font-size: .8rem; }
.form-error { color: var(--danger, #d93636); font-size: .9rem; min-height: 0; margin: 0 0 12px; }
.form-error:empty, .form-ok:empty { display: none; }
.form-ok { color: var(--success, #188a4a); font-size: .9rem; margin: 0 0 12px; }
.form-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }

.panel { background: var(--surface); border: 1px solid var(--panel-line, var(--line)); border-radius: var(--radius-lg); padding: 24px; }
.panel-title { font-size: 1.15rem; margin-bottom: 16px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  font: inherit; font-size: .9rem; padding: 8px 14px; border-radius: var(--radius-chip, 999px);
  background: var(--chip-bg, transparent); color: var(--text); border: 1px solid var(--line); cursor: pointer;
}
.chip.active { background: var(--text); color: var(--bg); border-color: var(--text); }
.badge { position: absolute; top: 10px; left: 10px; background: var(--badge-bg, var(--accent)); color: var(--badge-ink, var(--accent-ink)); font-size: .75rem; font-weight: 700; padding: 4px 8px; border-radius: var(--radius-chip, 6px); }
.status { display: inline-block; font-size: .78rem; font-weight: 600; padding: 4px 10px; border-radius: 999px; white-space: nowrap; background: var(--surface-2); color: var(--muted); }
.status-pending { background: #fff4d6; color: #8a5a00; }
.status-paid, .status-processing { background: #e2ecff; color: #2349a8; }
.status-completed { background: #dcf5e6; color: #146c3a; }
.status-cancelled { background: #f3e1e1; color: #8c2a2a; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none; background: var(--text); color: var(--bg); padding: 12px 18px; border-radius: 10px; transition: .2s; z-index: 100; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* page head */
.page-head { padding-top: 40px; padding-bottom: 8px; }
.page-title { font-size: clamp(1.8rem, 3.5vw, 2.6rem); margin-bottom: 12px; }

/* product grid & default card */
.grid-products { display: grid; grid-template-columns: repeat(auto-fill, minmax(var(--card-min, 230px), 1fr)); gap: var(--grid-gap, 20px); }
.card { position: relative; display: flex; flex-direction: column; text-decoration: none; color: inherit; background: var(--surface); border: 1px solid var(--panel-line, var(--line)); border-radius: var(--radius-lg); overflow: hidden; }
.card-media { position: relative; aspect-ratio: var(--card-ratio, 460 / 215); background: var(--surface-2); }
.card-media img { width: 100%; height: 100%; object-fit: cover; }
.card-body { padding: 14px 16px 16px; display: flex; flex-direction: column; flex: 1; }
.card-title { font-size: 1rem; margin-bottom: 4px; }
.card-sub { color: var(--muted); font-size: .85rem; margin-bottom: 12px; }
.card-foot { margin-top: auto; display: flex; align-items: baseline; gap: 8px; }
.card-price { font-weight: 700; font-size: 1.05rem; }
.card-old { color: var(--muted); font-size: .85rem; }
.card:hover .card-title { color: var(--accent-text, var(--accent)); }

/* catalog */
.catalog { padding-bottom: 64px; }
.catalog-bar { display: flex; flex-wrap: wrap; gap: 16px; justify-content: space-between; align-items: center; margin-bottom: 24px; }
.catalog-tools { display: flex; gap: 10px; flex: 1 1 360px; max-width: 520px; }
.catalog-tools select { max-width: 190px; }
.empty { text-align: center; padding: 48px 0; color: var(--muted); }

/* product page */
.product { padding-top: 24px; padding-bottom: 64px; }
.crumbs { display: flex; gap: 8px; font-size: .9rem; color: var(--muted); margin-bottom: 20px; }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--text); }
.product-grid { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 32px; align-items: start; }
.product-media { border-radius: var(--radius-lg); overflow: hidden; background: var(--surface-2); }
.product-media img { width: 100%; aspect-ratio: var(--product-ratio, 460 / 215); object-fit: cover; }
.product-buy { position: sticky; top: 90px; }
.product-title { font-size: clamp(1.5rem, 2.6vw, 2rem); margin-bottom: 8px; }
.product-sub { color: var(--muted); }
.opt-group { border: 0; padding: 0; margin: 0 0 16px; }
.opt-group legend { font-size: .875rem; font-weight: 600; margin-bottom: 8px; padding: 0; }
.opt-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.opt { position: relative; cursor: pointer; }
.opt input { position: absolute; opacity: 0; }
.opt-box { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; height: 100%; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.opt input:checked + .opt-box { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); background: var(--opt-active-bg, var(--surface)); }
.opt input:focus-visible + .opt-box { outline: 2px solid var(--accent); outline-offset: 2px; }
.opt-label { font-weight: 600; font-size: .92rem; }
.opt-note { color: var(--muted); font-size: .78rem; }
.opt-price { font-size: .88rem; margin-top: 4px; }
.opt-price s { color: var(--muted); font-size: .8rem; }
.qty { display: grid; grid-template-columns: 44px 1fr 44px; gap: 6px; }
.qty .input { text-align: center; }
.qty-btn { font: inherit; font-size: 1.2rem; border: 1px solid var(--line); background: var(--surface); color: var(--text); border-radius: var(--radius); cursor: pointer; }
.total-row { display: flex; justify-content: space-between; align-items: baseline; padding: 16px 0; border-top: 1px solid var(--line); margin-top: 4px; }
.total-row strong { font-size: 1.5rem; font-family: var(--font-display); }
.price-notes { font-size: .82rem; color: var(--muted); margin: -6px 0 12px; }
.price-notes p { margin: 0 0 4px; }
.rate-row { display: grid; grid-template-columns: 70px 160px 1fr auto auto; gap: 12px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); }
.adm-limits { margin: 16px 0; }
.delivery-note { font-size: .85rem; color: var(--muted); margin: 14px 0 0; }
.product-desc { max-width: 720px; margin-top: 40px; }
.related { margin-top: 48px; }
.prose { line-height: 1.7; }
.prose h2 { font-size: 1.25rem; margin: 28px 0 10px; }
.prose ul { padding-left: 20px; }

/* auth */
.auth-wrap { display: grid; place-items: center; padding: 56px var(--gutter, 20px) 80px; }
.auth-card { width: 100%; max-width: 420px; }
.auth-title { font-size: 1.7rem; margin-bottom: 20px; }
.auth-links { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; margin-top: 16px; font-size: .9rem; }
.auth-agree { font-size: .8rem; color: var(--muted); margin: 12px 0 0; }

/* account */
.account, .admin, .checkout, .order-page, .contacts, .narrow-page { padding-top: 40px; padding-bottom: 72px; }
.acc-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 20px; align-items: flex-end; margin-bottom: 24px; }
.acc-balance { display: grid; grid-template-columns: auto auto; gap: 4px 16px; align-items: center; padding: 16px 20px; }
.acc-balance strong { font-size: 1.5rem; font-family: var(--font-display); grid-row: 2; }
.acc-balance .btn { grid-row: 1 / 3; grid-column: 2; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 24px; overflow-x: auto; }
.tab { font: inherit; background: none; border: 0; border-bottom: 2px solid transparent; padding: 12px 16px; color: var(--muted); cursor: pointer; white-space: nowrap; margin-bottom: -1px; }
.tab.active { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
.order-list { display: grid; gap: 10px; }
.order-row { display: grid; grid-template-columns: 96px 1fr auto; gap: 16px; align-items: center; padding: 12px; background: var(--surface); border: 1px solid var(--panel-line, var(--line)); border-radius: var(--radius-lg); text-decoration: none; color: inherit; }
.order-row img { width: 96px; height: 54px; object-fit: cover; border-radius: calc(var(--radius) * .6); }
.order-main { display: grid; gap: 2px; min-width: 0; }
.order-main small { color: var(--muted); }
.order-side { display: grid; justify-items: end; gap: 6px; }
.order-amount { font-weight: 700; }
.acc-cols, .order-cols, .checkout-grid, .contacts-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
.narrow { max-width: 480px; }
.tx-list { display: grid; }
.tx { display: flex; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.tx span:first-child { display: grid; }
.tx small { color: var(--muted); }
.tx-amt { font-weight: 700; white-space: nowrap; }
.tx-amt.pos { color: var(--success, #188a4a); }
.logout-btn { margin-top: 20px; }
#topup-presets { margin-bottom: 16px; }

/* order & checkout */
.back-link { display: inline-block; margin-bottom: 20px; color: var(--muted); }
.order-head { display: flex; gap: 20px; align-items: center; margin-bottom: 24px; flex-wrap: wrap; }
.order-head img { width: 160px; border-radius: var(--radius); aspect-ratio: 460 / 215; object-fit: cover; }
.order-head > div { flex: 1; min-width: 200px; }
.kv { margin: 0 0 16px; display: grid; gap: 10px; }
.kv div { display: flex; justify-content: space-between; gap: 16px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: right; font-weight: 600; word-break: break-all; }
.code-row { display: flex; gap: 10px; align-items: center; justify-content: space-between; padding: 12px; margin-bottom: 8px; background: var(--surface-2); border-radius: var(--radius); }
.code-label { color: var(--muted); font-size: .8rem; min-width: 70px; }
.code-row code { flex: 1;  font-size: 1.05rem; font-weight: 700; letter-spacing: .06em; word-break: break-all; }
.checkout-grid { grid-template-columns: 1.1fr 1fr; }
.pay-method { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 10px; cursor: pointer; }
.pay-method span { display: grid; }
.pay-method small { color: var(--muted); }
.pay-method:has(input:checked) { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.pay-method.disabled { opacity: .55; cursor: not-allowed; }
.pay-method input { accent-color: var(--accent); margin-top: 4px; }
.sum-img { width: 100%; aspect-ratio: 460 / 215; object-fit: cover; border-radius: var(--radius); margin-bottom: 16px; }

/* faq, legal, contacts */
.narrow-page { max-width: 820px; }
.faq-item { border-bottom: 1px solid var(--line); }
.faq-item summary { cursor: pointer; padding: 18px 0; font-weight: 600; font-size: 1.05rem; list-style: none; display: flex; justify-content: space-between; gap: 16px; }
.faq-item summary::after { content: '+'; font-size: 1.3rem; line-height: 1; color: var(--muted); }
.faq-item[open] summary::after { content: '−'; }
.faq-item summary::-webkit-details-marker { display: none; }
.faq-body { padding-bottom: 18px; color: var(--muted); max-width: 68ch; }
.faq-more { margin-top: 24px; }
.contacts-info p { margin-bottom: 28px; }

/* admin */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 16px; }
.stat { display: grid; gap: 6px; }
.stat span { color: var(--muted); font-size: .9rem; }
.stat strong { font-size: 1.7rem; font-family: var(--font-display); }
.bars { display: flex; align-items: flex-end; gap: 6px; height: 220px; }
.bar { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 6px; }
.bar i { display: block; width: 100%; background: var(--accent); border-radius: 4px 4px 0 0; }
.bar small { color: var(--muted); font-size: .72rem; }
.table-wrap { overflow-x: auto; margin-top: 16px; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th, .table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { font-weight: 600; color: var(--muted); font-size: .8rem; }
.table small { color: var(--muted); }
.table .thumb { width: 64px; height: 36px; object-fit: cover; border-radius: 4px; }
.muted-row { opacity: .5; }
.nowrap { white-space: nowrap; }
#adm-order-filter { margin-bottom: 4px; }
.msg-list { display: grid; gap: 12px; }
.msg header { display: flex; flex-wrap: wrap; gap: 10px; align-items: baseline; margin-bottom: 8px; }
.msg header small { color: var(--muted); margin-left: auto; }
.modal { border: 0; border-radius: var(--radius-lg); padding: 0; width: min(720px, calc(100% - 32px)); background: var(--surface); color: var(--text); }
.modal::backdrop { background: rgba(0,0,0,.5); }
.modal-body { padding: 24px; max-height: 85vh; overflow: auto; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; }

.notfound { text-align: center; padding: 96px 20px; }
.notfound-code { font-family: var(--font-display); font-size: 6rem; line-height: 1; margin-bottom: 12px; color: var(--accent-text, var(--accent)); }
.notfound-actions { display: flex; gap: 12px; justify-content: center; margin-top: 24px; }

@media (max-width: 900px) {
  .product-grid, .acc-cols, .order-cols, .checkout-grid, .contacts-grid { grid-template-columns: 1fr; }
  .product-buy { position: static; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 560px) {
  .catalog-tools { flex-direction: column; max-width: none; }
  .catalog-tools select { max-width: none; }
  .order-row { grid-template-columns: 1fr auto; }
  .order-row img { display: none; }
  .form-2 { grid-template-columns: 1fr; }
  .panel { padding: 18px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
.adm-actions { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
