/* =========================================================
 * app.css โ€” global styles (เนเธเน design-tokens.css เน€เธเนเธ Source)
 * เธซเนเธฒเธก hardcode เธชเธตเนเธซเธกเน เนเธเน var(--*) เน€เธชเธกเธญ
 * ========================================================= */

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  min-width: 0;
}

/* ── CLS Prevention: reserve space for icons & images ── */
/* Lucide icons: <i data-lucide> → replaced by <svg> at runtime.
   Reserve the same space the SVG will occupy so layout doesn't shift. */
[data-lucide] {
  display: inline-block;
  width: 1em;
  height: 1em;
  vertical-align: -0.125em;
  flex-shrink: 0;
}
/* Honour explicit width/height from inline style */
[data-lucide][style*="width"] {
  /* width comes from inline style, just ensure height matches */
  aspect-ratio: 1;
}
/* Product images: reserve aspect ratio */
img {
  max-width: 100%;
  height: auto;
}
img[loading="lazy"] {
  content-visibility: auto;
}

html {
  overflow-y: scroll;
  background: var(--surface);
}

html,
body {
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}

body {
  font-family: var(--font-sans);
  background: var(--surface);
  color: var(--text);
  font-size: var(--fs-base);
  line-height: var(--lh-normal);
  min-height: 100vh;
}

img {
  max-width: 100%;
  display: block;
}

.img-shell {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  aspect-ratio: 1;
  background: var(--surface);
}

.img-shell::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    linear-gradient(110deg, rgba(255,255,255,0) 0%, rgba(255,255,255,.22) 38%, rgba(255,255,255,0) 72%),
    linear-gradient(180deg, rgba(255,255,255,.06), rgba(255,255,255,.02));
  transform: translateX(-120%);
  opacity: 0;
  pointer-events: none;
  z-index: 0;
}

.img-shell::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 22px;
  height: 22px;
  margin: -11px 0 0 -11px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,.25);
  border-top-color: rgba(255,255,255,.9);
  opacity: 0;
  pointer-events: none;
}

.img-shell.is-loading::before {
  opacity: 1;
  animation: img-shimmer 1.15s linear infinite;
}

.img-shell.is-loading::after {
  opacity: 1;
  animation: spin-loader .72s linear infinite;
}

.smart-img {
  opacity: 0;
  transform: scale(1.04);
  filter: blur(8px);
  transition: opacity .38s ease, transform .5s cubic-bezier(.22,.61,.36,1), filter .38s ease;
  will-change: opacity, transform, filter;
}

.smart-img.is-ready {
  opacity: 1;
  transform: scale(1);
  filter: blur(0);
}

.after-initial-load .smart-img {
  transition: none !important;
  transform: none !important;
  filter: none !important;
}

.img-shell.is-loaded::before,
.img-shell.is-error::before {
  opacity: 0;
  animation: none;
}

.img-shell.is-loaded::after,
.img-shell.is-error::after {
  opacity: 0;
  animation: none;
}

@keyframes img-shimmer {
  100% { transform: translateX(120%); }
}

@media (prefers-reduced-motion: reduce) {
  .img-shell.is-loading::before {
    animation: none;
  }

  .pcard-stage.show-skeleton.is-pending::before,
  .pcard-stage.show-skeleton.is-pending::after,
  .pcard-stage.show-skeleton.is-pending .pcard::before,
  .pcard-stage.show-skeleton.is-pending .pcard::after {
    animation: none;
  }

  .smart-img {
    transition: none;
    transform: none;
    filter: none;
  }
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

ul {
  list-style: none;
}

[x-cloak] {
  display: none !important;
}

/* Pre-reserve space for Lucide icons to prevent layout shifts during JS injection */
[data-lucide] {
  display: inline-block;
  width: 1.25em;
  /* Default proportional size */
  height: 1.25em;
  stroke-width: 2;
  stroke: currentColor;
  fill: none;
  vertical-align: -0.15em;
  /* Alignment tweak */
}

/* ===== Layout ===== */
main {
  min-height: calc(100vh - 330px);
}

.container {
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 var(--sp-4);
}

/* ===== Header (Desktop) ===== */
.topbar {
  background: var(--nav);
  color: #fff;
  font-size: var(--fs-xs);
  line-height: 1;
}

.topbar .wrap {
  max-width: var(--container);
  margin: 0 auto;
  padding: 6px var(--sp-4);
  display: flex;
  justify-content: space-between;
}

.topbar a {
  opacity: .85;
  margin-left: 14px;
  transition: color var(--dur-fast) var(--ease-out);
}

.topbar a:hover {
  opacity: 1;
  color: var(--accent);
}

/* Desktop nav sticks entirely (topbar + header) when scrolling */
.desktop-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  width: 100%;
  z-index: var(--z-nav);
}

/* Compensate for fixed desktop nav height (topbar ~32px + header ~64px) */
@media (min-width: 1024px) {
  body.has-navbar {
    padding-top: var(--desk-h, 96px);
  }
}

.header {
  background: var(--nav);
  color: #fff;
  box-shadow: var(--sh-md);
}

.header .wrap {
  max-width: var(--container);
  margin: 0 auto;
  min-height: var(--header-h);
  padding: var(--sp-2) var(--sp-4);
  display: flex;
  align-items: center;
  gap: var(--sp-4);
}

.logo {
  font-weight: var(--fw-bold);
  font-size: var(--fs-xl);
  white-space: nowrap;
}

.logo .dot {
  color: var(--accent);
}

.search {
  flex: 1;
  display: flex;
  background: #fff;
  border: 1px solid rgba(255, 255, 255, .18);
  border-radius: var(--rd-md);
  overflow: hidden;
  box-shadow: var(--sh-sm);
}

.search input {
  flex: 1;
  border: 0;
  padding: 10px var(--sp-3);
  font: inherit;
  color: var(--text);
  outline: 0;
}

.search button {
  background: var(--accent);
  color: #fff;
  padding: 0 var(--sp-4);
  font-weight: var(--fw-semibold);
  min-height: 42px;
  transition: background var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out);
}

.search button:hover {
  background: var(--accent-dark);
}

.search button:active {
  transform: translateY(1px);
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
}

.nav-actions a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--fs-sm);
}

.nav-actions a:hover {
  color: var(--accent);
}

/* ===== Mobile Top / Bottom Nav ===== */
.m-top,
.m-bottom {
  display: none;
}

@media (max-width: 1023px) {
  .desktop-only {
    display: none !important;
  }

  .m-top {
    display: flex;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--top-h);
    background: var(--nav);
    color: #fff;
    align-items: center;
    padding: 0 var(--sp-3);
    gap: var(--sp-3);
    z-index: var(--z-nav);
    box-shadow: var(--sh-md);
  }

  .m-bottom {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    height: var(--bot-h);
    background: #fff;
    border-top: 1px solid var(--border);
    padding-bottom: env(safe-area-inset-bottom);
    z-index: var(--z-nav);
  }

  .m-bottom a {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    font-size: 11px;
    color: var(--muted);
    transition: color var(--dur-fast) var(--ease-out);
  }

  .m-bottom a.active,
  .m-bottom a:hover {
    color: var(--accent);
  }

  .m-bottom i {
    font-size: 18px;
  }

  body {
    padding-top: var(--top-h);
    padding-bottom: calc(var(--bot-h) + env(safe-area-inset-bottom));
  }
}

/* ===== Cards & Buttons ===== */
.card {
  background: var(--card);
  border-radius: var(--rd-lg);
  box-shadow: var(--sh-sm);
  overflow: hidden;
}

/* removed .card:hover translate and shadow for cleanliness */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px var(--sp-5);
  border-radius: var(--rd-md);
  font-weight: var(--fw-semibold);
  font-size: var(--fs-base);
  transition: all var(--dur-fast) var(--ease-out);
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 8px 18px -14px color-mix(in srgb, var(--accent) 72%, transparent 28%);
}

.btn-primary:hover {
  background: var(--accent-dark);
}

.btn-primary:active {
  transform: translateY(1px);
}

.btn-secondary {
  background: var(--nav);
  color: #fff;
}

.btn-secondary:hover {
  background: var(--nav-2);
}

.btn-outline {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
}

.btn-outline:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

/* ===== Form ===== */
.input,
.select,
.textarea {
  width: 100%;
  padding: 10px var(--sp-3);
  border: 1px solid var(--border);
  border-radius: var(--rd-md);
  background: #fff;
  color: var(--text);
  font: inherit;
  transition: border-color var(--dur-fast) var(--ease-out);
}

.input:focus,
.select:focus,
.textarea:focus {
  outline: 0;
  border-color: var(--accent);
}

/* ===== Utility ===== */
.price {
  color: var(--danger);
  font-weight: var(--fw-bold);
}

.price-old {
  color: var(--muted);
  text-decoration: line-through;
  margin-left: 6px;
  font-size: var(--fs-xs);
}

