/* ============================================
   同人誌小商城 — 前台（客人）＋後台共用樣式
   手機優先（客人幾乎都從手機掃碼進來）
   ============================================ */
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  background: #faf7f4;
  color: #3a3230;
  line-height: 1.6;
}
img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }

.wrap { max-width: 860px; margin: 0 auto; padding: 16px; }
.wrap.narrow { max-width: 640px; }

/* ---- 首頁 Banner ---- */
.banner { margin: 4px 0 14px; }
.banner img {
  width: 100%; border-radius: 14px;
  box-shadow: 0 2px 10px rgba(90, 60, 40, 0.14);
}
.banner-preview { max-width: 320px; }

/* ---- Banner 線上裁切 ---- */
.crop-tip { font-size: 13px; color: #96887f; margin-bottom: 8px; }
.crop-box { max-height: 340px; overflow: hidden; background: #efe8e1; border-radius: 8px; margin-bottom: 10px; }
.crop-box img { max-width: 100%; display: block; }
.crop-actions { display: flex; gap: 8px; margin-bottom: 12px; }

/* ---- 前台頁首 ---- */
.shop-head {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 0 16px;
}
.shop-head h1 { font-size: 20px; flex: 1; }
.shop-head .back { font-size: 14px; color: #a0674b; }
.order-lookup {
  font-size: 13px; color: #a0674b;
  border: 1px solid #e3c9ba; border-radius: 16px; padding: 4px 12px;
}
.notice {
  background: #fff3e8; border: 1px solid #f0d9c4; border-radius: 10px;
  padding: 10px 14px; font-size: 14px; margin-bottom: 16px; color: #7a5540;
}
.empty { text-align: center; color: #a89a92; padding: 48px 0; font-size: 14px; }

/* ---- 商品卡片格 ---- */
.grid {
  display: grid; gap: 14px;
  grid-template-columns: repeat(2, 1fr);
}
@media (min-width: 640px) { .grid { grid-template-columns: repeat(3, 1fr); } }
.card {
  background: #fff; border-radius: 12px; overflow: hidden;
  box-shadow: 0 1px 4px rgba(90, 60, 40, 0.08);
  transition: transform 0.12s;
}
.card:active { transform: scale(0.98); }
.card.sold-out .cover img { filter: grayscale(0.8) brightness(0.9); }
.cover { position: relative; aspect-ratio: 3 / 4; background: #f0e8e2; }
.cover img { width: 100%; height: 100%; object-fit: cover; }
.no-cover {
  width: 100%; height: 100%; display: flex; align-items: center; justify-content: center;
  color: #c4b2a6; font-size: 13px;
}
.badge-type {
  position: absolute; left: 8px; top: 8px;
  background: rgba(160, 103, 75, 0.92); color: #fff;
  font-size: 11px; padding: 2px 8px; border-radius: 10px;
}
.badge-soldout {
  position: absolute; right: 8px; top: 8px;
  background: rgba(60, 50, 45, 0.85); color: #fff;
  font-size: 11px; padding: 2px 8px; border-radius: 10px;
}
.badge-presale {
  position: absolute; left: 8px; top: 32px;
  background: rgba(194, 90, 58, 0.92); color: #fff;
  font-size: 11px; padding: 2px 8px; border-radius: 10px;
}
.item-meta .badge-presale { position: static; }
.presale-note {
  background: #fdeee6; border: 1px solid #f0cdb8; border-radius: 8px;
  padding: 8px 12px; font-size: 13px; color: #a0522d; margin-bottom: 10px;
}
.card-info { padding: 10px 12px; }
.card-title {
  font-size: 14px; font-weight: 600;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card-price { color: #c25a3a; font-weight: 700; margin-top: 4px; }
.shop-foot { text-align: center; font-size: 12px; color: #b0a49c; padding: 28px 0 12px; }

/* ---- 商品內頁 ---- */
.item { background: #fff; border-radius: 14px; overflow: hidden; box-shadow: 0 1px 4px rgba(90,60,40,0.08); }
.item-cover { background: #f0e8e2; }
.item-cover img { width: 100%; max-height: 70vh; object-fit: contain; }
.item-body { padding: 18px; }
.item-title { font-size: 19px; margin-bottom: 8px; }
.item-meta { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.item-meta .badge-type { position: static; }
.item-meta .stock { font-size: 13px; color: #96887f; }
.item-price { font-size: 24px; color: #c25a3a; font-weight: 700; margin-bottom: 12px; }
.item-desc { font-size: 14px; color: #5c524c; margin-bottom: 18px; white-space: normal; }
.btn-order {
  display: block; width: 100%; text-align: center;
  background: #c25a3a; color: #fff; font-size: 16px; font-weight: 600;
  border: none; border-radius: 10px; padding: 13px; cursor: pointer;
}
.btn-order:disabled, button.btn-order[disabled] { background: #cfc2b9; cursor: not-allowed; }
.hint { font-size: 12px; color: #a89a92; margin-top: 10px; text-align: center; }

/* ---- 後台 ---- */
body.admin { background: #f4f2ef; }
.admin-head {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 10px; padding: 8px 0 18px;
}
.admin-head h1 { font-size: 19px; }
.admin-head nav { display: flex; gap: 8px; flex-wrap: wrap; }

.btn {
  display: inline-block; background: #8a6046; color: #fff;
  font-size: 14px; border: none; border-radius: 8px;
  padding: 8px 14px; cursor: pointer;
}
.btn.ghost { background: transparent; color: #8a6046; border: 1px solid #cbb5a5; }
.btn.small { font-size: 12px; padding: 4px 10px; }
.btn.danger { background: #b8452f; }
.btn.big { width: 100%; padding: 13px; font-size: 16px; margin-top: 8px; }

.list { width: 100%; border-collapse: collapse; background: #fff; border-radius: 10px; overflow: hidden; font-size: 14px; }
.list th, .list td { padding: 10px 8px; border-bottom: 1px solid #eee5de; text-align: left; vertical-align: middle; }
.list th { background: #ede4dc; font-size: 13px; }
.list tr.off-shelf { opacity: 0.55; }
.thumb { width: 44px; height: 58px; object-fit: cover; border-radius: 4px; }
.thumb-cell { width: 52px; }
.ops { white-space: nowrap; }
.ops .inline { display: inline; }

.form label { display: block; font-size: 14px; margin-bottom: 14px; color: #5c524c; }
.form input[type="text"], .form input[type="number"], .form input[type="password"],
.form select, .form textarea {
  display: block; width: 100%; margin-top: 4px;
  font-size: 15px; padding: 9px 10px;
  border: 1px solid #d5c5b8; border-radius: 8px; background: #fff;
}
.form textarea { resize: vertical; }
.form .row { display: flex; gap: 12px; flex-wrap: wrap; }
.form .row label { flex: 1; min-width: 140px; }
.form .check { display: flex; align-items: center; gap: 8px; margin-top: 24px; }
.form .check input { width: auto; margin: 0; }
.form fieldset { border: 1px solid #ddd0c5; border-radius: 10px; padding: 14px; margin-bottom: 14px; }
.form fieldset legend { font-size: 13px; color: #96887f; padding: 0 6px; }
.preview { max-width: 140px; border-radius: 8px; margin: -6px 0 14px; }
.preview.qr { max-width: 180px; }

/* ---- 下單/付款/查訂單（第二批） ---- */
.order-summary {
  background: #fff; border-radius: 12px; padding: 14px 16px; margin-bottom: 16px;
  box-shadow: 0 1px 4px rgba(90,60,40,0.08); font-size: 14px;
  display: flex; flex-direction: column; gap: 6px;
}
.order-summary .price { color: #c25a3a; font-weight: 600; }
.order-summary .total { border-top: 1px dashed #e5d8cd; padding-top: 8px; margin-top: 4px; font-size: 15px; }
.order-summary .badge-type, .order-summary .badge-presale { position: static; align-self: flex-start; }
.status-line { font-size: 15px; margin-bottom: 4px; }
.lookup-item { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.lookup-item .tag { font-size: 12px; color: #a0674b; background: #f7ebe2; border-radius: 8px; padding: 2px 8px; }
.lookup-form { margin-bottom: 18px; }

.code-box {
  background: #fff8ee; border: 2px dashed #d9a879; border-radius: 12px;
  text-align: center; padding: 16px; margin-bottom: 16px;
}
.code-label { font-size: 13px; color: #a0674b; margin-bottom: 6px; }
.code-value { font-size: 30px; font-weight: 800; letter-spacing: 4px; color: #7a4a2e; }
.code-sub { font-size: 12px; color: #b09a88; margin-top: 6px; }

.qr-row { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-bottom: 16px; }
.qr-block { background: #fff; border-radius: 12px; padding: 12px; text-align: center; box-shadow: 0 1px 4px rgba(90,60,40,0.08); }
.qr-block img { width: 200px; max-width: 62vw; margin: 0 auto; }
.qr-title { font-size: 13px; margin-bottom: 8px; color: #5c524c; }

.ok-box {
  background: #eef7ee; border: 1px solid #cfe5cf; border-radius: 10px;
  padding: 12px 14px; font-size: 14px; color: #3e6b4a; margin-bottom: 16px;
}
.ok-box a { color: #2f7a45; text-decoration: underline; }

.reveal-box {
  background: #fff; border: 2px solid #c25a3a; border-radius: 12px;
  padding: 16px; margin-bottom: 16px; font-size: 14px;
}
.reveal-warn {
  background: #c25a3a; color: #fff; border-radius: 8px;
  text-align: center; padding: 8px; font-weight: 700; margin-bottom: 12px;
}
.reveal-title { font-weight: 700; margin-bottom: 8px; }
.reveal-row { margin-bottom: 8px; word-break: break-all; }
.reveal-row .sel { user-select: all; }
.reveal-sub { font-size: 12px; color: #b09a88; text-align: center; margin-top: 10px; }

/* ---- 後台訂單 ---- */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.tab {
  font-size: 13px; padding: 5px 10px; border-radius: 16px;
  background: #fff; border: 1px solid #d5c5b8; color: #6b5c52;
}
.tab.active { background: #8a6046; border-color: #8a6046; color: #fff; }
.detail-card {
  background: #fff; border-radius: 12px; padding: 6px 16px; margin-bottom: 16px;
  box-shadow: 0 1px 4px rgba(90,60,40,0.08); font-size: 14px;
}
.detail-row {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 9px 0; border-bottom: 1px solid #f2e9e1; flex-wrap: wrap;
}
.detail-row:last-child { border-bottom: none; }
.detail-row > span:first-child { color: #96887f; flex-shrink: 0; }
.section-title { font-size: 15px; margin: 18px 0 8px; color: #5c524c; }
.screenshot { max-width: 260px; border-radius: 10px; box-shadow: 0 1px 6px rgba(90,60,40,0.15); }
.action-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }

.login-box {
  max-width: 320px; margin: 18vh auto 0; background: #fff;
  border-radius: 14px; padding: 28px; box-shadow: 0 2px 10px rgba(90,60,40,0.1);
}
.login-box h1 { font-size: 18px; margin-bottom: 16px; text-align: center; }
.login-box input {
  display: block; width: 100%; font-size: 15px; padding: 10px;
  border: 1px solid #d5c5b8; border-radius: 8px; margin-bottom: 12px;
}
.login-box .btn { width: 100%; }
.error { color: #b8452f; font-size: 14px; margin-bottom: 10px; text-align: center; }
.ok { color: #3e7d4f; font-size: 14px; margin-bottom: 12px; }
