:root {
  --bg: #0d0d0d;
  --panel: #1a1a1a;
  --panel2: #222;
  --gold: #daa520;
  --gold-soft: #b8902a;
  --text: #e8e2d4;
  --muted: #8a8475;
  --line: #2d2a22;
  --danger: #c0392b;
  --ok: #2e8b57;
}
/* 强制 hidden 属性生效：覆盖 .login-wrap/.app 等类上的 display 规则，
   否则 hidden 会被 author 样式的 display:flex 顶掉，导致登录框关不掉/主框架叠在一起 */
[hidden] { display: none !important; }
* { box-sizing: border-box; }
body {
  margin: 0; font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg); color: var(--text);
}
button { cursor: pointer; font-family: inherit; }

/* 登录 */
.login-wrap { height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-card {
  width: 320px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; padding: 32px; text-align: center;
}
.login-logo { font-size: 28px; font-weight: 700; color: var(--gold); letter-spacing: 4px; }
.login-sub { color: var(--muted); margin: 6px 0 24px; font-size: 13px; }
.login-card input {
  width: 100%; padding: 11px 12px; margin-bottom: 12px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--bg); color: var(--text); font-size: 14px;
}
.login-card button {
  width: 100%; padding: 11px; border: none; border-radius: 8px;
  background: var(--gold); color: #1a1a1a; font-weight: 700; font-size: 15px;
}
.login-err { color: var(--danger); font-size: 13px; margin-top: 12px; min-height: 16px; }

/* 框架 */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 200px; background: var(--panel); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 16px 0;
}
.brand { color: var(--gold); font-size: 20px; font-weight: 700; text-align: center; letter-spacing: 3px; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.sidebar nav { flex: 1; display: flex; flex-direction: column; margin-top: 8px; }
.sidebar nav a {
  padding: 12px 22px; color: var(--muted); text-decoration: none; font-size: 14px;
  border-left: 3px solid transparent; transition: .15s;
}
.sidebar nav a:hover { color: var(--text); background: var(--panel2); }
.sidebar nav a.active { color: var(--gold); border-left-color: var(--gold); background: var(--panel2); }
.side-foot { padding: 14px 22px; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); display: flex; justify-content: space-between; }
.side-foot a { color: var(--gold-soft); cursor: pointer; }

.content { flex: 1; display: flex; flex-direction: column; }
.topbar { padding: 18px 28px; border-bottom: 1px solid var(--line); }
.topbar h2 { margin: 0; font-size: 18px; color: var(--gold); }
.view { padding: 24px 28px; }

/* 卡片 */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 18px; }
.stat .num { font-size: 26px; font-weight: 700; color: var(--gold); }
.stat .lab { color: var(--muted); font-size: 13px; margin-top: 4px; }