.muted {
  color: var(--muted);
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--rd-full);
  background: var(--surface);
  font-size: var(--fs-xs);
  color: var(--text);
}

.badge-accent {
  background: var(--accent);
  color: #fff;
}

/* ===== Product grid ===== */
.grid-products {
  display: grid;
  gap: var(--sp-4);
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
}

.pcard {
  padding: var(--sp-3);
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
  isolation: isolate;
  border: 1px solid color-mix(in srgb, var(--border) 82%, #fff 18%);
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--card) 94%, #fff 6%) 0%, var(--card) 100%);
  box-shadow:
    0 8px 18px -14px color-mix(in srgb, var(--nav) 36%, transparent 64%),
    var(--sh-sm);
  transition: transform var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out);
}

.pcard::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  opacity: 0;
  background:
    radial-gradient(120% 80% at 100% 0%, color-mix(in srgb, var(--accent) 12%, transparent 88%) 0%, transparent 68%);
  transition: opacity var(--dur-fast) var(--ease-out);
}

.pcard:hover {
  transform: translateY(-5px);
  border-color: color-mix(in srgb, var(--accent) 28%, var(--border) 72%);
  box-shadow:
    0 18px 28px -20px color-mix(in srgb, var(--nav) 45%, transparent 55%),
    var(--sh-lg);
}

.pcard:hover::before {
  opacity: 1;
}

.pcard-stage {
  position: relative;
}

.pcard-stage::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: var(--rd-xl);
  background:
    linear-gradient(110deg, rgba(255,255,255,0) 0%, rgba(255,255,255,.18) 40%, rgba(255,255,255,0) 74%),
    linear-gradient(180deg, rgba(255,255,255,.05), rgba(255,255,255,.02));
  transform: translateX(-120%);
  opacity: 0;
  pointer-events: none;
  z-index: 2;
}

.pcard-stage::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 26px;
  height: 26px;
  margin: -13px 0 0 -13px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,.2);
  border-top-color: rgba(255,255,255,.95);
  opacity: 0;
  pointer-events: none;
  z-index: 3;
}

.pcard-stage.show-skeleton.is-pending::before {
  opacity: 0;
  animation: none;
}

.pcard-stage.show-skeleton.is-pending::after {
  opacity: 0;
  animation: none;
}

.pcard-stage .pcard {
  position: relative;
  transition: opacity .32s ease, transform .45s cubic-bezier(.22,.61,.36,1), filter .32s ease;
}

.pcard-stage.no-reveal-anim .pcard {
  transition: none !important;
}

.pcard-stage.is-pending .pcard {
  opacity: 0;
  transform: translateY(14px);
  filter: blur(2px);
  pointer-events: none;
}

.pcard-stage.show-skeleton.is-pending .pcard {
  opacity: 1;
  transform: none;
  filter: none;
  pointer-events: none;
  background: #f2f5fa;
  box-shadow: inset 0 0 0 1px rgba(21, 38, 67, .05);
}

.pcard-stage.show-skeleton.is-pending .pcard > * {
  visibility: hidden;
}

.pcard-stage.show-skeleton.is-pending .pcard::before,
.pcard-stage.show-skeleton.is-pending .pcard::after {
  content: '';
  position: absolute;
  left: var(--sp-3);
  right: var(--sp-3);
  border-radius: 10px;
  animation: skeleton-shimmer 1.35s linear infinite;
  z-index: 1;
}

.pcard-stage.show-skeleton.is-pending .pcard::before {
  top: var(--sp-3);
  aspect-ratio: 1/1;
  border-radius: var(--rd-md);
  background:
    linear-gradient(100deg, rgba(255,255,255,0) 0%, rgba(255,255,255,.34) 46%, rgba(255,255,255,0) 100%),
    linear-gradient(0deg, #dbe3ee 0%, #dbe3ee 100%);
  background-size: 220% 100%, 100% 100%;
  background-repeat: no-repeat;
}

.pcard-stage.show-skeleton.is-pending .pcard::after {
  bottom: 50px;
  height: 56px;
  border-radius: 8px;
  background:
    linear-gradient(100deg, rgba(255,255,255,0) 0%, rgba(255,255,255,.32) 46%, rgba(255,255,255,0) 100%),
    linear-gradient(#d2dcea 0 0),
    linear-gradient(#d2dcea 0 0),
    linear-gradient(#d2dcea 0 0);
  background-repeat: no-repeat;
  background-size: 220% 100%, 62% 12px, 88% 12px, 46% 12px;
  background-position: 0 0, 0 0, 0 22px, 0 44px;
}

.pcard-stage.is-ready .pcard {
  opacity: 1 !important;
  transform: none !important;
  filter: none !important;
  pointer-events: auto !important;
}

.pcard-stage.is-ready .pcard > * {
  visibility: visible;
}

.pcard-stage.is-ready::after {
  opacity: 0;
  animation: none;
}

.load-more-gate {
  grid-column: 1/-1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-4);
  color: var(--muted);
  font-size: var(--fs-sm);
}

.load-more-dots {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.load-more-dots .dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--muted) 72%, #fff 28%);
  animation: load-dot-bounce .75s ease-in-out infinite;
}

.load-more-dots .dot:nth-child(2) {
  animation-delay: .12s;
}

.load-more-dots .dot:nth-child(3) {
  animation-delay: .24s;
}

@keyframes load-dot-bounce {
  0%,
  80%,
  100% {
    transform: translateY(0) scale(.9);
    opacity: .45;
  }

  40% {
    transform: translateY(-4px) scale(1);
    opacity: 1;
  }
}

@keyframes skeleton-shimmer {
  from {
    background-position: 100% 0, 0 0, 0 22px, 0 44px;
  }
  to {
    background-position: -120% 0, 0 0, 0 22px, 0 44px;
  }
}

.pcard .thumb {
  aspect-ratio: 1/1;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--surface) 92%, #fff 8%) 0%, var(--surface) 100%);
  border-radius: var(--rd-lg);
  box-shadow:
    inset 0 0 0 1px color-mix(in srgb, var(--border) 70%, #fff 30%),
    inset 0 -10px 20px -18px color-mix(in srgb, var(--nav) 26%, transparent 74%);
  overflow: hidden;
  position: relative;
}

.pcard .thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform .42s cubic-bezier(.22,.61,.36,1), filter .32s ease;
}

.pcard:hover .thumb img {
  transform: scale(1.045);
  filter: saturate(1.03);
}

.pcard .name {
  font-weight: var(--fw-semibold);
  font-size: var(--fs-sm);
  line-height: 1.4;
  height: 2.8em;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  color: color-mix(in srgb, var(--text) 92%, var(--nav) 8%);
}

/* Discount badge on thumbnail */
.pcard-discount {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 1;
  background: linear-gradient(135deg, var(--danger) 0%, color-mix(in srgb, var(--danger) 74%, var(--accent) 26%) 100%);
  color: #fff;
  font-size: 11px;
  font-weight: var(--fw-bold);
  line-height: 1;
  padding: 5px 9px;
  border-radius: var(--rd-full);
  box-shadow: 0 8px 14px -10px color-mix(in srgb, var(--danger) 70%, transparent 30%);
}

/* Category tag */
.pcard-cat {
  display: inline-block;
  align-self: flex-start;
  font-size: 10px;
  font-weight: var(--fw-semibold);
  letter-spacing: .02em;
  color: color-mix(in srgb, var(--accent) 85%, var(--text) 15%);
  background: color-mix(in srgb, var(--accent) 10%, #fff 90%);
  border: 1px solid color-mix(in srgb, var(--accent) 22%, transparent 78%);
  padding: 3px 9px;
  border-radius: var(--rd-full);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

/* Short description */
.pcard-desc {
  font-size: 11px;
  color: color-mix(in srgb, var(--muted) 88%, var(--text) 12%);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin: 0;
}

/* Price row */
.pcard-price-row {
  display: flex;
  align-items: baseline;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 2px;
}

.pcard .price {
  font-size: clamp(17px, 1.2vw, 19px);
  font-weight: var(--fw-bold);
  letter-spacing: -.01em;
}

.pcard .price-old {
  font-size: 11px;
}

/* Footer: sold count + stock */
.pcard-footer {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: auto;
  min-height: 18px;
  padding-top: 6px;
  border-top: 1px dashed color-mix(in srgb, var(--border) 70%, transparent 30%);
}

.pcard-sold {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  color: var(--muted);
}

.pcard-sold i {
  color: #f59e0b;
}

.pcard-low-stock {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  color: #ef4444;
  font-weight: var(--fw-semibold);
}

/* ===== Product Detail Page (PDP) ===== */

/* Main image container */
.pdp-main-img {
  aspect-ratio: 1/1;
  background: var(--surface);
  border-radius: var(--rd-md);
  overflow: hidden;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pdp-main-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: opacity .2s;
}

.pdp-img-counter {
  position: absolute;
  bottom: 10px;
  right: 10px;
  background: rgba(0, 0, 0, .55);
  color: #fff;
  font-size: 12px;
  padding: 3px 10px;
  border-radius: var(--rd-full);
  pointer-events: none;
}

.pdp-nav-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 0;
  background: rgba(255, 255, 255, .85);
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--sh-sm);
  z-index: 2;
  opacity: 0;
  transition: opacity var(--dur-fast), background var(--dur-fast);
}

.pdp-main-img:hover .pdp-nav-arrow {
  opacity: 1;
}

.pdp-nav-arrow:hover {
  background: #fff;
}

.pdp-nav-left {
  left: 10px;
}

.pdp-nav-right {
  right: 10px;
}

/* Force SVG icon visibility inside gallery nav arrows */
.pdp-nav-arrow svg {
  display: block;
  width: 20px;
  height: 20px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

/* Discount badge */
.pdp-discount-badge {
  position: absolute;
  top: 12px;
  left: 0;
  z-index: 1;
  background: var(--danger);
  color: #fff;
  font-size: var(--fs-sm);
  font-weight: var(--fw-bold);
  line-height: 1;
  padding: 6px 12px 6px 10px;
  border-radius: 0 var(--rd-sm) var(--rd-sm) 0;
  box-shadow: 0 2px 6px rgba(239, 68, 68, .3);
}

/* Thumbnail strip */
.pdp-thumbs {
  display: flex;
  gap: 6px;
  margin-top: 8px;
  overflow-x: auto;
  padding: 4px 0;
  scrollbar-width: thin;
}

.pdp-thumb {
  width: 68px;
  height: 68px;
  border-radius: var(--rd-sm);
  object-fit: cover;
  cursor: pointer;
  flex-shrink: 0;
  border: 2px solid transparent;
  transition: border-color var(--dur-fast);
}

.pdp-thumb:hover {
  border-color: var(--accent);
}

.pdp-thumb-active {
  border-color: var(--accent) !important;
}

/* Category tag */
.pdp-cat-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  align-self: flex-start;
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  color: var(--accent);
  background: rgba(255, 107, 0, .08);
  padding: 4px 12px;
  border-radius: var(--rd-full);
  margin-bottom: var(--sp-2);
  transition: background var(--dur-fast);
}

.pdp-cat-tag:hover {
  background: rgba(255, 107, 0, .15);
  color: var(--accent);
}

/* Stats row */
.pdp-stats {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  flex-wrap: wrap;
  font-size: var(--fs-sm);
  color: var(--muted);
  margin-bottom: var(--sp-3);
  padding-bottom: var(--sp-3);
  border-bottom: 1px solid var(--border);
}

.pdp-stats span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* Price block */
.pdp-price-block {
  background: var(--surface);
  border-radius: var(--rd-md);
  padding: var(--sp-3) var(--sp-4);
  margin-bottom: var(--sp-4);
}

.pdp-save-badge {
  display: inline-block;
  padding: 2px 8px;
  background: rgba(239, 68, 68, .1);
  color: var(--danger);
  border-radius: var(--rd-full);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
}

.pdp-discount-info {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 6px;
  font-size: var(--fs-xs);
  color: var(--danger);
}

/* Stock alerts */
.pdp-stock-alert {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: var(--rd-md);
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  margin-bottom: var(--sp-3);
}

.pdp-stock-out {
  background: rgba(239, 68, 68, .08);
  color: #dc2626;
}

.pdp-stock-low {
  background: rgba(245, 158, 11, .1);
  color: #d97706;
}

.pdp-stock-medium {
  background: rgba(59, 130, 246, .06);
  color: #2563eb;
}

/* Delivery/warranty/return highlights */
.pdp-highlights {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--sp-2);
  padding: var(--sp-3) 0;
  margin-top: var(--sp-2);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.pdp-highlight-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: var(--sp-2);
}

