:root {
  --bg: #f4f7fb;
  --card: #ffffff;
  --text: #1a2332;
  --muted: #5a6b7d;
  --primary: #C9A227;
  --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(201, 162, 39, 0.08);
}
.shop-edit .gb-aviso.is-over {
  border-color: var(--primary);
  background: #f7f1d8;
}
.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,
.tax-admin {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}
.tax-admin h2 { margin: 0 0 6px; font-size: 1.05rem; }
.tax-list { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
.tax-cat {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
  background: #f8fafc;
}
.tax-cat-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.tax-cat-head strong { flex: 1 1 140px; font-size: 0.95rem; }
.tax-cat-head .btn,
.tax-sub .btn { min-height: 34px; padding: 4px 10px; font-size: 0.8rem; }
.tax-subs { display: flex; flex-direction: column; gap: 6px; margin: 0; padding: 0; list-style: none; }
.tax-sub {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border-radius: 10px;
  background: #fff;
  border: 1px solid var(--border);
}
.tax-sub span { flex: 1 1 120px; font-size: 0.88rem; }
.tax-count { color: var(--muted); font-size: 0.75rem; font-weight: 700; }
.tax-empty { margin: 0; color: var(--muted); font-size: 0.88rem; }
.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 {
  position: relative;
  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-zoom {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  color: #6b4f0a;
  display: grid;
  place-items: center;
  box-shadow: 0 4px 12px rgba(26, 35, 50, 0.18);
  pointer-events: none;
}
.card-zoom svg {
  display: block;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.card-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  padding: 10px 10px 12px;
  gap: 6px;
}
.card-sku { margin: 0 0 2px; font-size: 0.72rem; font-weight: 800; letter-spacing: 0.03em; color: #6b4f0a; }
.card-name {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 800;
  line-height: 1.25;
  height: calc(1.25em * 2);
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.card-desc {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.35;
  height: calc(1.35em * 2);
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.card-foot {
  margin: auto 0 0;
  padding-top: 4px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  min-height: 1.2em;
}
.card-price {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 800;
  color: #6b4f0a;
  line-height: 1.2;
  flex: 0 0 auto;
}
.card-tax {
  margin: 0;
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--muted);
  line-height: 1.2;
  text-align: right;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  min-width: 0;
}
.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: flex;
  flex-direction: column;
  gap: 14px;
}
.product-form, .admin-item {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 14px;
}
.form-top {
  margin-bottom: 10px;
}
.product-form h2,
.form-top h2 { margin: 0; font-size: 1.05rem; }
.product-form .form-actions {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.form-grid {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.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 {
  font: inherit;
  font-weight: 500;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 10px;
  background: #fff;
  color: var(--text);
  width: 100%;
  box-sizing: border-box;
}
.file-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}
.file-label {
  font-size: 0.86rem;
  font-weight: 700;
}
.file-field .btn {
  width: 100%;
  min-height: 44px;
}
.admin-list-wrap {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 14px;
}
.admin-list-title {
  margin: 0 0 12px;
  font-size: 1.05rem;
}
@media (min-width: 900px) {
  .form-grid {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: 10px 12px;
    align-items: start;
  }
  .product-form label,
  .form-grid .file-field { margin-bottom: 0; }
  .fg-name { grid-column: span 6; }
  .fg-cost { grid-column: span 3; }
  .fg-sale { grid-column: span 3; }
  .fg-cat { grid-column: span 3; }
  .fg-sub { grid-column: span 3; }
  .fg-desc { grid-column: span 6; }
  .fg-desc textarea { min-height: 88px; max-height: 120px; resize: vertical; }
  .fg-cover { grid-column: span 3; }
  .fg-gallery { grid-column: span 3; }
  .file-field .btn { min-height: 40px; }
  .file-field .hint { margin: 0; font-size: 0.75rem; }
  .cover-preview {
    width: 72px;
    height: 72px;
    margin: 0;
  }
  .form-gallery { margin-bottom: 0; }
  .form-gallery .thumb {
    width: 48px;
    height: 48px;
  }
}
.file-field input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
  opacity: 0;
  pointer-events: none;
}
#admin-view {
  padding-bottom: calc(110px + env(safe-area-inset-bottom, 0px));
}
.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; }
.price-markup {
  display: flex !important;
  flex-direction: row !important;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  cursor: pointer;
}
.price-markup input {
  width: 18px !important;
  height: 18px;
  margin: 0;
  accent-color: var(--primary, #4293E1);
}
#f-price[readonly] {
  background: #f3f6fa;
  color: #6b4f0a;
  font-weight: 800;
}
.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; }
@media (min-width: 900px) {
  .admin-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    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 .admin-meta {
  margin: 2px 0 8px;
  font-weight: 700;
  color: #6b4f0a;
  font-size: 0.88rem;
  line-height: 1.35;
}
.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: #6b4f0a;
}
.detail-info .desc {
  margin: 0 0 14px;
  white-space: pre-wrap;
  line-height: 1.45;
  color: var(--text);
}
.detail-info .btn-primary,
.detail-info .btn-wa { width: 100%; min-height: 46px; }
.detail-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.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: #6b4f0a; }
.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: #6b4f0a; }
.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;
  }
}
