:root {
  --bg: #f4f7fb;
  --card: #ffffff;
  --text: #1a2332;
  --muted: #5a6b7d;
  --primary: #4293E1;
  --border: #d8e0ea;
  --shadow: 0 8px 24px rgba(26, 35, 50, 0.06);
  --wa: #128c7e;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
}
button, a { touch-action: manipulation; }

.app-top {
  position: sticky;
  top: 0;
  z-index: 40;
  background: #fff;
  border-bottom: 1px solid var(--border);
}
.app-top-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
  min-width: 0;
}
.brand img { width: 40px; height: 40px; border-radius: 10px; }
.brand strong { display: block; font-size: 0.95rem; line-height: 1.15; }
.brand small { color: var(--muted); font-size: 0.8rem; }
.top-actions { display: flex; gap: 8px; align-items: center; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
  font-size: 0.88rem;
  cursor: pointer;
}
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn[hidden] { display: none !important; }
.btn-ghost { background: transparent; }
.wa-actions { display: flex; flex-direction: column; gap: 8px; }
.btn-wa { background: var(--wa); border-color: var(--wa); color: #fff; width: 100%; min-height: 46px; }
.btn-danger { color: #9f1239; border-color: #fecdd3; background: #fff; }

.wrap {
  max-width: 1280px;
  margin: 0 auto;
  padding: 14px 14px 28px;
}
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}
.filters input[type="search"],
.filters select {
  flex: 1 1 180px;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
  background: #fff;
  color: var(--text);
}
.gb-aviso { margin: 0 0 12px; }
.gb-aviso[hidden] { display: none !important; }
.shop-edit .gb-aviso {
  border: 1px dashed #c5d0dc;
  border-radius: 12px;
  padding: 8px;
  background: rgba(66, 147, 225, 0.04);
}
.shop-edit .gb-aviso.is-over {
  border-color: var(--primary);
  background: #e8f3fc;
}
.gb-aviso-label {
  margin: 0 0 6px;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--muted);
}
.gb-aviso-hint {
  margin: 0;
  text-align: center;
  color: var(--muted);
  font-size: 0.8rem;
}
.gb-aviso-item { margin: 0 0 8px; }
.gb-aviso-item:last-child { margin-bottom: 0; }
.gb-aviso-item.is-dragging { opacity: 0.4; pointer-events: none; }
.gb-aviso-tools {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 6px;
}
.gb-aviso-tools .btn { min-height: 32px; padding: 4px 10px; font-size: 0.8rem; }
.gb-aviso-drag { cursor: grab; touch-action: none; }
.gb-aviso-slide {
  display: block;
  width: 100%;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}