.pdp-highlight-item div {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.pdp-highlight-item strong {
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  line-height: 1.3;
}

.pdp-highlight-item span {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.3;
}

/* Meta info */
.pdp-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-3);
  padding-top: var(--sp-3);
  font-size: var(--fs-xs);
  color: var(--muted);
}

.pdp-meta span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* Long description */
.pdp-description {
  line-height: 1.8;
  color: var(--text);
}

.pdp-description p {
  margin-bottom: var(--sp-3);
}

.pdp-description ul,
.pdp-description ol {
  margin-left: var(--sp-5);
  margin-bottom: var(--sp-3);
}

.pdp-description li {
  margin-bottom: var(--sp-1);
}

.pdp-description img {
  border-radius: var(--rd-md);
  margin: var(--sp-3) 0;
  max-width: 100%;
}

.pdp-description h3,
.pdp-description h4 {
  margin: var(--sp-4) 0 var(--sp-2);
  font-weight: var(--fw-bold);
}

.pdp-description table {
  width: 100%;
  border-collapse: collapse;
  margin: var(--sp-3) 0;
}

.pdp-description th,
.pdp-description td {
  border: 1px solid var(--border);
  padding: 8px 12px;
  text-align: left;
}

.pdp-description th {
  background: var(--surface);
  font-weight: var(--fw-semibold);
}

/* Collapsible description wrapper */
.pdp-desc-card {
  position: relative;
}

.pdp-desc-wrapper {
  position: relative;
  overflow: hidden;
}

.pdp-description {
  max-height: 20em;
  overflow: hidden;
  transition: max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.pdp-desc-expanded .pdp-description {
  max-height: 2000px !important;
}

.pdp-desc-fade {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 120px;
  background: linear-gradient(to bottom,
      rgba(255, 255, 255, 0) 0%,
      rgba(255, 255, 255, 0.6) 40%,
      rgba(255, 255, 255, 0.95) 80%,
      rgba(255, 255, 255, 1) 100%);
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.pdp-desc-toggle {
  text-align: center;
  padding-top: var(--sp-3);
}

.pdp-desc-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 28px;
  border: 1.5px solid var(--accent);
  border-radius: var(--rd-full);
  background: transparent;
  color: var(--accent);
  font-weight: var(--fw-semibold);
  font-size: var(--fs-sm);
  cursor: pointer;
  transition: all 0.25s ease;
}

.pdp-desc-btn:hover {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

.pdp-desc-btn svg {
  transition: transform 0.3s ease;
}

.pdp-desc-expanded+template+.pdp-desc-toggle .pdp-desc-btn svg,
.pdp-desc-btn:hover svg {
  /* Optional: animate chevron on hover */
}

/* ===== Lightbox ===== */
.pdp-lightbox {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: lb-in .2s ease-out;
}

@keyframes lb-in {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.pdp-lb-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, .92);
}

.pdp-lb-toolbar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  z-index: 10;
  color: #fff;
}

.pdp-lb-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 0;
  background: rgba(255, 255, 255, .12);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--dur-fast);
}

.pdp-lb-btn:hover {
  background: rgba(255, 255, 255, .25);
}

