:root {
  --ink: #1d1d1f;
  --muted: #6e6e73;
  --line: #e5e5ea;
  --paper: #ffffff;
  --wash: #f5f5f7;
  --accent: #0b6e4f;
  --accent-ink: #ffffff;
  --danger: #b42318;
  --ok: #067647;
  --radius: 12px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--paper);
}
img { max-width: 100%; height: auto; display: block; }
a { color: var(--accent); }
h1 { font-size: 1.75rem; margin: 1rem 0; line-height: 1.2; }
h2 { font-size: 1.25rem; margin: 1.25rem 0 .5rem; }
h3 { font-size: 1.05rem; margin: 1rem 0 .25rem; }
code { background: var(--wash); padding: .1rem .35rem; border-radius: 6px; }
.wrap { width: min(1120px, 100% - 2rem); margin-inline: auto; }
.narrow { max-width: 440px; margin: 0 auto; padding: 1rem 0; }
.center { text-align: center; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 1rem; top: 1rem; background: var(--ink); color: #fff; padding: .5rem; z-index: 9; }

/* Header */
.site-header { border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--paper); z-index: 5; }
.bar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 60px; flex-wrap: wrap; }
.brand { font-weight: 700; text-decoration: none; color: var(--ink); letter-spacing: -.01em; }
nav { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
nav a { text-decoration: none; color: var(--ink); font-size: .95rem; }
nav a:hover { color: var(--accent); }
.inline { display: inline; margin: 0; }
button.link { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; font: inherit; }

/* Footer */
.site-footer { margin-top: 3rem; border-top: 1px solid var(--line); padding: 1.5rem 0; color: var(--muted); font-size: .875rem; }

/* Flash messages */
.flash { padding: .75rem 1rem; border-radius: 8px; margin: .75rem 0; border: 1px solid transparent; }
.flash-success { background: #ecfdf3; color: var(--ok); border-color: #abefc6; }
.flash-error { background: #fef3f2; color: var(--danger); border-color: #fecdca; }
.flash-info { background: var(--wash); border-color: var(--line); }
.flash[hidden] { display: none; }

/* Buttons and forms */
.btn {
  display: inline-block; padding: .65rem 1.1rem; border-radius: 999px; border: 1px solid var(--ink);
  background: var(--paper); color: var(--ink); font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
}
.btn:hover { background: var(--wash); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: #095a40; }
.btn-small { padding: .35rem .7rem; font-size: .875rem; }
.block { display: block; width: 100%; text-align: center; }
input, select, textarea {
  font: inherit; padding: .6rem .7rem; border: 1px solid #c7c7cc; border-radius: 8px; width: 100%; background: #fff;
}
input[type="checkbox"], input[type="radio"] { width: auto; }
input[type="number"] { width: 6rem; }
label { display: grid; gap: .3rem; font-size: .92rem; font-weight: 500; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; margin: 0; display: grid; gap: .75rem; }
legend { font-weight: 700; padding: 0 .4rem; }
.stack { display: grid; gap: .9rem; }
.inline-block { display: inline-block; margin-top: .5rem; }
.row3 { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: .75rem; }
.choice { display: flex; align-items: center; gap: .6rem; padding: .5rem .25rem; font-weight: 500; }
.choice small { color: var(--muted); margin-left: auto; }
.grid-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: .75rem; align-items: end; }
.span-2 { grid-column: span 2; }
.filters { display: flex; flex-wrap: wrap; gap: .6rem; margin: 1rem 0 1.5rem; }
.filters input { flex: 2 1 220px; }
.filters select { flex: 1 1 160px; width: auto; }

/* Hero, grid, cards */
.hero { padding: 1.5rem 0 .5rem; }
.hero h1 { font-size: clamp(1.8rem, 4vw, 2.5rem); margin-bottom: .25rem; }
.hero p { color: var(--muted); margin-top: 0; }
.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.card { border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem; display: flex; flex-direction: column; gap: .4rem; background: #fff; }
.card-link { text-decoration: none; color: inherit; display: grid; gap: .4rem; }
.card img, .ph { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 8px; background: var(--wash); }
.ph { display: grid; place-items: center; color: var(--muted); font-size: .9rem; }
.ph.large { aspect-ratio: 1 / 1; }
.card h2 { font-size: 1rem; margin: 0; }
.price { font-weight: 700; margin: 0; }
.price.big { font-size: 1.6rem; }
.empty { color: var(--muted); padding: 2rem 0; text-align: center; }
.badge { display: inline-block; font-size: .75rem; font-weight: 700; padding: .2rem .55rem; border-radius: 999px; width: fit-content; }
.badge-new { background: #e7f6ee; color: #05603a; }
.badge-open_box { background: #fff4e5; color: #8a4b00; }
.badge-used { background: #eef2ff; color: #3730a3; }

/* Product page */
.product { display: grid; gap: 2rem; grid-template-columns: 1fr; padding-top: .5rem; }
.gallery { display: grid; gap: .5rem; align-content: start; }
#main-img { border-radius: var(--radius); aspect-ratio: 4 / 3; object-fit: cover; width: 100%; background: var(--wash); }
.thumbs { display: flex; gap: .4rem; flex-wrap: wrap; }
.thumb { width: 72px; height: 72px; padding: 0; border: 2px solid var(--line); border-radius: 8px; overflow: hidden; background: none; cursor: pointer; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.details { display: grid; gap: .6rem; align-content: start; }
.condition-box { background: var(--wash); padding: .9rem 1rem; border-radius: var(--radius); }
.condition-box p { margin: .3rem 0 0; }
.add-to-cart { display: flex; gap: .75rem; align-items: end; flex-wrap: wrap; }
.prose { color: #3a3a3c; white-space: normal; }

/* Cart, checkout, order */
.cart-layout { display: grid; gap: 2rem; grid-template-columns: 1fr; align-items: start; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: .6rem .4rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.table-scroll { overflow-x: auto; }
.table.small { font-size: .875rem; }
.right { text-align: right; }
.right-float { float: right; }
.summary { border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; display: grid; gap: .4rem; }
.summary p { margin: 0; display: flex; justify-content: space-between; gap: 1rem; }
.summary .total { font-weight: 700; border-top: 1px solid var(--line); padding-top: .5rem; margin-top: .25rem; }
.sum-line { font-size: .95rem; }
.status { font-size: 1rem; }
.status-paid, .status-fulfilled { color: var(--ok); }
.status-payment_rejected { color: var(--danger); }
.pay-panel { border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem; display: grid; gap: .75rem; align-content: start; }
.instructions { background: var(--wash); padding: .8rem 1rem; border-radius: 8px; white-space: pre-line; }
.codes { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(2, 1fr); gap: .5rem; }
.codes code { font-size: 1.1rem; }
.qr { background: #fff; padding: .75rem; border: 1px solid var(--line); border-radius: var(--radius); width: fit-content; }
.qr svg { width: 220px; height: 220px; }
.secret { word-break: break-all; }

/* Admin review */
.review { margin: 1rem 0; }
.review-head { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.review-actions { display: flex; gap: 1rem; flex-wrap: wrap; align-items: end; margin-top: .5rem; }
.review-actions form { margin: 0; }
.reject-form { display: flex; gap: .6rem; align-items: end; flex-wrap: wrap; flex: 1 1 420px; }
.reject-form label { flex: 1 1 260px; }

/* Responsive */
@media (min-width: 760px) {
  .product { grid-template-columns: 1.1fr 1fr; }
  .cart-layout { grid-template-columns: 1.6fr 1fr; }
  .cart-layout > .pay-panel, .cart-layout > section:last-child { position: sticky; top: 90px; }
}
@media (max-width: 560px) {
  .row3 { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .choice small { display: none; }
}

/* Chat links band */
.chat-band { border-top: 1px solid var(--line); background: var(--wash); padding: 1.5rem 0; margin-top: 2rem; }
.chat-band h2 { margin-top: 0; }
.chat-links { display: flex; gap: .6rem; flex-wrap: wrap; margin-top: .75rem; }

/* Inbox */
.tabs { display: flex; gap: .5rem; margin: .5rem 0 1rem; }
.tabs a { padding: .4rem .9rem; border-radius: 999px; border: 1px solid var(--line); text-decoration: none; color: var(--ink); }
.tabs a.active { background: var(--ink); color: #fff; border-color: var(--ink); }
.thread-list { list-style: none; padding: 0; margin: 0; display: grid; gap: .5rem; }
.thread-row { border: 1px solid var(--line); border-radius: var(--radius); }
.thread-row a { display: grid; gap: .25rem; padding: .75rem 1rem; text-decoration: none; color: var(--ink); }
.preview { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge-whatsapp { background: #e7f8ef; color: #0b6e4f; }
.badge-telegram { background: #e6f4fb; color: #0b5c86; }
.chat-log { display: grid; gap: .6rem; margin: 1rem 0; }
.bubble { max-width: 75%; padding: .6rem .8rem; border-radius: 12px; background: var(--wash); }
.bubble-in { justify-self: start; }
.bubble-out { justify-self: end; background: #e7f3ff; }
.bubble-failed { border: 1px solid #fecdca; background: #fef3f2; }
.bubble-body { overflow-wrap: anywhere; }
.bubble-meta { color: var(--muted); margin-top: .25rem; }
.reply-form { margin-top: 1rem; }
