:root {
  --bg: #f6f7fb; --card: #fff; --text: #171a26; --muted: #6b7185; --line: #e6e8f0;
  --brand: #5b4cf0; --brand2: #13b8a6; --ok: #12a150; --bad: #e5484d; --warn: #d98a00;
  --radius: 16px; --shadow: 0 1px 2px rgba(20,22,40,.04), 0 8px 24px rgba(20,22,40,.06);
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0e1018; --card: #161925; --text: #eceef6; --muted: #949ab0; --line: #262a3a; --shadow: none; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.8 Vazirmatn, Tahoma, sans-serif; }
a { color: var(--brand); text-decoration: none; }
h1, h2, h3, h4 { margin: 0 0 .5em; line-height: 1.4; }
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); font-weight: 400; }
.small { font-size: 13px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); border: 0; padding: 0; }
main { min-height: 70vh; padding-top: 24px; padding-bottom: 48px; }

/* header */
.top { position: sticky; top: 0; z-index: 10; background: color-mix(in srgb, var(--card) 85%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.bar { display: flex; align-items: center; gap: 24px; height: 64px; }
.logo { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 18px; color: var(--text); }
.logo-mark { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 10px; color: #fff; font-size: 13px; background: linear-gradient(135deg, var(--brand), var(--brand2)); }
.bar nav { display: flex; gap: 20px; margin-inline-end: auto; }
.bar nav a { color: var(--muted); font-weight: 600; }
.bar nav a:hover { color: var(--text); }
.cart-btn { display: flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 12px; border: 1px solid var(--line); color: var(--text); font-weight: 600; background: var(--card); }
.count { background: var(--brand); color: #fff; border-radius: 99px; min-width: 22px; height: 22px; display: grid; place-items: center; font-size: 12px; }

/* buttons */
.btn { display: inline-flex; justify-content: center; align-items: center; gap: 6px; border: 0; cursor: pointer; font: inherit; font-weight: 600; color: #fff; background: var(--brand); padding: 10px 18px; border-radius: 12px; transition: .15s; }
.btn:hover { filter: brightness(1.08); transform: translateY(-1px); }
.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); }
.btn.block { width: 100%; margin-top: 12px; padding: 13px; }
.icon-btn { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 16px; padding: 6px 10px; border-radius: 8px; }
.icon-btn:hover { background: color-mix(in srgb, var(--bad) 12%, transparent); color: var(--bad); }
.link { font-weight: 600; }
.center { display: block; text-align: center; margin-top: 10px; }

/* flash & status */
.flash { padding: 12px 16px; border-radius: 12px; margin-bottom: 20px; font-weight: 600; background: color-mix(in srgb, var(--ok) 12%, var(--card)); color: var(--ok); border: 1px solid color-mix(in srgb, var(--ok) 30%, transparent); }
.flash.bad { background: color-mix(in srgb, var(--bad) 10%, var(--card)); color: var(--bad); border-color: color-mix(in srgb, var(--bad) 30%, transparent); }
.flash a { margin-inline-start: 8px; }
.status { display: inline-block; padding: 2px 10px; border-radius: 99px; font-size: 13px; font-weight: 600; }
.status.ok { background: color-mix(in srgb, var(--ok) 14%, transparent); color: var(--ok); }
.status.bad { background: color-mix(in srgb, var(--bad) 14%, transparent); color: var(--bad); }
.status.warn { background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--warn); }

/* hero */
.hero { text-align: center; padding: 40px 0 24px; }
.hero h1 { font-size: clamp(26px, 5vw, 42px); font-weight: 800; }
.grad { background: linear-gradient(90deg, var(--brand), var(--brand2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero p { color: var(--muted); max-width: 620px; margin: 0 auto 20px; }
.perks { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.perks li { background: var(--card); border: 1px solid var(--line); padding: 6px 14px; border-radius: 99px; font-size: 14px; }

.chips { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin: 16px 0 28px; }
.chips a { padding: 6px 16px; border-radius: 99px; background: var(--card); border: 1px solid var(--line); color: var(--muted); font-weight: 600; }
.chips a.on { background: var(--text); color: var(--bg); border-color: var(--text); }

/* product cards */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 18px; }
.card { position: relative; display: flex; flex-direction: column; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); transition: .2s; }
.card:hover { transform: translateY(-3px); border-color: color-mix(in srgb, var(--brand) 40%, var(--line)); }
.tag { position: absolute; top: 16px; left: 16px; font-size: 12px; font-weight: 600; padding: 2px 10px; border-radius: 99px; background: color-mix(in srgb, var(--brand) 12%, transparent); color: var(--brand); }
.card-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.card-head h3 { margin: 0; font-size: 17px; }
.mark { flex: none; display: grid; place-items: center; width: 48px; height: 48px; border-radius: 14px; background: var(--c); color: #fff; font-weight: 800; font-size: 15px; font-family: system-ui, sans-serif; }
.mark.sm { width: 40px; height: 40px; border-radius: 12px; font-size: 13px; }
.feats { list-style: none; padding: 0; margin: 0 0 16px; flex: 1; color: var(--muted); font-size: 14px; }
.feats li::before { content: "✓"; color: var(--ok); margin-inline-end: 8px; font-weight: 800; }
.card-foot { display: flex; align-items: end; justify-content: space-between; gap: 10px; border-top: 1px dashed var(--line); padding-top: 14px; }
.price del { display: block; color: var(--muted); font-size: 13px; }
.price strong { font-size: 18px; font-weight: 800; }
small { font-size: 12px; color: var(--muted); font-weight: 400; }

.steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 18px; margin-top: 48px; }
.steps div { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.steps b { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 10px; background: var(--brand); color: #fff; margin-bottom: 8px; }
.steps p { margin: 0; color: var(--muted); font-size: 14px; }

/* boxes / cart / checkout */
.page-title { font-size: 26px; }
.box { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.layout { display: grid; grid-template-columns: 1fr 340px; gap: 20px; align-items: start; }
.summary { position: sticky; top: 84px; }
.row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 8px 0; }
.row + .row { border-top: 1px solid var(--line); }
.row.total { font-weight: 800; font-size: 17px; }
.line { display: flex; align-items: center; gap: 14px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.line-info { flex: 1; display: flex; flex-direction: column; }
.line-sum { min-width: 130px; text-align: left; }
.qty { width: 70px; text-align: center; }
.line-actions { display: flex; justify-content: space-between; align-items: center; padding-top: 16px; }
.empty { text-align: center; padding: 60px 20px; }
.empty-icon { font-size: 48px; }

input, textarea { width: 100%; font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-top: 4px; }
input:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--brand) 40%, transparent); border-color: var(--brand); }
.form label { display: block; font-weight: 600; margin-bottom: 14px; }
.form em { display: block; color: var(--bad); font-style: normal; font-size: 13px; font-weight: 400; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.check { display: flex !important; gap: 10px; align-items: center; font-weight: 400 !important; }
.check input { width: auto; margin: 0; accent-color: var(--brand); }
.narrow { max-width: 520px; margin: 0 auto; }
.narrow h3 { margin-top: 28px; }
.order-row { color: var(--text); }

.progress { list-style: none; display: flex; padding: 0; margin: 0 0 24px; counter-reset: s; }
.progress li { flex: 1; text-align: center; color: var(--muted); font-size: 14px; position: relative; padding-top: 34px; }
.progress li::before { counter-increment: s; content: counter(s); position: absolute; top: 0; right: 50%; transform: translateX(50%); width: 28px; height: 28px; line-height: 28px; border-radius: 50%; background: var(--line); color: var(--muted); font-weight: 700; z-index: 1; }
.progress li + li::after { content: ""; position: absolute; top: 13px; left: 50%; width: 100%; height: 2px; background: var(--line); }
.progress li.done::before { content: "✓"; background: var(--ok); color: #fff; }
.progress li.on { color: var(--text); font-weight: 600; }
.progress li.on::before { background: var(--brand); color: #fff; }

/* gateway */
.gateway { max-width: 420px; margin: 20px auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); }
.gw-head { display: flex; gap: 12px; align-items: center; margin-bottom: 16px; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.gw-head div { display: flex; flex-direction: column; font-size: 13px; }
.gw-head b { font-size: 16px; }
.gw-lock { font-size: 28px; }
.gw-actions { margin-top: 8px; }

/* receipt */
.receipt { max-width: 640px; margin: 0 auto; text-align: center; padding: 32px; }
.receipt-icon { width: 72px; height: 72px; margin: 0 auto 12px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-size: 36px; font-weight: 800; }
.receipt-icon.ok { background: var(--ok); box-shadow: 0 0 0 10px color-mix(in srgb, var(--ok) 15%, transparent); }
.receipt-icon.bad { background: var(--warn); box-shadow: 0 0 0 10px color-mix(in srgb, var(--warn) 15%, transparent); }
.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 20px 0; }
.facts div { background: var(--bg); border-radius: 12px; padding: 10px; display: flex; flex-direction: column; gap: 2px; }
.facts span:first-child { font-size: 13px; color: var(--muted); }
.facts .status { align-self: center; }
.items { text-align: right; margin-bottom: 20px; }
.receipt-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

/* invoice */
.invoice-tools { display: flex; justify-content: space-between; align-items: center; max-width: 860px; margin: 0 auto 16px; }
.invoice { max-width: 860px; margin: 0 auto; background: #fff; color: #171a26; border: 1px solid #e6e8f0; border-radius: var(--radius); padding: 36px; }
.invoice .muted { color: #6b7185; }
.inv-head { display: flex; justify-content: space-between; gap: 20px; padding-bottom: 20px; border-bottom: 2px solid #171a26; }
.invoice .logo { color: #171a26; }
.inv-title { text-align: left; }
.inv-title h1 { font-size: 22px; }
.inv-parties { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin: 20px 0; }
.inv-parties > div { border: 1px solid #e6e8f0; border-radius: 12px; padding: 12px 16px; }
.inv-parties h4 { color: #6b7185; font-size: 13px; margin-bottom: 4px; }
.inv-parties p { margin: 0; }
.inv-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.inv-table th, .inv-table td { border: 1px solid #e6e8f0; padding: 10px; text-align: center; }
.inv-table td:nth-child(2) { text-align: right; }
.inv-table th { background: #f3f4f8; }
.inv-table tfoot td { font-weight: 600; }
.inv-table tfoot td:first-child { text-align: left; }
.inv-table .grand td { background: #171a26; color: #fff; font-weight: 800; }
.inv-foot { display: flex; justify-content: space-between; align-items: center; gap: 20px; margin-top: 20px; font-size: 14px; }
.stamp { flex: none; border: 3px solid; border-radius: 12px; padding: 6px 18px; font-weight: 800; font-size: 18px; transform: rotate(-8deg); }
.stamp.ok { color: var(--ok); }
.stamp.bad { color: var(--bad); }

footer.foot { border-top: 1px solid var(--line); padding: 20px 0; font-size: 14px; }
footer.foot .wrap { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; }

@media (max-width: 820px) {
  .layout { grid-template-columns: 1fr; }
  .summary { position: static; }
  .bar { gap: 12px; }
  .bar nav { gap: 12px; font-size: 14px; }
  .cart-btn span { display: none; }
  .cols, .facts, .inv-parties { grid-template-columns: 1fr; }
  .line { flex-wrap: wrap; }
  .line-sum { min-width: 0; }
  .invoice { padding: 20px; }
  .inv-head { flex-direction: column; }
  .inv-title { text-align: right; }
  .inv-table { font-size: 12px; }
  .inv-table th, .inv-table td { padding: 6px 4px; }
}
@media (max-width: 480px) { .bar nav a:first-child { display: none; } }

@media print {
  .top, .foot, .no-print, .flash { display: none !important; }
  body { background: #fff; }
  main { padding: 0; }
  .invoice { border: 0; padding: 0; }
  .inv-table .grand td, .inv-table th { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