/* Force SVG icon visibility inside lightbox controls */
.pdp-lb-btn svg,
.pdp-lb-arrow svg {
  display: block;
  width: 20px;
  height: 20px;
  stroke: #fff;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

.pdp-lb-arrow svg {
  width: 28px;
  height: 28px;
}

.pdp-lb-img-wrap {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  touch-action: none;
}

.pdp-lb-img {
  max-width: 90vw;
  max-height: 80vh;
  object-fit: contain;
  transition: transform .15s ease-out;
  user-select: none;
  -webkit-user-drag: none;
}

/* LB arrows */
.pdp-lb-arrow {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 0;
  background: rgba(255, 255, 255, .12);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  transition: background var(--dur-fast);
}

.pdp-lb-arrow:hover {
  background: rgba(255, 255, 255, .25);
}

.pdp-lb-arrow-l {
  left: 16px;
}

.pdp-lb-arrow-r {
  right: 16px;
}

/* LB bottom thumbnails */
.pdp-lb-thumbs {
  position: fixed;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 6px;
  z-index: 10;
  padding: 6px 10px;
  background: rgba(0, 0, 0, .6);
  border-radius: var(--rd-md);
  overflow-x: auto;
  max-width: 90vw;
  scrollbar-width: thin;
}

.pdp-lb-thumb {
  width: 52px;
  height: 52px;
  border-radius: var(--rd-sm);
  object-fit: cover;
  cursor: pointer;
  flex-shrink: 0;
  border: 2px solid transparent;
  opacity: .6;
  transition: opacity var(--dur-fast), border-color var(--dur-fast);
}

.pdp-lb-thumb:hover {
  opacity: 1;
}

.pdp-lb-thumb-active {
  border-color: #fff !important;
  opacity: 1;
}

/* PDP mobile */
@media (max-width: 768px) {
  .pdp-highlights {
    grid-template-columns: 1fr;
    gap: var(--sp-1);
  }

  .pdp-price-block {
    padding: var(--sp-2) var(--sp-3);
  }

  .pdp-thumb {
    width: 56px;
    height: 56px;
  }

  .pdp-nav-arrow {
    opacity: 1;
    width: 32px;
    height: 32px;
  }

  .pdp-lb-arrow {
    width: 40px;
    height: 40px;
  }

  .pdp-lb-thumb {
    width: 44px;
    height: 44px;
  }

  .pdp-lb-img {
    max-width: 96vw;
    max-height: 75vh;
  }
}

/* ===== Animations ===== */
.fade-in {
  animation: fade-in var(--dur-base) var(--ease-out);
}

@keyframes fade-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

/* ===== HTMX indicator ===== */
.htmx-indicator {
  opacity: 0;
  transition: opacity var(--dur-fast) var(--ease-out);
}

.htmx-request .htmx-indicator {
  opacity: 1;
}

/* ===== Print (เธชเธณเธซเธฃเธฑเธ A4) ===== */
@media print {

  .no-print,
  .header,
  .m-top,
  .m-bottom,
  .topbar {
    display: none !important;
  }

  body {
    background: #fff;
  }

  @page {
    size: A4;
    margin: 10mm;
  }

  .print-order {
    page-break-inside: avoid;
  }
}

/* ===== Topbar layout (social left · links right) ===== */
.topbar .wrap {
  align-items: center;
}

.topbar-left,
.topbar-right {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}

.topbar-left a,
.topbar-right a,
.topbar-right .linkish {
  margin: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  color: inherit;
  border: 0;
  font: inherit;
  padding: 0;
  cursor: pointer;
  opacity: .85;
  transition: opacity var(--dur-fast) var(--ease-out), color var(--dur-fast);
}

.topbar-left a:hover,
.topbar-right a:hover,
.topbar-right .linkish:hover {
  opacity: 1;
  color: var(--accent);
}

.topbar-left i,
.topbar-right i {
  width: 14px;
  height: 14px;
}

.topbar-sep {
  opacity: .35;
}

/* ===== User menu (desktop dropdown) ===== */
.user-menu {
  position: relative;
}

.user-menu .user-drop {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  background: #fff;
  color: var(--text);
  min-width: 200px;
  border-radius: var(--rd-md);
  box-shadow: var(--sh-lg);
  padding: 4px;
  z-index: var(--z-drawer);
}

.user-drop a,
.user-drop button {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  border-radius: var(--rd-sm);
  color: var(--text);
  background: transparent;
  border: 0;
  font: inherit;
  cursor: pointer;
  text-align: left;
  font-size: var(--fs-sm);
}

.user-drop a:hover,
.user-drop button:hover {
  background: var(--surface);
  color: var(--text);
}

.user-drop i {
  width: 15px;
  height: 15px;
  color: var(--muted);
}

.user-drop .sep {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

/* ===== Search with live-suggest dropdown ===== */
.search-wrap {
  flex: 1;
  position: relative;
}

.live-suggest {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 6px);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--rd-md);
  box-shadow: var(--sh-lg);
  max-height: 420px;
  overflow: auto;
  z-index: var(--z-drawer);
}

.live-suggest-inner {
  padding: 4px;
}

.live-suggest-head {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  font-size: var(--fs-xs);
  color: var(--muted);
  font-weight: var(--fw-semibold);
}

.live-suggest-list {
  list-style: none;
  display: grid;
  gap: 2px;
}

.live-suggest-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border-radius: var(--rd-sm);
  color: var(--text);
}

.live-suggest-item:hover {
  background: var(--surface);
}

.live-suggest-thumb {
  width: 40px;
  height: 40px;
  border-radius: var(--rd-sm);
  background: var(--surface);
  overflow: hidden;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.live-suggest-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.live-suggest-meta {
  flex: 1;
  min-width: 0;
}

.live-suggest-name {
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.live-suggest-all {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px;
  margin-top: 4px;
  border-top: 1px solid var(--border);
  color: var(--accent);
  font-weight: var(--fw-semibold);
  font-size: var(--fs-sm);
}

.live-suggest-all:hover {
  background: var(--surface);
}

/* ===== Search history dropdown (YouTube-style, desktop) ===== */
.search-hist-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 6px;
  width: 100%;
  box-sizing: border-box;
  border-radius: 10px;
  transition: background .15s ease;
}
.search-hist-row:hover,
.search-hist-row:focus-within {
  background: #eceff3 !important;
}
.search-hist-link {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  padding: 9px 8px;
  font-size: var(--fs-sm);
  color: var(--text);
  text-decoration: none;
  min-width: 0;
  border-radius: 8px;
  cursor: pointer;
}
.search-hist-link:hover { color: var(--text); }
.search-hist-link span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.search-hist-del {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: none;
  border: none;
  cursor: pointer;
  color: #6b7280;
  border-radius: 50%;
  opacity: 0;
  transition: opacity .15s ease, background .15s ease, color .15s ease;
}
.search-hist-row:hover .search-hist-del,
.search-hist-row:focus-within .search-hist-del {
  opacity: 1;
}
.search-hist-del:hover { background: #e5e7eb; color: #374151; }
.search-hist-row:hover .search-hist-link svg,
.search-hist-row:focus-within .search-hist-link svg { color: var(--text); }

/* ===== Mobile search recommendations ===== */
.search-reco-mobile {
  margin-top: var(--sp-4);
  padding-top: var(--sp-4);
  border-top: 1px solid var(--border);
}

.search-reco-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--sp-3);
}

.search-reco-item {
  display: block;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 8px;
  background: #fff;
}

.search-reco-item img {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 10px;
  object-fit: cover;
  background: var(--surface);
}

.search-reco-item .meta {
  min-width: 0;
  margin-top: 8px;
}

.search-reco-item .name {
  margin: 0;
  font-size: 20px;
  font-weight: var(--fw-semibold);
  color: var(--text);
  line-height: 1.25;
  display: -webkit-box;
  line-clamp: 2;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

@media (min-width: 1024px) {
  .search-reco-mobile {
    display: none;
  }
}

/* ===== Cart badge (shared) ===== */
.cart-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: var(--rd-full);
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: var(--fw-bold);
  line-height: 1;
}

.cart-badge.is-zero {
  display: none;
}

.nav-actions .cart-badge {
  margin-left: 2px;
}

/* ===== Modal (track parcel) ===== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .55);
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-4);
}

.modal-panel {
  background: var(--card);
  border-radius: var(--rd-lg);
  box-shadow: var(--sh-xl);
  width: 100%;
  max-width: 560px;
  overflow: hidden;
  color: var(--text);
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: var(--sp-4) var(--sp-5) var(--sp-3);
  gap: var(--sp-3);
}

.modal-head h3 {
  font-size: var(--fs-lg);
  font-weight: var(--fw-bold);
}

.icon-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--rd-full);
  border: 0;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.icon-btn:hover {
  background: var(--border);
}

.icon-btn i {
  width: 16px;
  height: 16px;
}

.carrier-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: var(--sp-2);
  padding: 0 var(--sp-5) var(--sp-5);
}

.carrier-card {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--rd-md);
  color: var(--text);
  background: var(--card);
}

.carrier-card:hover {
  border-color: var(--accent);
  color: var(--text);
}

.carrier-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.carrier-name {
  flex: 1;
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
}

/* ===== Hero promo (carousel left · 2 tiles right) ===== */
.hero-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: var(--sp-4);
}

.hero-main {
  position: relative;
  border-radius: var(--rd-lg);
  overflow: hidden;
  box-shadow: var(--sh-md);
  min-height: 320px;
}

.hero-slide {
  position: absolute;
  inset: 0;
  display: block;
}

.hero-slide>.card {
  border-radius: 0;
  height: 100%;
}

.hero-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  border-radius: var(--rd-full);
  border: 0;
  background: rgba(255, 255, 255, .85);
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  box-shadow: var(--sh-sm);
}

.hero-arrow:hover {
  background: #fff;
}

.hero-arrow-l {
  left: var(--sp-3);
}

.hero-arrow-r {
  right: var(--sp-3);
}

.hero-arrow i {
  width: 18px;
  height: 18px;
}

.hero-dots {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: var(--sp-3);
  display: flex;
  gap: 6px;
  z-index: 2;
}

.hero-dots button {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 0;
  cursor: pointer;
  background: rgba(255, 255, 255, .5);
  transition: background var(--dur-fast);
}

.hero-dots button.is-active {
  background: #fff;
}

.hero-side {
  display: grid;
  grid-template-rows: 1fr 1fr;
  gap: var(--sp-4);
}

.hero-side>.card {
  display: block;
  min-height: 150px;
}

.hero-bg {
  background-size: cover !important;
  background-position: center !important;
  background-repeat: no-repeat !important;
}

.logo-img {
  width: auto;
  height: auto;
  display: block;
  border-radius: var(--rd-sm);
  background: #fff;
  padding: 3px 5px;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, .7),
    0 8px 18px -14px rgba(15, 23, 42, .24);
}