.gb-aviso-slide img {
  display: block;
  width: 100%;
  height: auto;
}
.gb-aviso-admin {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}
.gb-aviso-admin h2 { margin: 0 0 6px; font-size: 1.05rem; }
.gb-aviso-admin label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 8px 0;
  font-size: 0.86rem;
  font-weight: 700;
}
.gb-aviso-admin input {
  font: inherit;
  font-weight: 500;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 10px;
}
.gb-aviso-admin-list { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.gb-aviso-row {
  display: grid;
  grid-template-columns: 140px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
}
.gb-aviso-row img { width: 140px; height: 52px; object-fit: cover; border-radius: 8px; background: #e8eef5; }
.intro { margin: 0 0 8px; color: var(--muted); font-size: 0.92rem; }
.meta-line { margin: 0 0 12px; color: var(--muted); }

.grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.grid-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
@media (min-width: 721px) {
  .grid-row { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
}
.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 16px;
}
.pager span { color: var(--muted); font-weight: 700; font-size: 0.9rem; }
.pager .btn:disabled { opacity: 0.45; cursor: default; }

.card {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  overflow: hidden;
  cursor: pointer;
  text-align: left;
  padding: 0;
  color: inherit;
  font: inherit;
  width: 100%;
}
.card-cover {
  aspect-ratio: 1 / 1;
  background: #e8eef5 center / cover no-repeat;
}
.card-cover.is-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-weight: 700;
}
.card-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  padding: 8px 8px 10px;
}
.card-sku { margin: 0 0 2px; font-size: 0.72rem; font-weight: 800; letter-spacing: 0.03em; color: #0f3d73; }
.card-body h3 { margin: 0 0 2px; font-size: 0.92rem; line-height: 1.25; }
.card-price { margin: 0 0 4px; font-size: 0.95rem; font-weight: 800; color: #0f3d73; }
.card-desc {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-actions { display: flex; flex-direction: column; gap: 6px; margin-top: auto; }
.card-quick { width: 100%; min-height: 34px; padding: 6px 8px; font-size: 0.78rem; }
.card-add {
  width: 100%;
  min-height: 36px;
  padding: 7px 8px;
  font-size: 0.78rem;
}
.empty {
  background: #fff;
  border: 1px dashed var(--border);
  border-radius: 14px;
  padding: 28px 16px;
  text-align: center;
  color: var(--muted);
}

.admin-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}
.admin-head h1 { margin: 0; font-size: 1.25rem; }
.admin-layout { display: grid; gap: 14px; }
@media (min-width: 900px) {
  .admin-layout { grid-template-columns: minmax(280px, 380px) minmax(0, 1fr); align-items: start; }
}
.product-form, .admin-item {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 14px;
}
.product-form h2 { margin: 0 0 10px; font-size: 1.05rem; }
.product-form label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 10px;
  font-size: 0.86rem;
  font-weight: 700;
}
.product-form input[type="text"],
.product-form input[type="number"],
.product-form textarea,
.product-form input[type="file"] {
  font: inherit;
  font-weight: 500;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 10px;
  background: #fff;
  color: var(--text);
}
.hint { margin: 0 0 8px; color: var(--muted); font-size: 0.82rem; }
.form-error { margin: 0 0 8px; color: #9f1239; font-weight: 700; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; }
.cover-preview {
  width: 120px;
  height: 120px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #e8eef5 center / cover no-repeat;
  margin: 0 0 10px;
}
.form-gallery, .thumbs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.thumb {
  position: relative;
  width: 72px;
  height: 72px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #e8eef5 center / cover no-repeat;
  padding: 0;
}
.thumb button, .thumb-x {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 50%;
  background: rgba(15, 23, 42, 0.78);
  color: #fff;
  cursor: pointer;
  font-size: 0.75rem;
}
.admin-list { display: flex; flex-direction: column; gap: 10px; }
.admin-item {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
}
.admin-item img, .admin-ph {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 10px;
  background: #e8eef5;
}
.admin-ph { display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 0.75rem; }
.admin-item h3 { margin: 0; font-size: 1rem; }
.admin-item p { margin: 2px 0 8px; font-weight: 800; color: #0f3d73; }
.admin-actions { display: flex; gap: 6px; flex-wrap: wrap; }

.detail-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(17, 24, 39, 0.55);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.detail-overlay[hidden] { display: none !important; }
.detail-sheet {
  background: #fff;
  width: 100%;
  max-height: 100dvh;
  overflow: auto;
  border-radius: 16px 16px 0 0;
}
.detail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: #fff;
  z-index: 1;
}
.detail-head h2 { margin: 0; font-size: 1.15rem; }
.detail-body { padding: 14px; }
.detail-cover {
  width: min(100%, 420px);
  margin: 0 auto 10px;
  aspect-ratio: 1 / 1;
  border: 0;
  border-radius: 14px;
  background: #e8eef5 center / cover no-repeat;
  display: block;
  cursor: zoom-in;
}
.detail-info .price {
  margin: 0 0 10px;
  font-size: 1.7rem;
  font-weight: 800;
  color: #0f3d73;
}
.detail-info .desc {
  margin: 0 0 14px;
  white-space: pre-wrap;
  line-height: 1.45;
  color: var(--text);
}
.detail-info .btn-primary { width: 100%; min-height: 46px; }
.detail-info .thumbs { margin-top: 0; }
@media (min-width: 860px) {
  .detail-overlay { align-items: center; padding: 24px; }
  .detail-sheet {
    max-width: 1040px;
    max-height: calc(100dvh - 48px);
    border-radius: 16px;
  }
  .detail-body {
    display: grid;
    grid-template-columns: minmax(280px, 1fr) minmax(300px, 400px);
    gap: 18px;
    align-items: start;
    padding: 16px 18px 22px;
  }
  .detail-cover { width: 100%; margin: 0 0 10px; }
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 120;
  background: rgba(8, 12, 20, 0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 64px;
}
.lightbox[hidden] { display: none !important; }
.lb-frame {
  background: #fff;
  padding: 12px;
  border-radius: 8px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
  max-width: min(920px, 100%);
  max-height: calc(100dvh - 48px);
}
.lb-frame img {
  display: block;
  max-width: 100%;
  max-height: calc(100dvh - 80px);
  object-fit: contain;
}
.lb-close, .lb-nav {
  position: absolute;
  border: 0;
  background: #fff;
  color: #111;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  font-size: 1.4rem;
  cursor: pointer;
}
.lb-close { top: 14px; right: 14px; }
.lb-prev { left: 12px; top: 50%; transform: translateY(-50%); }
.lb-next { right: 12px; top: 50%; transform: translateY(-50%); }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 140;
  background: #1a2332;
  color: #fff;
  padding: 10px 14px;
  border-radius: 10px;
  font-weight: 700;
}
.toast[hidden] { display: none !important; }

.bottom-nav {
  margin-top: 18px;
  padding: 14px 16px calc(16px + env(safe-area-inset-bottom));
  text-align: center;
  color: var(--muted);
  font-size: 0.82rem;
}
.bottom-nav a { color: var(--primary); font-weight: 700; text-decoration: none; }
.foot-copy { margin: 6px 0 0; }

@media (max-width: 640px) {
  .lightbox { padding: 56px 12px; }
  .lb-prev { left: 6px; }
  .lb-next { right: 6px; }
}

.cart-screen {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: #eef1f4;
  color: var(--text);
  display: none;
  flex-direction: column;
  min-height: 0;
}
.cart-screen.is-open { display: flex; }
.cart-top {
  position: relative;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  background: #fff;
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
}
#cart-close { position: relative; z-index: 6; pointer-events: auto; }
.cart-top h2 { margin: 0; font-size: 1.3rem; }
.cart-top p { margin: 4px 0 0; font-weight: 800; color: #0f3d73; }
.cart-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.cart-list {
  flex: 1;
  overflow: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.cart-item {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 10px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 10px;
}
.cart-item img {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 10px;
  background: #e8eef5;
}
.cart-item h3 { margin: 0; font-size: 1rem; }
.cart-item p { margin: 2px 0 8px; color: var(--muted); }
.cart-item strong { display: block; margin-top: 8px; color: #0f3d73; }
.qty { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.qty button[data-qty] {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
  font-size: 1.1rem;
  font-weight: 800;
  cursor: pointer;
}
.cart-pay {
  background: #fff;
  border-top: 1px solid var(--border);
  padding: 12px 14px calc(12px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.cart-sum { margin: 0; font-size: 1.15rem; font-weight: 800; }
@media (min-width: 860px) {
  .cart-body { flex-direction: row; }
  .cart-list { flex: 1; }
  .cart-pay {
    width: 320px;
    border-top: 0;
    border-left: 1px solid var(--border);
    justify-content: flex-start;
    padding: 18px;
  }
}