/* 工具栏 */
.toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; gap: 12px; }
.toolbar .right { display: flex; gap: 8px; }
.btn {
  padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--panel2); color: var(--text); font-size: 13px;
}
.btn.primary { background: var(--gold); color: #1a1a1a; border-color: var(--gold); font-weight: 600; }
.btn.danger { color: var(--danger); border-color: #4a1f1f; }
select, input, textarea {
  background: var(--bg); color: var(--text); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 10px; font-size: 13px; font-family: inherit;
}

/* 表格 */
table { width: 100%; border-collapse: collapse; background: var(--panel); border-radius: 10px; overflow: hidden; }
th, td { padding: 11px 12px; text-align: left; border-bottom: 1px solid var(--line); font-size: 13px; }
th { color: var(--muted); font-weight: 600; background: var(--panel2); }
tr:hover td { background: #1d1b15; }
.tag { display: inline-block; background: #2a2410; color: var(--gold); border-radius: 4px; padding: 1px 7px; margin: 1px; font-size: 12px; }
.muted { color: var(--muted); }
.row-actions button { margin-right: 6px; }

/* 弹窗 */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; z-index: 50; }
.modal-card { width: min(880px, 94vw); max-height: 94vh; overflow: hidden; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; }
.modal-card.wide { width: min(1340px, 97vw); }
.modal-body .form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px 12px; align-items: end; }
.modal-body .form-grid .field { margin-bottom: 0; }
.modal-body .form-grid .field-span-2 { grid-column: 1 / -1; }
.modal-split { display: flex; gap: 20px; align-items: stretch; max-height: calc(94vh - 86px); overflow: hidden; }
.modal-split .form-grid { flex: 1; min-width: 0; overflow: auto; }
.preview-pane { width: 348px; flex-shrink: 0; overflow: hidden; }
.preview-title { font-size: 12px; color: var(--muted); margin-bottom: 10px; text-align: center; letter-spacing: 3px; }
/* ── 小程序手机预览（高度随视口自适应） ── */
.pv-phone {
  height: calc(94vh - 150px);
  min-height: 460px;
  display: flex;
  flex-direction: column;
  background: #0D0D0D;
  border: 8px solid #1f1f1f;
  border-radius: 28px;
  overflow: hidden;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}
.pv-status { display: flex; justify-content: space-between; padding: 6px 14px; color: #555; font-size: 10px; background: #111; flex-shrink: 0; }
.pv-nav { padding: 10px 14px; color: #eee; font-size: 13px; text-align: center; background: #111; border-bottom: 1px solid #222; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex-shrink: 0; }
.pv-hero { position: relative; flex: 1; min-height: 0; background: #161616; }
.pv-hero img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pv-glyph { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 72px; font-weight: 600; }
.pv-hero img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pv-glyph { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 72px; font-weight: 600; }
.pv-badge { position: absolute; top: 10px; right: 10px; background: rgba(218, 165, 32, 0.92); color: #111; font-size: 10px; padding: 2px 8px; border-radius: 10px; }
.pv-dots { position: absolute; bottom: 10px; left: 0; right: 0; display: flex; justify-content: center; gap: 5px; }
.pv-dots span { width: 6px; height: 6px; border-radius: 3px; background: rgba(255, 255, 255, 0.4); transition: all 0.2s; }
.pv-dots span.on { background: #DAA520; width: 16px; }
.pv-thumbs { display: flex; gap: 8px; padding: 10px; overflow-x: auto; }
.pv-thumbs img { width: 52px; height: 52px; object-fit: cover; border-radius: 6px; border: 2px solid transparent; cursor: pointer; opacity: 0.55; }
.pv-thumbs img.on { border-color: #DAA520; opacity: 1; }
.pv-info { padding: 10px 14px; color: #ddd; flex-shrink: 0; overflow: hidden; }
.pv-price { display: flex; align-items: baseline; gap: 8px; }
.pv-now { color: #DAA520; font-size: 22px; font-weight: 700; }
.pv-orig { color: #666; font-size: 12px; text-decoration: line-through; }
.pv-name { margin-top: 6px; font-size: 15px; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pv-tags { margin-top: 6px; display: flex; gap: 6px; flex-wrap: wrap; }
.pv-tags .tag { font-size: 10px; border: 1px solid #444; color: #999; padding: 1px 6px; border-radius: 3px; }
.pv-meta { margin-top: 8px; font-size: 11px; color: #777; }
.pv-desc {
  margin-top: 10px;
  font-size: 12px;
  color: #999;
  line-height: 1.6;
  word-break: break-all;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.pv-bar { display: flex; border-top: 1px solid #222; flex-shrink: 0; }
.pv-thumbs { display: flex; gap: 8px; padding: 8px 10px; overflow-x: auto; flex-shrink: 0; }
.pv-thumbs img { width: 44px; height: 44px; object-fit: cover; border-radius: 6px; border: 2px solid transparent; cursor: pointer; opacity: 0.55; flex-shrink: 0; }
.pv-bar span { flex: 1; text-align: center; padding: 12px 0; font-size: 13px; font-weight: 600; }
.pv-cart { background: #2a2a2a; color: #eee; }
.pv-buy { background: linear-gradient(90deg, #DAA520, #e8b93e); color: #111; }

/* ── 弹窗响应式：按窗口宽度分级适配 ── */
@media (max-width: 1560px) {
  .modal-card.wide { width: min(1240px, 97vw); }
  .preview-pane { width: 320px; }
}
@media (max-width: 1360px) {
  .modal-card.wide { width: min(1120px, 97vw); }
  .preview-pane { width: 296px; }
  .pv-phone { height: calc(94vh - 150px); }
  .pv-now { font-size: 19px; }
}
@media (max-width: 1160px) {
  .modal-card.wide { width: min(1000px, 97vw); }
  .preview-pane { width: 264px; }
  .modal-split { gap: 14px; }
}
@media (max-width: 1000px) {
  /* 窄屏：预览移到表单下方 */
  .modal-split { flex-direction: column; max-height: none; }
  .modal-split .form-grid { overflow: visible; }
  .preview-pane { width: 100%; }
  .pv-phone { height: auto; min-height: 0; max-height: none; }
  .pv-hero { aspect-ratio: 4 / 3; flex: none; }
  .pv-desc { -webkit-line-clamp: 3; }
  .modal-card.wide { width: min(720px, 96vw); }
}
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); font-weight: 600; color: var(--gold); }
.modal-head button { background: none; border: none; color: var(--muted); font-size: 18px; }
.modal-body { padding: 14px 16px; }
.modal-body .field { margin-bottom: 14px; }
.img-upload {
  display: flex;
  gap: 8px;
  align-items: center;
  flex: 1;
  flex-wrap: wrap;
}
.img-upload img {
  max-height: 120px;
  max-width: 180px;
  border-radius: 8px;
  border: 1px solid #333;
  background: #222;
}
.img-upload input[data-name] {
  flex: 1;
  min-width: 200px;
}
.img-upload {
  max-width: 640px;
}
.img-upload .btn {
  flex-shrink: 0;
}
.img-upload .btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.img-multi-list {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.img-multi-item {
  position: relative;
}
.img-multi-item img {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid #333;
  background: #222;
  display: block;
}
.img-multi-del {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 20px;
  height: 20px;
  background: #c0392b;
  color: #fff;
  border-radius: 50%;
  font-size: 12px;
  line-height: 20px;
  text-align: center;
  cursor: pointer;
}
.upload-progress {
  width: 100%;
  height: 10px;
  background: #222;
  border-radius: 5px;
  overflow: hidden;
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.upload-progress-inner {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #DAA520, #f0c060);
  border-radius: 5px;
  transition: width 0.15s;
}
.upload-progress-text {
  font-size: 12px;
  color: #bbb;
  white-space: nowrap;
}
.upload-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 16px;
}
.upload-card {
  background: #1a1a1a;
  border: 1px solid #2a2a2a;
  border-radius: 10px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.upload-card img {
  width: 100%;
  height: 120px;
  object-fit: cover;
  border-radius: 6px;
  background: #222;
}
.upload-check {
  font-size: 13px;
  color: #bbb;
  display: flex;
  align-items: center;
  gap: 6px;
}
.upload-meta {
  font-size: 12px;
  color: #888;
}
.upload-meta .warn {
  color: #e67e22;
}
.prod-thumb {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid #333;
  cursor: zoom-out;
  display: block;
}
.prod-glyph {
  font-size: 26px;
  font-weight: 600;
}
.upload-card img[data-action="img-preview"] {
  cursor: zoom-out;
  transition: transform 0.15s;
}
.upload-card img[data-action="img-preview"]:hover {
  transform: scale(1.04);
}
#lightbox {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.88);
  cursor: zoom-out;
}
#lightbox .lightbox-img {
  max-width: 92vw;
  max-height: 88vh;
  border-radius: 8px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.6);
}
#lightbox .lightbox-bar {
  margin-top: 12px;
  color: #ccc;
  font-size: 13px;
}
#lightbox .lightbox-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 34px;
  line-height: 48px;
  cursor: pointer;
  transition: background 0.15s;
}
#lightbox .lightbox-arrow:hover {
  background: rgba(218, 165, 32, 0.85);
}
#lightbox .lightbox-arrow.prev { left: 24px; }
#lightbox .lightbox-arrow.next { right: 24px; }
#lightbox .lightbox-close {
  position: absolute;
  top: 18px;
  right: 22px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 16px;
  cursor: pointer;
}
#lightbox .lightbox-close:hover {
  background: rgba(192, 57, 43, 0.85);
}
.modal-body label { display: block; color: var(--muted); font-size: 11px; margin-bottom: 3px; }
.modal-body input, .modal-body textarea, .modal-body select { width: 100%; }
.modal-foot { padding: 10px 16px; border-top: 1px solid var(--line); text-align: right; }

/* toast */
.toast { position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%); background: #2e8b57; color: #fff; padding: 10px 20px; border-radius: 8px; font-size: 14px; z-index: 99; }
.toast.err { background: var(--danger); }
.checkbox-row { display: flex; align-items: center; gap: 8px; }
.checkbox-row input { width: auto; }

/* ============ 商品详情版式区块编辑器（layout_blocks） ============ */
.blocks-editor { border: 1px solid var(--line); border-radius: 8px; padding: 8px; background: #141414; }
.blocks-editor .blk-card { background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; margin-bottom: 8px; }
.blocks-editor .blk-card.blk-new { box-shadow: 0 0 0 1px var(--gold); }
.blk-head { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-bottom: 1px dashed var(--line); flex-wrap: wrap; }
.blk-idx { color: var(--gold); font-weight: 700; font-size: 12px; }
.blk-head select.blk-type { width: auto; min-width: 108px; }
.blk-tip { color: var(--muted); font-size: 11px; flex: 1; min-width: 80px; }
.blk-ops { display: inline-flex; gap: 4px; }
.btn.sm { padding: 3px 8px; font-size: 12px; border-radius: 5px; }
.blk-body { padding: 8px 10px 10px; display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px 10px; align-items: end; }
.blk-body .blk-fld-full, .blk-body .blk-imgwrap, .blk-body .blk-item-list { grid-column: 1 / -1; }
.blk-fld label, .blk-imgwrap label { display: block; color: var(--muted); font-size: 11px; margin-bottom: 2px; }
.blk-fld input, .blk-imgwrap input { width: 100%; background: var(--bg); border: 1px solid var(--line); color: var(--text); border-radius: 5px; padding: 5px 8px; font-size: 12px; }
.blk-imgwrap { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.blk-imgwrap label { width: 100%; }
.blk-imgwrap input { flex: 1; min-width: 140px; }
.blk-item-list { display: flex; flex-direction: column; gap: 5px; }
.blk-list-hint { color: var(--muted); font-size: 11px; }
.blk-item-row { display: flex; gap: 5px; align-items: center; }
.blk-item-row input { flex: 1; min-width: 0; background: var(--bg); border: 1px solid var(--line); color: var(--text); border-radius: 5px; padding: 4px 7px; font-size: 12px; }
.blk-item-row.blk-item-product input:nth-child(1) { flex: 0 0 64px; }
.blk-item-row.blk-item-product input:nth-child(2) { flex: 1.4; }
.blk-item-row.blk-item-product input:nth-child(3) { flex: 0 0 70px; }
.blk-item-row.blk-item-product input:nth-child(4) { flex: 1.2; }
.blk-item-showcase input:nth-child(1) { flex: 1; }
.blk-item-showcase input:nth-child(2) { flex: 1.4; }
.blk-item-showcase input:nth-child(3) { flex: 1.2; }
.blocks-add { text-align: center; padding: 4px 0; }
.blocks-add .btn { color: var(--gold); border: 1px dashed var(--gold); background: none; }

/* ============ ERP 版式预览：layout_blocks 区块 ============ */
.pv-scroll { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; }
.pv-phone .pv-hero { flex: none; height: 250px; }
.pv-thumbs { flex-shrink: 0; }
.pv-blocks { padding: 10px 14px 16px; display: flex; flex-direction: column; gap: 12px; }
.pv-blk-empty { color: #555; font-size: 12px; text-align: center; border: 1px dashed #333; border-radius: 8px; padding: 18px 0; }
.pv-blk { background: #121212; border-radius: 10px; padding: 12px; }
.pv-titles { display: flex; align-items: center; gap: 8px; background: none; padding: 4px 0; }
.pv-titles-line { flex: 1; height: 1px; background: linear-gradient(90deg, transparent, #444, transparent); }
.pv-titles-main { font-size: 17px; font-weight: 700; color: #f2e9d0; letter-spacing: 2px; text-align: center; }
.pv-titles-sub { font-size: 11px; color: #8a8475; text-align: center; margin-top: 2px; }
.pv-services { display: flex; gap: 6px; flex-wrap: wrap; background: none; padding: 2px 0; }
.pv-services span { font-size: 11px; color: #d8c9a0; border: 1px solid #3a3526; border-radius: 12px; padding: 4px 10px; background: #16140e; }
.pv-sec-title { font-size: 15px; font-weight: 700; color: #f0e6c8; text-align: center; margin-bottom: 8px; letter-spacing: 2px; }
.pv-sec-sub { font-size: 11px; color: #8a8475; text-align: center; margin-bottom: 8px; }
.pv-banner { padding: 0; overflow: hidden; background: #101010; }
.pv-banner img { width: 100%; display: block; }
.pv-banner-cap { padding: 8px 12px; text-align: center; color: #f0e6c8; font-size: 13px; }
.pv-banner-cap span { display: block; font-size: 11px; color: #8a8475; margin-top: 2px; }
.pv-desc-text { font-size: 12px; color: #a9a294; line-height: 1.8; white-space: pre-wrap; }
.pv-grid { display: grid; gap: 8px; }
.pv-grid-3 { grid-template-columns: repeat(3, 1fr); }
.pv-grid-4 { grid-template-columns: repeat(4, 1fr); }
.pv-card { background: #181818; border-radius: 8px; overflow: hidden; }
.pv-card-img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; background: #222; }
.pv-card-name { font-size: 11px; color: #ccc; padding: 5px 6px 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pv-card-price { font-size: 12px; font-weight: 700; color: var(--gold); padding: 2px 6px 7px; }
.pv-focus { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.pv-focus-cell { background: #181818; border-radius: 8px; padding: 7px; text-align: center; position: relative; }
.pv-focus-idx { position: absolute; top: 4px; left: 6px; font-size: 10px; font-weight: 700; color: var(--gold); }
.pv-focus-img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 6px; background: #222; }
.pv-focus-name { font-size: 11px; color: #ccc; margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pv-showcase { display: flex; flex-direction: column; gap: 10px; background: none; padding: 0; }
.pv-showcase-card { border-radius: 12px; overflow: hidden; display: flex; align-items: stretch; }
.pv-showcase-txt { flex: 1; padding: 12px; display: flex; flex-direction: column; justify-content: center; }
.pv-showcase-title { font-size: 15px; font-weight: 700; color: #241f14; }
.pv-showcase-desc { font-size: 11px; color: #5a5140; margin-top: 5px; line-height: 1.6; }
.pv-showcase-img { width: 44%; aspect-ratio: 1; object-fit: cover; display: block; }