.logo-nobg {
  background: transparent !important;
  padding: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
}

.logo-wrap {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  flex: 0 0 auto;
}

/* Match top-nav logo height to search controls */
.header .logo-wrap .logo-img {
  width: auto;
  height: 44px;
}

.auth-header .logo-wrap .logo-img {
  width: 152px;
}

footer .logo .logo-img {
  width: 156px;
}

/* ===== Mobile drawer (menu) ===== */
@media (max-width: 1023px) {
  .m-top .logo-wrap .logo-img {
    width: 58px;
    padding: 2px;
  }

  .m-top .m-search {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 6px;
    background: #fff;
    border-radius: var(--rd-md);
    padding: 6px var(--sp-3);
    color: var(--text);
  }

  .m-top .m-search input {
    flex: 1;
    border: 0;
    background: transparent;
    font: inherit;
    color: var(--text);
    outline: 0;
    min-width: 0;
  }

  .m-top .m-cart {
    position: relative;
    color: #fff;
  }

  .m-cart-badge,
  .m-bot-badge {
    position: absolute;
    top: -4px;
    right: -8px;
  }

  .m-top .m-burger {
    background: transparent;
    border: 0;
    color: #fff;
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
  }

  .m-bottom a.has-badge {
    position: relative;
  }

  .m-bot-badge {
    top: 4px;
    right: calc(50% - 22px);
  }

  .m-drawer {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, .62);
    backdrop-filter: blur(2px);
    z-index: var(--z-drawer);
    display: flex;
    justify-content: flex-end;
  }

  .m-drawer-panel {
    width: min(368px, 92vw);
    height: 100%;
    background: #fff;
    color: var(--text);
    display: flex;
    flex-direction: column;
    box-shadow: var(--sh-xl);
    will-change: transform;
  }

  /* Right-side slide animation */
  .m-drawer-enter {
    transition: transform var(--dur-base) var(--ease-out);
  }

  .m-drawer-enter-start {
    transform: translateX(100%);
  }

  .m-drawer-enter-end {
    transform: translateX(0);
  }

  .m-drawer-leave {
    transition: transform var(--dur-base) var(--ease-out);
  }

  .m-drawer-leave-start {
    transform: translateX(0);
  }

  .m-drawer-leave-end {
    transform: translateX(100%);
  }

  .m-drawer-head {
    padding: 14px;
    border-bottom: 1px solid var(--border);
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 10px;
    background: linear-gradient(180deg, #fafcff 0%, #f6f8fc 100%);
    position: sticky;
    top: 0;
    z-index: 2;
  }

  .m-drawer-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-right: auto;
  }

  .m-drawer-brand .logo-img {
    width: 124px;
  }

  .m-drawer-brand-title {
    font-size: var(--fs-sm);
    font-weight: var(--fw-bold);
    line-height: 1.15;
  }

  .m-drawer-brand-sub {
    font-size: 11px;
    color: var(--muted);
    line-height: 1.2;
  }

  .m-auth-grid {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .m-auth-grid .btn {
    width: 100%;
    padding: 10px 12px;
    justify-content: center;
  }

  .m-drawer-close {
    width: 40px;
    height: 40px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text);
    background: #eef2f7;
    border: 1px solid var(--border);
    margin-left: auto;
  }

  .m-drawer-user {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    min-width: 0;
    width: 100%;
    padding: 10px 12px;
    border-radius: var(--rd-md);
    background: #fff;
    border: 1px solid var(--border);
  }

  .m-drawer-user .avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: var(--fw-bold);
  }

  .m-drawer-list {
    padding: 10px;
    overflow-y: auto;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 12px;
  }

  .m-drawer-section {
    display: flex;
    flex-direction: column;
    gap: 4px;
  }

  .m-drawer-section-title {
    font-size: 11px;
    font-weight: var(--fw-semibold);
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: .04em;
    padding: 2px 6px;
  }

  .m-quick-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
  }

  .m-quick-card {
    display: inline-flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 6px;
    min-height: 72px;
    padding: 10px 12px;
    border-radius: var(--rd-md);
    border: 1px solid var(--border);
    background: #fff;
    color: var(--text);
    font: inherit;
    text-align: left;
    cursor: pointer;
  }

  .m-quick-card i {
    width: 16px;
    height: 16px;
    color: var(--accent);
  }

  .m-quick-card span {
    font-size: 12px;
    font-weight: var(--fw-medium);
    line-height: 1.25;
  }

  .m-social-row {
    display: flex;
    gap: 10px;
    padding: 2px 0;
  }

  .m-social-row a {
    width: 40px;
    height: 40px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    background: #fff;
    color: #0f172a;
  }

  .m-social-row a i {
    width: 18px;
    height: 18px;
  }

  .m-social-row a:hover {
    background: #f8fafc;
    border-color: #d6dfec;
  }

  .m-drawer-list a:not(.m-quick-card),
  .m-drawer-list button:not(.m-quick-card) {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    width: 100%;
    padding: 11px 12px;
    border-radius: var(--rd-md);
    color: var(--text);
    background: #fff;
    border: 1px solid var(--border);
    font: inherit;
    cursor: pointer;
    text-align: left;
  }

  .m-drawer-list a:not(.m-quick-card):hover,
  .m-drawer-list button:not(.m-quick-card):hover {
    background: #f7f9fc;
    border-color: #d6dfec;
    color: var(--text);
  }

  .m-drawer-list a:not(.m-quick-card).active {
    background: #eef4ff;
    border-color: #bfd3ff;
    color: #1e40af;
  }

  .m-drawer-list i {
    width: 18px;
    height: 18px;
    color: var(--muted);
  }

  .m-drawer-list .sep {
    height: 1px;
    background: var(--border);
    margin: 4px 0;
  }

  /* Hero responsive */
  .hero-grid {
    grid-template-columns: 1fr;
  }

  .hero-main {
    min-height: 220px;
  }

  .hero-side {
    grid-template-rows: auto;
    grid-template-columns: 1fr 1fr;
  }

  .hero-side>.card {
    min-height: 110px;
  }
}

@media (max-width: 520px) {
  .carrier-grid {
    grid-template-columns: 1fr 1fr;
  }
}

/* ===== Category horizontal scroller ===== */
.cat-row-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  margin-bottom: var(--sp-3);
}

.cat-row-arrows {
  display: flex;
  gap: 6px;
}

.cat-track {
  display: flex;
  gap: var(--sp-3);
  overflow-x: auto;
  scroll-behavior: smooth;
  scroll-snap-type: x mandatory;
  padding: 4px 2px 8px;
  scrollbar-width: none;
}

.cat-track::-webkit-scrollbar {
  display: none;
}

.cat-item {
  flex: 0 0 auto;
  scroll-snap-align: start;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: 118px;
  padding: var(--sp-3) 6px;
  color: var(--text);
  text-align: center;
  border-bottom: 2px solid transparent;
  transition: border-color var(--dur-fast) var(--ease-out), color var(--dur-fast);
}

