:root {
  --brand: #3A2F2A;
  --brand-dark: #2B2725;
  --ink: #2B2725;
  --muted: #8A8580;
  --line: #E8E3DE;
  --bg: #F7F5F2;
  --panel: #ffffff;
  --soft: #F3EEE9;
  --ok: #557565;
  --warn: #9B7148;
  --info: #6F655E;
  --price: #B35C3A;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled {
  cursor: not-allowed;
  opacity: .58;
}

.demo-header {
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  background: rgba(255,255,255,.94);
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 4px;
}

h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 650;
  letter-spacing: 0;
}

.mode-tabs {
  display: inline-flex;
  gap: 8px;
  padding: 4px;
  background: var(--soft);
  border-radius: 8px;
  border: 1px solid var(--line);
}

.mode-tabs button,
.admin-sidebar button,
.filter-bar button,
.tabbar button,
.seg button {
  border: 0;
  background: transparent;
  color: var(--muted);
}

.mode-tabs button {
  padding: 8px 14px;
  color: var(--muted);
  border-radius: 6px;
}

.mode-tabs button.active,
.seg button.active {
  background: #fff;
  color: var(--brand);
  box-shadow: none;
}

.workspace {
  min-height: calc(100vh - 72px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 24px;
}

.phone-shell {
  width: 390px;
  height: 812px;
  background: #2B2725;
  padding: 12px;
  border-radius: 20px;
  box-shadow: 0 12px 34px rgba(58,47,42,.14);
}

.phone-status {
  height: 28px;
  padding: 0 12px;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
}

.mini-app {
  height: 748px;
  overflow: hidden;
  background: var(--bg);
  border-radius: 12px;
  position: relative;
}

.page {
  height: 100%;
  overflow-y: auto;
  padding-bottom: 72px;
}

.nav {
  position: sticky;
  top: 0;
  z-index: 5;
  min-height: 48px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  background: rgba(255,255,255,.96);
  border-bottom: 1px solid var(--line);
}

.nav-title {
  font-size: 17px;
  font-weight: 650;
  flex: 1;
  text-align: center;
}

.icon-btn {
  width: 32px;
  height: 32px;
  border: 0;
  background: transparent;
  color: #343940;
  font-size: 18px;
}

.search {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  height: 36px;
  padding: 0 12px;
  background: #F3F0EC;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.search input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
}

.hero {
  position: relative;
  isolation: isolate;
  margin: 16px;
  padding: 22px;
  min-height: 176px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  color: #fff;
  background-size: cover;
  background-position: center;
  border-radius: 10px;
  overflow: hidden;
}

.hero::before { content: ""; position: absolute; inset: 0; background: rgba(43,39,37,.56); z-index: -1; }

.hero h2 {
  margin: 0;
  font-size: 22px;
  line-height: 1.35;
  font-weight: 700;
}

.hero p { margin: 6px 0 0; font-size: 13px; opacity: .92; }
.hero-cta { margin-top: 16px; padding: 8px 12px; border: 1px solid rgba(255,255,255,.75); border-radius: 8px; color: #fff; background: rgba(255,255,255,.12); font-size: 13px; }
.hero > .badge { align-self: flex-start; margin-top: 12px; background: rgba(255,255,255,.18); color: #fff; border: 1px solid rgba(255,255,255,.35); }

.quick-cats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  padding: 0 16px 8px;
}

.cat-tile {
  border: 1px solid var(--line);
  background: #fff;
  padding: 12px 4px;
  min-height: 74px;
  border-radius: 8px;
}

.cat-icon {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  margin: 0 auto 8px;
  background: var(--soft);
  color: var(--brand);
  border-radius: 8px;
}

.cat-tile span { font-size: 12px; color: #343940; }

.section {
  margin: 16px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}

.section-head {
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  border-bottom: 1px solid var(--line);
}

.section-head h3,
.admin-card h3 {
  margin: 0;
  font-size: 17px;
  font-weight: 650;
}

.muted { color: var(--muted); font-size: 12px; }

.product-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  padding: 12px;
  background: #fff;
}

.product-card {
  position: relative;
  border: 0;
  text-align: left;
  background: #fff;
  padding: 0;
  min-height: 238px;
  border-radius: 8px;
  overflow: hidden;
}

.product-card > :not(.product-img) { margin-left: 10px; margin-right: 10px; }
.product-card > .price { margin-bottom: 12px; }

.product-img,
.cart-img,
.detail-img {
  background-size: cover;
  background-position: center;
  background-color: #eee;
}

.product-img {
  height: 142px;
  margin-bottom: 10px;
  border-radius: 7px;
}

.product-name {
  min-height: 38px;
  padding: 0 2px;
  font-size: 14px;
  line-height: 1.45;
  color: var(--ink);
}

.price {
  color: var(--price);
  font-size: 20px;
  font-weight: 750;
  margin-top: 7px;
}

.strike {
  color: #9aa0a6;
  text-decoration: line-through;
  font-size: 12px;
  font-weight: 400;
  margin-left: 4px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 7px;
  background: var(--soft);
  color: #6F5C4D;
  font-size: 12px;
  border-radius: 4px;
}

.badge.ok { background: #e9f8ef; color: var(--ok); }
.badge.warn { background: #F7F0E5; color: var(--warn); }
.badge.gray { background: #F2F0EE; color: var(--muted); }
.badge.info { background: #EEEAE7; color: var(--info); }

.filter-bar {
  display: flex;
  gap: 4px;
  margin: 12px 16px;
  padding: 4px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.filter-bar button {
  flex: 1;
  height: 42px;
  color: var(--muted);
  border-radius: 6px;
}

.filter-bar button.active { color: #fff; background: var(--brand); font-weight: 650; }

.list-card {
  display: grid;
  grid-template-columns: 112px 1fr;
  gap: 12px;
  padding: 14px;
  background: #fff;
  border: 1px solid var(--line);
  text-align: left;
  border-radius: 8px;
  width: 100%;
}

.list-card .product-img { height: 104px; margin: 0; }

.detail-img { height: 330px; }

.detail-title,
.detail-block,
.cart-card,
.checkout-card,
.order-card {
  background: #fff;
  margin: 12px 16px 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.detail-title h2 {
  margin: 0 0 8px;
  font-size: 18px;
  line-height: 1.35;
}

.meta-row,
.total-row,
.form-row,
.admin-form-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.admin-form-row > span {
  min-width: 86px;
  color: #4d5560;
  font-size: 13px;
}

.admin-form-row input,
.admin-form-row select,
.admin-form-row textarea {
  flex: 1;
}

.meta-row { padding: 8px 0; color: var(--muted); font-size: 13px; }
.meta-row + .meta-row { border-top: 1px solid var(--line); }

.footer-actions {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 64px;
  display: grid;
  grid-template-columns: 72px 1fr 1fr;
  gap: 0;
  background: #fff;
  border-top: 1px solid var(--line);
  z-index: 8;
}

.footer-actions button {
  border: 0;
  border-right: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

.footer-actions .primary { background: var(--brand); color: #fff; border-right: 0; }
.footer-actions .success { background: #8B6F5A; color: #fff; border-right: 0; }
.footer-actions [data-favorite] { display: none; }
.favorite-icon { color: var(--brand); font-size: 22px; }

.tabbar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 60px;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  background: #fff;
  border-top: 1px solid var(--line);
  z-index: 9;
}

.tabbar button {
  font-size: 12px;
  color: var(--muted);
}

.tabbar button.active { color: var(--brand); font-weight: 650; }

.cart-card {
  display: grid;
  grid-template-columns: 26px 76px 1fr;
  gap: 12px;
  align-items: center;
}

.cart-img { width: 76px; height: 76px; }

.qty {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
}

.qty button {
  width: 28px;
  height: 28px;
  border: 0;
  background: #f7f8fa;
}

.qty span {
  min-width: 30px;
  text-align: center;
  font-size: 13px;
}

.cart-footer,
.checkout-footer {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 60px;
  min-height: 54px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  background: #fff;
  border-top: 1px solid var(--line);
  z-index: 8;
}

.btn {
  border: 1px solid var(--brand);
  min-height: 34px;
  padding: 0 14px;
  background: var(--brand);
  color: #fff;
  border-radius: 8px;
}

.btn.secondary { background: #8B6F5A; border-color: #8B6F5A; }
.btn.ghost { background: #fff; color: var(--ink); border: 1px solid var(--line); }
.btn.ok { background: var(--ok); }

.empty {
  min-height: 280px;
  display: grid;
  place-items: center;
  text-align: center;
  color: var(--muted);
  padding: 24px;
}

.empty strong { display: block; color: var(--ink); margin-bottom: 8px; }
.empty strong::before { content: "☕"; display: grid; place-items: center; width: 44px; height: 44px; margin: 0 auto 12px; color: var(--brand); background: var(--soft); border-radius: 50%; font-size: 20px; }

.seg {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.seg button {
  min-height: 42px;
  border-bottom: 2px solid transparent;
}

.seg button.active {
  box-shadow: none;
  border-bottom-color: var(--brand);
}

.coupon {
  border: 1px solid var(--line);
  padding: 14px;
  background: #fff;
  border-radius: 8px;
}

.coupon.active {
  border-color: var(--brand);
  background: var(--soft);
}

.coupon-entry { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px; cursor: pointer; }
.coupon-entry h3 { margin: 2px 0 4px; font-size: 18px; }
.coupon-entry p { margin: 0; }
.section-kicker { color: #8B6F5A; font-size: 12px; }
.coupon-center { display: grid; grid-template-columns: 62px 1fr auto; gap: 12px; align-items: center; }
.coupon-value { color: var(--price); font-size: 30px; font-weight: 750; }
.coupon-value small { font-size: 14px; }
.coupon-main p { margin: 4px 0 0; font-size: 12px; color: var(--muted); }

.review-upload { margin-top: 16px; }
.review-image-grid { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.review-image, .review-add { width: 64px; height: 64px; border: 1px solid var(--line); border-radius: 8px; background-size: cover; background-position: center; }
.review-image { position: relative; }
.review-image .icon-btn { position: absolute; top: 2px; right: 2px; width: 22px; height: 22px; color: #fff; background: rgba(43,39,37,.68); border-radius: 4px; }
.review-add { display: grid; place-items: center; background: #fff; color: var(--muted); }
.review-add small { display: block; font-size: 11px; }
.review-thumbs, .admin-review-images { display: flex; gap: 6px; margin-top: 8px; }
.review-thumbs span, .admin-review-images span { width: 48px; height: 48px; border-radius: 6px; background-size: cover; background-position: center; }
.review-item + .review-item { border-top: 1px solid var(--line); margin-top: 12px; padding-top: 12px; }

.admin-product-cell { display: flex; align-items: center; gap: 10px; min-width: 185px; }
.admin-product-cell > span { width: 42px; height: 42px; flex: 0 0 auto; border-radius: 6px; background-size: cover; background-position: center; }
.product-editor { width: min(980px, calc(100vw - 32px)); }
.product-editor h3 { margin: 20px 0 12px; font-size: 16px; }
.product-editor h3:first-child { margin-top: 0; }
.product-media-grid { display: flex; gap: 10px; flex-wrap: wrap; }
.product-media-thumb, .product-media-add { position: relative; width: 110px; height: 90px; border: 1px solid var(--line); border-radius: 8px; background-size: cover; background-position: center; }
.product-media-thumb span { position: absolute; left: 5px; top: 5px; padding: 2px 5px; color: #fff; background: rgba(43,39,37,.72); border-radius: 4px; font-size: 11px; }
.product-media-thumb .icon-btn { position: absolute; top: 3px; right: 3px; width: 22px; height: 22px; color: #fff; background: rgba(43,39,37,.72); border-radius: 4px; }
.product-media-thumb .link-btn { position: absolute; left: 5px; bottom: 5px; padding: 2px 5px; color: #fff; background: rgba(43,39,37,.72); border-radius: 4px; font-size: 11px; }
.product-media-add { display: grid; place-items: center; background: #fff; color: var(--muted); }
.product-media-add small { display: block; font-size: 11px; }
.detail-editor-toolbar { display: flex; align-items: center; gap: 6px; min-height: 42px; padding: 5px 8px; border: 1px solid var(--line); border-bottom: 0; background: #faf8f6; }
.detail-editor-toolbar > span { flex: 1; }
.detail-editor-toolbar .icon-btn { width: 28px; height: 28px; font-size: 14px; font-weight: 700; }
.detail-editor-toolbar .btn { min-height: 28px; padding: 4px 9px; font-size: 12px; }
.detail-editor-canvas { min-height: 220px; padding: 14px; border: 1px solid var(--line); background: #fff; }
.detail-editor-text { min-height: 28px; padding: 6px 8px; outline: none; border-radius: 4px; color: var(--ink); line-height: 1.7; }
.detail-editor-text:focus, .detail-editor-text.selected, .detail-editor-image.selected, .detail-editor-video.selected { outline: 2px solid #d5b49e; outline-offset: 1px; }
.detail-editor-image { position: relative; height: 180px; margin: 10px 0; border-radius: 6px; background-size: cover; background-position: center; cursor: pointer; }
.detail-editor-image span { position: absolute; left: 8px; top: 8px; padding: 3px 6px; border-radius: 4px; background: rgba(43,39,37,.65); color: #fff; font-size: 11px; }
.detail-editor-video { display: flex; align-items: center; gap: 10px; width: 100%; margin: 10px 0; padding: 14px; border: 1px solid var(--line); border-radius: 6px; background: #fff; color: var(--muted); text-align: left; cursor: pointer; }
.detail-editor-video span { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--soft); color: var(--brand); }
.detail-editor-selection { display: flex; align-items: center; justify-content: flex-end; gap: 10px; min-height: 34px; padding: 6px 0; font-size: 12px; }
.detail-editor-selection span { flex: 1; color: var(--muted); }
.mock-media-choice { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.mock-media-choice .product-media-thumb { width: 100%; height: 110px; cursor: pointer; background-color: #fff; }
.mock-media-choice .detail-editor-video { margin: 0; }
.import-dropzone { padding: 28px; border: 1px dashed #B9AAA0; border-radius: 8px; text-align: center; background: #FCFBFA; }
.detail-content-image { height: 180px; margin-top: 12px; border-radius: 8px; background-size: cover; background-position: center; }
.detail-video-card { display: flex; align-items: center; gap: 10px; margin-top: 12px; padding: 14px; border: 1px solid var(--line); border-radius: 8px; color: var(--muted); }
.detail-video-card span { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--soft); color: var(--brand); }

.coupon.disabled {
  opacity: .55;
}

.success-page {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
}

.success-mark {
  width: 72px;
  height: 72px;
  display: grid;
  place-items: center;
  background: #e9f8ef;
  color: var(--ok);
  font-size: 34px;
  border-radius: 50%;
}

.admin-shell {
  width: min(1180px, 100%);
  min-height: 760px;
  display: grid;
  grid-template-columns: 220px 1fr;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 10px 28px rgba(58,47,42,.08);
}

.admin-sidebar {
  background: #2B2725;
  padding: 18px 12px;
  overflow-y: auto;
}

.admin-brand {
  color: #fff;
  font-size: 18px;
  font-weight: 700;
  padding: 10px 12px 20px;
}

.admin-sidebar button {
  width: 100%;
  height: 40px;
  margin: 3px 0;
  text-align: left;
  padding: 0 12px;
  color: #CFC6C0;
  border-radius: 6px;
}

.admin-sidebar button.active {
  background: var(--brand);
  box-shadow: inset 3px 0 0 #BCA38D;
  color: #fff;
}

.admin-main {
  min-width: 0;
  background: #F7F5F2;
}

.admin-topbar {
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.admin-topbar span {
  margin-left: 10px;
  color: var(--muted);
  font-size: 13px;
}

#adminApp { padding: 24px; }

.stats {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  margin-bottom: 14px;
}

.stat,
.admin-card {
  background: #fff;
  border: 1px solid var(--line);
}

.stat { padding: 18px; border-radius: 8px; }
.stat span { color: var(--muted); font-size: 12px; }
.stat strong { display: block; margin-top: 8px; font-size: 24px; }

.admin-card { padding: 18px; margin-bottom: 16px; border-radius: 8px; overflow-x: auto; }

.toolbar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.toolbar .left,
.toolbar .right {
  display: flex;
  gap: 8px;
  align-items: center;
}

.admin-input,
.admin-select,
.admin-textarea {
  min-height: 36px;
  border: 1px solid var(--line);
  background: #fff;
  padding: 0 10px;
  outline: 0;
  border-radius: 8px;
}

.admin-input:focus, .admin-select:focus, .admin-textarea:focus { border-color: #8B6F5A; box-shadow: 0 0 0 3px rgba(139,111,90,.12); }

.admin-textarea {
  min-height: 70px;
  padding: 8px 10px;
  resize: vertical;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
}

th, td {
  padding: 13px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 13px;
  vertical-align: middle;
}

th { color: #6F655E; background: #F9F7F5; font-weight: 650; }
tbody tr:hover { background: #FCFBFA; }

.row-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.link-btn {
  border: 0;
  background: transparent;
  color: #6F5C4D;
  padding: 0;
}

.link-btn.danger { color: #A24B36; }

.pager {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 12px;
  color: var(--muted);
  font-size: 13px;
}

.modal-layer {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  background: rgba(43,39,37,.34);
}

.modal {
  width: min(520px, calc(100vw - 32px));
  max-height: 88vh;
  overflow: auto;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 16px 42px rgba(43,39,37,.16);
}

.sheet {
  align-self: end;
  width: 390px;
  max-height: 74vh;
  background: #fff;
  overflow: auto;
  border-radius: 10px 10px 0 0;
}

.modal-head {
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
}

.modal-body { padding: 16px; }

.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
}

.sku-grid {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.sku-grid button {
  min-height: 34px;
  border: 1px solid var(--line);
  background: #fff;
  padding: 0 12px;
  border-radius: 8px;
}

.sku-grid button.active {
  border-color: var(--brand);
  color: var(--brand);
  background: var(--soft);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 36px;
  transform: translateX(-50%) translateY(20px);
  padding: 9px 14px;
  background: rgba(43,39,37,.92);
  border-radius: 8px;
  color: #fff;
  opacity: 0;
  pointer-events: none;
  transition: .2s;
  z-index: 50;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.hidden { display: none !important; }

@media (max-width: 720px) {
  .demo-header {
    height: auto;
    gap: 12px;
    align-items: flex-start;
    flex-direction: column;
    padding: 14px;
  }

  .workspace { padding: 10px; }
  .phone-shell { width: 100%; max-width: 390px; height: calc(100vh - 126px); min-height: 640px; }
  .mini-app { height: calc(100% - 28px); }
  .admin-shell { grid-template-columns: 1fr; }
  .admin-sidebar { display: flex; overflow-x: auto; }
  .admin-brand { min-width: 130px; padding: 10px; }
  .admin-sidebar button { min-width: 96px; text-align: center; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .toolbar { flex-direction: column; }
}