.cat-item:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.cat-icon {
  width: 78px;
  height: 78px;
  border-radius: var(--rd-full);
  background: var(--card);
  color: var(--nav);
  border: 1px solid var(--border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background var(--dur-fast), color var(--dur-fast), border-color var(--dur-fast), transform var(--dur-fast);
}

.cat-icon-has-img {
  padding: 0;
  overflow: hidden;
  background: var(--surface);
}

.cat-icon-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.cat-icon i,
.cat-icon svg {
  width: 38px;
  height: 38px;
}

.cat-item:hover .cat-icon {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.cat-item:hover .cat-icon-has-img {
  background: var(--surface);
  color: inherit;
}

.cat-name {
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  line-height: 1.3;
}

/* ===== Markdown content ===== */
.static-md-wrap {
  max-width: 760px;
}

.static-md-wrap > h1 {
  font-size: var(--fs-2xl);
  font-weight: 700;
  margin-bottom: var(--sp-4);
}

.md-content {
  color: var(--text);
  line-height: 1.78;
  font-size: 15px;
}

.md-content > *:first-child {
  margin-top: 0;
}

.md-content > *:last-child {
  margin-bottom: 0;
}

.md-content p,
.md-content ul,
.md-content ol,
.md-content blockquote,
.md-content pre,
.md-content hr {
  margin: 0 0 var(--sp-3);
}

.md-content h1,
.md-content h2,
.md-content h3,
.md-content h4,
.md-content h5,
.md-content h6 {
  margin: var(--sp-4) 0 var(--sp-2);
  font-weight: 700;
  line-height: 1.35;
  color: var(--text);
}

.md-content h2 {
  font-size: var(--fs-xl);
}

.md-content h3 {
  font-size: var(--fs-lg);
}

.md-content ul,
.md-content ol {
  padding-left: 1.2rem;
}

.md-content li {
  margin: 0 0 6px;
}

.md-content a {
  color: var(--primary);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.md-content code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, Liberation Mono, monospace;
  font-size: .92em;
  background: #eef2ff;
  padding: 1px 5px;
  border-radius: 6px;
}

.md-content pre {
  overflow-x: auto;
  background: #0f172a;
  color: #e2e8f0;
  border-radius: var(--rd-md);
  padding: var(--sp-3);
}

.md-content pre code {
  background: transparent;
  color: inherit;
  padding: 0;
}

.md-content blockquote {
  border-left: 3px solid var(--accent);
  padding: 4px 0 4px 12px;
  color: var(--muted);
}

.md-content hr {
  border: 0;
  border-top: 1px solid var(--border);
}

/* Desktop: Horizontal scroller with premium cards */
@media (min-width: 1024px) {
  .cat-row-arrows {
    display: flex;
  }

  .cat-track {
    display: flex;
    gap: var(--sp-4);
    overflow-x: auto;
    scroll-behavior: smooth;
    scroll-snap-type: x mandatory;
    padding: var(--sp-2) 2px 20px;
    /* space for shadow */
    scrollbar-width: none;
  }

  .cat-track::-webkit-scrollbar {
    display: none;
  }

  .cat-item {
    flex: 0 0 196px;
    /* Fixed card width for scroller */
    scroll-snap-align: start;
    padding: var(--sp-4) var(--sp-3);
    gap: 14px;
    border: 1px solid var(--border);
    border-radius: var(--rd-lg);
    background: var(--card);
    box-shadow: 0 1px 3px rgba(0, 0, 0, .05);
    transition: all var(--dur-base) var(--ease-out);
  }

  .cat-item:hover {
    color: var(--accent);
    border-color: var(--accent);
    background: linear-gradient(135deg, rgba(255, 107, 0, .03) 0%, rgba(79, 70, 229, .06) 100%);
    box-shadow: 0 4px 16px rgba(79, 70, 229, .12);
  }

  .cat-icon {
    width: 96px;
    height: 96px;
  }

  .cat-icon i,
  .cat-icon svg {
    width: 46px;
    height: 46px;
  }

  /* removed .cat-item hover lift and scale */
  .cat-name {
    font-size: var(--fs-sm);
  }
}

@media (max-width: 1023px) {
  .cat-row-arrows {
    display: none;
  }

  .cat-item {
    width: 112px;
    /* Fixed width to match longest text */
    flex: 0 0 112px;
    padding: var(--sp-2) 4px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--rd-md);
    box-shadow: var(--sh-sm);
  }
}

/* =========================================================
 * Mobile fine-tuning (<=768px) — keep original tokens, fix fit
 * ========================================================= */
@media (max-width: 1023px) {

  /* Tighter page gutter so content fits phone widths */
  .container {
    padding: 0 var(--sp-3);
  }

  /* Hero carousel: full-width on phone, smaller paddings/fonts */
  .hero-grid {
    gap: var(--sp-3);
  }

  .hero-main {
    min-height: 180px;
    border-radius: var(--rd-md);
    touch-action: pan-y;
  }

  .hero-slide>.card {
    padding: var(--sp-4) var(--sp-4);
    gap: 6px;
  }

  .hero-slide h2 {
    font-size: var(--fs-lg) !important;
  }

  .hero-slide p {
    font-size: var(--fs-sm) !important;
  }

  .hero-slide .btn {
    padding: 8px var(--sp-4);
    font-size: var(--fs-sm);
  }

  .hero-arrow {
    display: none;
  }

  .hero-dots {
    bottom: 8px;
  }

  .hero-side {
    gap: var(--sp-3);
  }

  .hero-side>.card {
    padding: var(--sp-3) !important;
    min-height: 96px;
    border-radius: var(--rd-md);
  }

  .hero-side>.card>div>div:first-child {
    font-size: var(--fs-base) !important;
  }

  .hero-side>.card>div>div:last-child {
    font-size: var(--fs-xs) !important;
  }

  /* Section headings */
  section.fade-in {
    gap: var(--sp-6) !important;
  }

  section.fade-in h2 {
    font-size: var(--fs-lg) !important;
  }

  /* Product grid: 2 cols on phone, breathable */
  .grid-products {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--sp-3);
  }

  .pcard {
    padding: var(--sp-2);
    gap: 4px;
    border-radius: var(--rd-md);
    box-shadow: var(--sh-sm);
  }

  .pcard::before {
    display: none;
  }

  .pcard .name {
    font-size: var(--fs-xs);
    line-height: 1.35;
    height: 2.7em;
  }

  .pcard .price {
    font-size: var(--fs-sm);
  }

  .pcard .price-old {
    font-size: 10px;
  }

  .pcard-desc {
    display: none;
  }

  .pcard-cat {
    font-size: 9px;
    padding: 1px 6px;
  }

  .pcard-discount {
    font-size: 10px;
    padding: 3px 6px 3px 4px;
    top: 6px;
  }

  .pcard-sold {
    font-size: 10px;
  }

  .pcard-low-stock {
    font-size: 10px;
  }

  /* Category row: smaller icons and names */
  .cat-row-head {
    margin-bottom: var(--sp-2);
  }

  .cat-track {
    gap: var(--sp-2);
    padding: 4px 6px 12px;
  }

  .cat-item {
    width: 118px;
    /* Optimized for mobile screens */
    flex: 0 0 118px;
    padding: var(--sp-3) 4px;
    gap: 6px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--rd-md);
    box-shadow: var(--sh-sm);
  }

  .cat-icon {
    width: 58px;
    height: 58px;
    border: 0;
    background: var(--surface);
  }

  .cat-icon i,
  .cat-icon svg {
    width: 28px;
    height: 28px;
  }

  .cat-name {
    font-size: 10px;
    line-height: 1.2;
  }

  /* Mobile top bar: make logo + search + cart + burger fit nicely */
  .m-top {
    gap: var(--sp-2);
    padding: 0 var(--sp-2);
  }

  .m-top .logo {
    font-size: var(--fs-base) !important;
  }

  .m-top .m-search {
    padding: 6px var(--sp-2);
  }

  .m-top .m-search input {
    font-size: var(--fs-sm);
  }

  .m-top .m-cart i,
  .m-top .m-burger i {
    width: 20px !important;
  }

  /* Live-suggest dropdown: match phone width */
  .live-suggest {
    max-height: 60vh;
  }

  /* Modal: fuller width on phone */
  .modal-panel {
    max-width: 100%;
    border-radius: var(--rd-md);
  }

  .modal-head {
    padding: var(--sp-3) var(--sp-4) var(--sp-2);
  }

  .carrier-grid {
    padding: 0 var(--sp-4) var(--sp-4);
  }

  /* Page-level spacing */
  main.container {
    padding-top: var(--sp-4) !important;
    padding-bottom: var(--sp-8) !important;
  }
}

/* Very small phones (iPhone SE etc.) */
@media (max-width: 400px) {
  .m-top .logo {
    display: inline-flex;
  }

  .m-top .logo-wrap .logo-img {
    width: 42px;
  }

  .cat-item {
    min-width: 94px;
  }

  .cat-icon {
    width: 52px;
    height: 52px;
  }

  .cat-icon i,
  .cat-icon svg {
    width: 24px;
    height: 24px;
  }

  .hero-main {
    min-height: 160px;
  }

  .hero-slide h2 {
    font-size: var(--fs-base) !important;
  }
}

/* ===== Auth Split Layout (Shopee Style) ===== */
.auth-layout {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
}

.auth-header {
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: var(--sp-4) 0;
  z-index: 10;
}

.auth-header .wrap {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--sp-4);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.auth-header .logo-group {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
}

.auth-header .auth-title {
  font-size: var(--fs-xl);
  font-weight: var(--fw-semibold);
  color: var(--text);
  border-left: 1px solid var(--border);
  padding-left: var(--sp-4);
}

.auth-main {
  flex: 1;
  background-color: var(--nav);
  background-image: 
    radial-gradient(circle at 10% 20%, rgba(16, 185, 129, 0.1) 0%, transparent 40%),
    radial-gradient(circle at 90% 80%, rgba(59, 130, 246, 0.1) 0%, transparent 40%);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
}

.auth-split {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: var(--sp-8) var(--sp-4);
  display: grid;
  grid-template-columns: 1fr 420px;
  gap: var(--sp-12);
  align-items: center;
}

.auth-main {
  flex: 1;
  background-color: var(--surface); /* Clean light background */
  background-image: 
    radial-gradient(at 0% 0%, rgba(16, 185, 129, 0.05) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(59, 130, 246, 0.05) 0px, transparent 50%);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  position: relative;
  overflow: hidden;
}

.auth-main::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%2310B981' fill-opacity='0.03'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
  pointer-events: none;
}

.auth-hero {
  color: var(--text) !important;
  padding-right: var(--sp-8);
}

.auth-hero .hero-logo-large {
  width: 280px;
  height: auto;
  margin-bottom: var(--sp-8);
  filter: none !important;
  border-radius: var(--rd-md);
  box-shadow: 0 16px 36px -28px rgba(15, 23, 42, .22);
}

.auth-hero h2 {
  font-size: 42px;
  font-weight: var(--fw-bold);
  line-height: 1.1;
  margin-bottom: var(--sp-8);
  color: var(--nav) !important;
  background: none !important;
  -webkit-text-fill-color: initial !important;
  letter-spacing: -0.02em;
}

.auth-hero h2 span {
  color: var(--accent);
}

.auth-hero p {
  font-size: var(--fs-xl);
  color: var(--muted) !important;
  opacity: 0.9 !important;
  max-width: 460px;
  line-height: 1.8;
}

.auth-form-side {
  width: 100%;
}

.auth-card {
  background: #fff;
  border-radius: var(--rd-2xl);
  box-shadow: 
    0 10px 15px -3px rgba(0, 0, 0, 0.04), 
    0 4px 6px -2px rgba(0, 0, 0, 0.02),
    inset 0 0 0 1px rgba(0,0,0,0.02);
  padding: var(--sp-10) var(--sp-12);
  border-top: 0 !important;
  position: relative;
  z-index: 10;
}

.auth-card h1 {
  font-size: var(--fs-2xl);
  font-weight: var(--fw-bold);
  margin-bottom: var(--sp-8);
  color: var(--nav);
}

.auth-footer {
  background: var(--surface);
  padding: var(--sp-12) 0;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: var(--fs-sm);
}

.auth-footer .wrap {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--sp-4);
}

/* Universal Underline style for inputs on all Auth pages */
.auth-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--border) !important;
  margin-bottom: var(--sp-4) !important;
  background: transparent !important;
  transition: border-color var(--dur-base) ease;
}

.auth-input-wrapper:focus-within {
  border-color: var(--accent) !important;
}

.auth-input-wrapper i {
  position: absolute;
  left: 8px !important;
  width: 18px;
  height: 18px;
  color: var(--nav) !important;
  opacity: 0.8;
  pointer-events: none;
  z-index: 2;
}

.auth-input-wrapper .input {
  border: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  border-radius: 0 !important;
  padding-left: 22px !important;
  padding-right: 48px !important;
  height: 48px !important;
}

/* Password toggle in auth */
.pass-toggle {
  position: absolute;
  right: 12px;
  color: var(--muted);
  cursor: pointer;
  background: none;
  border: none;
  padding: 4px;
  display: flex;
  align-items: center;
}

/* Mobile specific auth header */
.auth-m-header {
  display: none; /* Desktop hidden */
}

/* Mobile branding is hidden by default (desktop) */
.auth-mobile-branding {
  display: none !important;
}

@media (max-width: 1023px) {
  body:not(.has-navbar) {
    padding-top: 0 !important;
  }

  .auth-m-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--sp-3) var(--sp-4);
    background: #fff;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
  }
  
  .auth-m-header h1 {
    font-size: var(--fs-lg);
    font-weight: var(--fw-semibold);
    color: var(--text);
    margin: 0;
  }

  .auth-m-header .icon-link {
    color: var(--text);
    display: flex;
    align-items: center;
    padding: 4px;
    text-decoration: none;
  }

  /* Center branding for mobile */
  .auth-mobile-branding {
    display: flex !important; /* Force visible on mobile */
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--sp-12) 0 var(--sp-4) !important;
    background: #fff;
    width: 100%;
  }

  .auth-mobile-branding .m-logo {
    width: 200px !important;
    height: auto;
  }

  .auth-header {
    display: none !important;
  }

  .auth-layout {
    background: #fff !important;
  }

  .auth-main {
    background: #fff !important;
    padding: 0;
  }

  .auth-main::before {
    display: none !important;
  }

  .auth-split {
    grid-template-columns: 1fr;
    gap: 0;
    padding: 0;
  }
  
  .auth-hero {
    display: none;
  }

  .auth-form-side {
    max-width: 100%;
    margin: 0;
    padding: 0;
  }

  .auth-card {
    padding: 0 var(--sp-8) var(--sp-12) !important;
    border: 0 !important;
    border-top: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    background: #fff !important;
  }
  
  /* Stack password fields on mobile */
  .auth-card > form > div[style*="grid-template-columns: 1fr 1fr"] {
    grid-template-columns: 1fr !important;
    gap: 0 !important;
  }
  
  .auth-footer {
    display: none;
  }
}

/* Ensure no background leak on mobile auth */
@media (max-width: 1023px) {
  body:not(.has-navbar) {
    background-color: #fff !important;
  }
}
/* ===== Recently Viewed =====*/
.rv-section{margin-top:var(--sp-6);}
.rv-section .section-title{font-size:var(--fs-xl);font-weight:700;margin-bottom:var(--sp-3);}
.rv-track > .pcard-stage{flex:0 0 190px;scroll-snap-align:start;}
.rv-track > .pcard-stage .pcard{height:100%;}
@media(min-width:1024px){.rv-track > .pcard-stage{flex:0 0 210px;}}

/* ===== Admin Workspace System ===== */
.admin-body {
  margin: 0;
  background: #f4f7fb;
  color: #0f172a;
}

.admin-app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px 1fr;
}

.admin-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  z-index: 80;
}

.admin-sidebar {
  position: sticky;
  top: 0;
  max-height: 100vh;
  overflow: auto;
  padding: 18px 14px;
  background: linear-gradient(180deg, #0f172a 0%, #13233d 100%);
  color: #e2e8f0;
  border-right: 1px solid rgba(148, 163, 184, 0.16);
  z-index: 90;
}

.admin-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 8px 14px;
}

.admin-brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  color: #fff;
  background: linear-gradient(145deg, #1d4ed8 0%, #0f3eb8 100%);
}

.admin-brand-title {
  font-size: 15px;
  font-weight: 800;
  line-height: 1.2;
}

.admin-brand-sub {
  font-size: 12px;
  color: #93c5fd;
}

.admin-nav {
  display: grid;
  gap: 4px;
  margin-top: 6px;
}

.admin-nav-item {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 9px 11px;
  border-radius: 10px;
  color: #cbd5e1;
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
}

.admin-nav-item:hover {
  background: rgba(148, 163, 184, 0.14);
  color: #fff;
}

.admin-nav-item.is-active {
  background: linear-gradient(145deg, #1b49ff 0%, #0a237e 100%);
  color: #fff;
}

.admin-nav-icon {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
}

.admin-user-box {
  margin-top: 14px;
  border-top: 1px solid rgba(148, 163, 184, 0.2);
  padding: 12px 10px 0;
}

.admin-user-name {
  font-size: 13px;
  font-weight: 700;
}

.admin-user-email {
  margin-top: 2px;
  font-size: 12px;
  color: #94a3b8;
  word-break: break-all;
}

.admin-logout-form {
  margin-top: 10px;
  padding: 0 8px;
}

.admin-logout-btn {
  width: 100%;
  justify-content: center;
  border-color: rgba(148, 163, 184, 0.45);
  color: #e2e8f0;
  background: rgba(30, 41, 59, 0.45);
}

.admin-main {
  min-width: 0;
}

.admin-main-top {
  position: sticky;
  top: 0;
  z-index: 40;
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 18px;
  background: rgba(244, 247, 251, 0.95);
  border-bottom: 1px solid #d8e1ec;
  backdrop-filter: blur(8px);
}

.admin-menu-btn {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: 1px solid #cbd5e1;
  background: #fff;
  display: none;
  align-items: center;
  justify-content: center;
  color: #0f172a;
}

.admin-main-top-title {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #475569;
}

.admin-main-top-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 6px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 999px;
  background: #fff;
  color: #0f172a;
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
}

.admin-content-wrap {
  padding: 18px;
  display: grid;
  gap: 14px;
}

.admin-flash {
  min-height: 44px;
  border-radius: 12px;
  padding: 10px 13px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
}

.admin-flash-success {
  background: #dcfce7;
  color: #065f46;
  border: 1px solid #86efac;
}

.admin-flash-error {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fca5a5;
}

.admin-body .admin-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}

.admin-body .admin-top h1 {
  margin: 0;
  font-size: clamp(1.12rem, 2.2vw, 1.52rem);
  font-weight: 800;
  line-height: 1.2;
}

.admin-body .card {
  border-radius: 14px;
  border: 1px solid #d8e1ec;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
}

.admin-body table {
  width: 100%;
  min-width: 680px;
  border-collapse: collapse;
}

.admin-body .card[style*="overflow:auto"],
.admin-body .card[style*="overflow: auto"] {
  overflow: auto !important;
}

.admin-body th,
.admin-body td {
  vertical-align: middle;
}

.admin-body .input,
.admin-body .textarea,
.admin-body .select,
.admin-body select.input {
  min-height: 40px;
}

.admin-body .textarea {
  min-height: 110px;
}

.admin-body .btn {
  min-height: 38px;
  align-items: center;
  justify-content: center;
}

.admin-body .btn.btn-danger {
  background: #b91c1c;
  border-color: #b91c1c;
  color: #fff;
}

.admin-body .btn.btn-danger:hover {
  background: #991b1b;
  border-color: #991b1b;
}

@media (max-width: 1180px) {
  .admin-app {
    grid-template-columns: 1fr;
  }

  .admin-sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: min(86vw, 320px);
    transform: translateX(-105%);
    transition: transform .18s ease;
  }

  .admin-sidebar.is-open {
    transform: translateX(0);
  }

  .admin-menu-btn {
    display: inline-flex;
  }
}

@media (max-width: 960px) {
  .admin-content-wrap {
    padding: 14px;
  }

  .admin-main-top {
    padding: 0 12px;
  }

  .admin-main-top-link {
    font-size: 12px;
    padding: 6px 9px;
  }

  .admin-body [style*="grid-template-columns:2fr 1fr"],
  .admin-body [style*="grid-template-columns: 2fr 1fr"],
  .admin-body [style*="grid-template-columns:1fr 1fr"],
  .admin-body [style*="grid-template-columns: 1fr 1fr"],
  .admin-body [style*="grid-template-columns:repeat(4,1fr)"],
  .admin-body [style*="grid-template-columns: repeat(4,1fr)"],
  .admin-body [style*="grid-template-columns:repeat(7,1fr)"],
  .admin-body [style*="grid-template-columns: repeat(7,1fr)"] {
    grid-template-columns: 1fr !important;
  }

  .admin-body form[style*="display:flex"] {
    flex-wrap: wrap !important;
  }

  .admin-body form[style*="display:flex"] > * {
    flex: 1 1 100%;
  }
}

@media (max-width: 680px) {
  .admin-main-top-title {
    display: none;
  }

  .admin-main-top-link {
    min-height: 32px;
    padding: 4px 8px;
  }

  .admin-body .admin-top {
    gap: 8px;
  }

  .admin-body .card {
    border-radius: 12px;
  }

  .admin-body table {
    min-width: 620px;
  }
}

@media print {
  .admin-main-top,
  .admin-sidebar,
  .admin-overlay,
  .no-print {
    display: none !important;
  }

  .admin-app {
    display: block !important;
  }

  .admin-content-wrap {
    padding: 0 !important;
  }
}

/* Static Content Workspace */
.admin-body .static-workspace-grid {
  min-width: 0;
}

.admin-body .static-page-list {
  max-height: calc(100vh - 110px);
  overflow: auto;
}

@media (max-width: 1080px) {
  .admin-body .static-workspace-grid {
    grid-template-columns: 1fr !important;
  }

  .admin-body .static-page-list {
    position: static !important;
    max-height: none;
  }
}

/* Orders admin responsive helpers */
.admin-body .orders-filter-grid {
  min-width: 0;
}

@media (max-width: 1080px) {
  .admin-body .orders-filter-grid {
    grid-template-columns: 1fr 1fr !important;
  }
}

@media (max-width: 720px) {
  .admin-body .orders-filter-grid {
    grid-template-columns: 1fr !important;
  }

  .admin-body .order-kpi-grid {
    grid-template-columns: 1fr 1fr !important;
  }
}

/* ===================================================
   Flash Sale � badge, countdown, price styles
   =================================================== */
.pcard--flash {
  outline: 2px solid #f97316;
  outline-offset: -2px;
}
.pcard-flash-badge {
  position: absolute;
  top: 8px; left: 8px;
  background: linear-gradient(135deg, #ef4444 0%, #f97316 100%);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .04em;
  padding: 2px 7px;
  border-radius: 20px;
  display: flex;
  align-items: center;
  gap: 3px;
  z-index: 2;
  box-shadow: 0 1px 6px rgba(239,68,68,.35);
  animation: flash-pulse 1.6s ease-in-out infinite;
}
@keyframes flash-pulse {
  0%,100% { opacity: 1; }
  50%      { opacity: .78; }
}
.price--flash {
  color: #ef4444 !important;
  font-weight: 800 !important;
}
.flash-countdown {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(239,68,68,.12);
  color: #ef4444;
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  padding: 2px 6px;
  border-radius: 6px;
  border: 1px solid rgba(239,68,68,.25);
  margin-top: 4px;
  letter-spacing: .02em;
}

/* PDP flash bar */
.pdp-flash-bar {
  background: linear-gradient(135deg, #ef4444 0%, #f97316 100%);
  border-radius: var(--rd-md);
  padding: var(--sp-3) var(--sp-4);
  margin-bottom: var(--sp-3);
}
.pdp-flash-bar .flash-countdown {
  background: rgba(255,255,255,.2);
  color: #fff;
  border-color: rgba(255,255,255,.35);
  font-size: 13px;
}
.pdp-flash-bar .price-old {
  color: rgba(255,255,255,.7);
  text-decoration: line-through;
}
.pdp-flash-bar .pdp-save-badge {
  background: rgba(255,255,255,.25);
  color: #fff;
}

/* ========== UX: Quick-add button on product cards ========== */
.pcard-quick-add {
  position: absolute;
  right: 8px;
  bottom: 8px;
  z-index: 3;
  width: 38px;
  height: 38px;
  min-width: 38px;
  border-radius: 999px;
  border: 0;
  background: var(--accent);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow:
    0 8px 20px -8px color-mix(in srgb, var(--accent) 55%, transparent 45%),
    0 2px 4px rgba(0,0,0,.12);
  transition: transform .18s var(--ease-out), box-shadow .18s var(--ease-out), background-color .18s var(--ease-out), opacity .18s ease;
  opacity: 0;
  transform: translateY(6px) scale(.9);
  pointer-events: none;
}
.pcard-stage.is-pending .pcard-quick-add { visibility: hidden; }
.pcard-quick-add:focus-visible {
  opacity: 1;
  transform: none;
  pointer-events: auto;
  outline: 2px solid #fff;
  outline-offset: 2px;
}
.pcard:hover .pcard-quick-add,
.pcard-stage:focus-within .pcard-quick-add {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}
.pcard-quick-add:hover {
  background: color-mix(in srgb, var(--accent) 88%, #000 12%);
  transform: translateY(-2px) scale(1.06);
  box-shadow:
    0 14px 24px -10px color-mix(in srgb, var(--accent) 65%, transparent 35%),
    0 3px 6px rgba(0,0,0,.15);
}
.pcard-quick-add:active {
  transform: scale(.94);
}
.pcard-quick-add.is-busy {
  pointer-events: none;
  opacity: 1;
}
.pcard-quick-add.is-busy i { display: none; }
.pcard-quick-add.is-busy::after {
  content: '';
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: ui-spin .7s linear infinite;
}
.pcard-quick-add.is-done {
  background: #16a34a;
  opacity: 1;
  transform: none;
  pointer-events: auto;
}
.pcard-quick-add.is-done i { display: inline-flex; }
/* Always show on touch / small screens (no hover) */
@media (hover: none), (max-width: 640px) {
  .pcard-quick-add {
    opacity: 1;
    transform: none;
    pointer-events: auto;
    width: 34px;
    height: 34px;
    min-width: 34px;
  }
}

/* Cart-bump micro-animation on the nav cart badge when count increases */
@keyframes cart-bump {
  0%   { transform: scale(1); }
  30%  { transform: scale(1.3); }
  60%  { transform: scale(.92); }
  100% { transform: scale(1); }
}
.cart-badge.is-bumping {
  animation: cart-bump .45s var(--ease-out);
}

/* ========== UX: Back-to-top button ========== */
.back-to-top {
  position: fixed;
  right: 16px;
  bottom: 88px; /* above mobile bottom nav */
  z-index: 40;
  width: 44px;
  height: 44px;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--border) 70%, transparent 30%);
  background: var(--card);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 10px 24px -10px rgba(0,0,0,.25), 0 2px 4px rgba(0,0,0,.08);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity .2s var(--ease-out), transform .2s var(--ease-out), background-color .15s ease;
}
.back-to-top.is-visible {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}
.back-to-top:hover {
  background: color-mix(in srgb, var(--accent) 10%, var(--card) 90%);
  color: var(--accent);
}
@media (min-width: 1024px) {
  .back-to-top { bottom: 24px; right: 24px; }
}

/* ========== UX: Skip to main content ========== */
.skip-to-content {
  position: absolute;
  left: 12px;
  top: 12px;
  z-index: 1000;
  padding: 10px 16px;
  background: var(--accent);
  color: #fff;
  border-radius: var(--rd-md);
  font-weight: 600;
  text-decoration: none;
  transform: translateY(-200%);
  transition: transform .15s ease-out;
}
.skip-to-content:focus {
  transform: translateY(0);
  outline: 2px solid #fff;
  outline-offset: 2px;
}

/* ========== UX: Better keyboard focus rings across the site ========== */
a:focus-visible,
button:focus-visible,
[role="button"]:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}
.pcard:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
