:root {
  --primary: #4b6bff;
  --primary-weak: #eef1ff;
  --danger: #e5484d;
  --success: #12a150;
  --warn: #f5a524;
  --text: #1f2329;
  --text-2: #5c6470;
  --text-3: #8a919e;
  --border: #e5e7ee;
  --bg: #f5f6f9;
  --card: #ffffff;
  --radius: 10px;
  --shadow: 0 2px 12px rgba(20, 25, 40, .06);
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; font-size: 14px; color: var(--text); background: var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}
a { color: var(--primary); text-decoration: none; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #d7dae3; border-radius: 4px; }

/* ---------- 登录 ---------- */
.login-wrap { height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #eef1ff 0%, #f7f8fb 55%, #eaf6ff 100%); }
.login-card { width: 380px; background: var(--card); border-radius: 16px; box-shadow: var(--shadow); padding: 40px 34px; }
.login-title { font-size: 22px; font-weight: 700; }
.login-sub { color: var(--text-3); font-size: 12px; letter-spacing: 2px; margin: 4px 0 24px; }
.login-tip { margin-top: 14px; font-size: 12px; color: var(--text-3); text-align: center; }

/* ---------- 布局 ---------- */
.layout { display: flex; height: 100vh; }
.sidebar { width: 216px; background: #1f2437; color: #c8ccd8; display: flex; flex-direction: column; flex: none; }
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 14px; }
.brand-logo { width: 34px; height: 34px; border-radius: 9px; background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 700; }
.brand-text b { display: block; color: #fff; font-size: 14px; }
.brand-text span { font-size: 11px; color: #7c8398; }
.menu { flex: 1; overflow: auto; padding: 6px 10px; }
.menu-item { display: flex; align-items: center; gap: 9px; padding: 10px 12px; border-radius: 8px; cursor: pointer;
  color: #c8ccd8; margin-bottom: 2px; font-size: 13.5px; }
.menu-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.menu-item.active { background: var(--primary); color: #fff; }
.menu-item .ico { width: 16px; text-align: center; opacity: .9; }
.menu-group { padding: 14px 12px 6px; font-size: 11px; color: #666e85; letter-spacing: 1px; }
.side-foot { padding: 12px 16px; border-top: 1px solid rgba(255,255,255,.08); display: flex; justify-content: space-between; font-size: 12px; }
.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.topbar { height: 56px; background: var(--card); border-bottom: 1px solid var(--border); display: flex;
  align-items: center; justify-content: space-between; padding: 0 22px; flex: none; }
.crumb { font-size: 15px; font-weight: 600; }
.topbar-right { display: flex; align-items: center; gap: 12px; color: var(--text-2); font-size: 13px; }
.badge { background: #fff4e5; color: #b76e00; padding: 3px 9px; border-radius: 20px; font-size: 12px; }
.badge.ok { background: #e7f7ee; color: #12783c; }
.view { flex: 1; overflow: auto; padding: 18px 22px 40px; }

/* ---------- 通用组件 ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; margin-bottom: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.card-title { font-size: 15px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.card-title::before { content: ''; width: 3px; height: 14px; background: var(--primary); border-radius: 2px; }
.btn { border: 1px solid var(--border); background: #fff; color: var(--text); padding: 7px 14px; border-radius: 7px;
  cursor: pointer; font-size: 13px; transition: .15s; display: inline-flex; align-items: center; gap: 6px; }
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { opacity: .9; color: #fff; }
.btn.danger { color: var(--danger); border-color: #f3c9ca; }
.btn.danger:hover { background: #fdecec; color: var(--danger); border-color: var(--danger); }
.btn.small { padding: 4px 9px; font-size: 12px; }
.btn.block { width: 100%; justify-content: center; }
input, select, textarea { border: 1px solid var(--border); border-radius: 7px; padding: 7px 10px; font-size: 13px;
  outline: none; color: var(--text); background: #fff; font-family: inherit; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); }
textarea { width: 100%; resize: vertical; min-height: 76px; line-height: 1.6; }
.form-item { margin-bottom: 14px; }
.form-item > label { display: block; font-size: 13px; color: var(--text-2); margin-bottom: 6px; }
.form-item input, .form-item select { width: 100%; }
.form-row { display: flex; gap: 12px; }
.form-row > div { flex: 1; }
.hint { font-size: 12px; color: var(--text-3); margin-top: 5px; line-height: 1.6; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.toolbar .grow { flex: 1; }
table.grid { width: 100%; border-collapse: collapse; font-size: 13px; }
table.grid th { text-align: left; padding: 10px 12px; background: #fafbfd; color: var(--text-2); font-weight: 500;
  border-bottom: 1px solid var(--border); white-space: nowrap; }
table.grid td { padding: 10px 12px; border-bottom: 1px solid #f0f1f5; vertical-align: middle; }
table.grid tr:hover td { background: #fbfcff; }
table.grid img.thumb { width: 42px; height: 42px; border-radius: 6px; object-fit: cover; background: #f0f1f5; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; margin-bottom: 16px; }
.stat { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; }
.stat .label { color: var(--text-3); font-size: 12.5px; }
.stat .value { font-size: 24px; font-weight: 700; margin-top: 6px; }
.stat .sub { font-size: 12px; color: var(--text-3); margin-top: 4px; }
.tag { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 12px; background: #f1f2f6; color: var(--text-2); }
.tag.ok { background: #e7f7ee; color: #12783c; }
.tag.off { background: #fdecec; color: #c0343a; }
.tag.warn { background: #fff4e5; color: #b76e00; }
.empty { text-align: center; color: var(--text-3); padding: 46px 0; font-size: 13px; }
.pager { display: flex; justify-content: flex-end; align-items: center; gap: 10px; margin-top: 14px; color: var(--text-2); font-size: 13px; }
.switch { position: relative; display: inline-block; width: 44px; height: 24px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch i { position: absolute; cursor: pointer; inset: 0; background: #d3d6de; border-radius: 20px; transition: .2s; }
.switch i::before { content: ''; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; }
.switch input:checked + i { background: var(--primary); }
.switch input:checked + i::before { transform: translateX(20px); }
.row-flex { display: flex; align-items: center; gap: 10px; }
.money { color: #d4380d; font-weight: 600; }
.money::before { content: '¥'; font-size: 11px; margin-right: 1px; }

/* ---------- 弹窗 / Toast ---------- */
.mask { position: fixed; inset: 0; background: rgba(18, 22, 33, .45); display: flex; align-items: center;
  justify-content: center; z-index: 1000; padding: 24px; }
.dialog { background: #fff; border-radius: 12px; width: 620px; max-width: 100%; max-height: 86vh; overflow: auto;
  box-shadow: 0 12px 40px rgba(0,0,0,.18); }
.dialog.wide { width: 900px; }
.dialog-head { padding: 16px 20px; border-bottom: 1px solid var(--border); font-weight: 600; display: flex;
  align-items: center; justify-content: space-between; }
.dialog-body { padding: 20px; }
.dialog-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }
.dialog .close { cursor: pointer; color: var(--text-3); font-size: 18px; }
#toast-root { position: fixed; top: 18px; left: 50%; transform: translateX(-50%); z-index: 2000; }
.toast { background: #1f2437; color: #fff; padding: 10px 18px; border-radius: 8px; margin-bottom: 10px; font-size: 13px;
  box-shadow: var(--shadow); animation: fade .25s; }
.toast.ok { background: #12a150; }
.toast.err { background: #e5484d; }
@keyframes fade { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; } }

/* ---------- DIY 编辑器 ---------- */
.diy { display: grid; grid-template-columns: 172px 1fr 316px; gap: 14px; align-items: start; }
.diy-col { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.diy-col h4 { margin: 0; padding: 12px 14px; border-bottom: 1px solid var(--border); font-size: 13.5px; }
.palette { padding: 10px; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.palette .comp { border: 1px dashed #cfd4e2; border-radius: 8px; padding: 10px 6px; text-align: center; cursor: pointer;
  font-size: 12.5px; color: var(--text-2); background: #fbfcff; }
.palette .comp:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-weak); }
.palette .comp b { display: block; font-size: 15px; margin-bottom: 3px; color: inherit; }
.phone-frame { padding: 16px; display: flex; justify-content: center; background: #f0f2f7; min-height: 620px; }
.phone { width: 375px; background: #fff; border-radius: 14px; box-shadow: 0 6px 24px rgba(0,0,0,.1); overflow: hidden; min-height: 600px; }
.phone-bar { height: 34px; background: #fff; display: flex; align-items: center; justify-content: center;
  font-size: 12px; color: #111; border-bottom: 1px solid #f0f1f5; letter-spacing: 1px; }
.phone-body { padding: 0 0 20px; min-height: 560px; }
.pv { padding: 8px 10px; position: relative; cursor: pointer; border: 1px dashed transparent; }
.pv:hover { border-color: #b9c2ff; background: #fbfcff; }
.pv.active { border-color: var(--primary); background: var(--primary-weak); }
.pv-ops { position: absolute; right: 4px; top: 4px; display: none; gap: 4px; z-index: 3; }
.pv:hover .pv-ops, .pv.active .pv-ops { display: flex; }
.pv-ops span { background: rgba(31,36,55,.82); color: #fff; font-size: 11px; padding: 2px 7px; border-radius: 4px; cursor: pointer; }
.pv.dragging { opacity: .4; }
.pv.drop-hint { border-top: 2px solid var(--primary); }
.props { padding: 14px; max-height: 74vh; overflow: auto; }
.props .empty { padding: 40px 10px; }
/* 手机预览内的组件渲染 */
.pv-image .ph { background: #f2f3f7; color: #a8aebd; display: flex; align-items: center; justify-content: center; font-size: 12px; }
.pv-goods { display: grid; gap: 8px; }
.pv-goods.col2 { grid-template-columns: 1fr 1fr; }
.pv-card { border: 1px solid #eef0f5; border-radius: 8px; overflow: hidden; background: #fff; }
.pv-card .cover { height: 96px; background: #f2f3f7; display: flex; align-items: center; justify-content: center; color: #b6bccb; font-size: 11px; }
.pv-card .cover img { width: 100%; height: 100%; object-fit: cover; }
.pv-card .info { padding: 7px 8px; }
.pv-card .t { font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pv-card .p { color: #d4380d; font-size: 13px; font-weight: 600; margin-top: 3px; }
.pv-card .s { color: #a0a6b4; font-size: 11px; }
.pv-cates { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.pv-cate { text-align: center; font-size: 11.5px; }
.pv-cate .ic { width: 44px; height: 44px; border-radius: 50%; background: #f2f3f7; margin: 0 auto 4px; display: flex;
  align-items: center; justify-content: center; color: #b6bccb; font-size: 11px; overflow: hidden; }
.pv-cate .ic img { width: 100%; height: 100%; object-fit: cover; }
.pv-board { border: 1px solid #eef0f5; border-radius: 8px; padding: 8px; font-size: 12px; }
.pv-board .row { display: flex; align-items: center; gap: 8px; padding: 5px 0; border-bottom: 1px dashed #f0f1f5; }
.pv-board .row:last-child { border-bottom: 0; }
.pv-board .rk { width: 20px; height: 20px; border-radius: 50%; background: #f1f2f6; color: #5c6470; font-size: 11px;
  display: flex; align-items: center; justify-content: center; flex: none; }
.pv-board .rk.top { background: #ffe9cc; color: #b76e00; }
.mat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 10px; }
.mat-item { border: 1px solid var(--border); border-radius: 8px; overflow: hidden; cursor: pointer; position: relative; }
.mat-item:hover { border-color: var(--primary); }
.mat-item.sel { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-weak); }
.mat-item img { width: 100%; height: 84px; object-fit: cover; display: block; background: #f2f3f7; }
.mat-item .nm { font-size: 11px; padding: 4px 6px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mat-item .del { position: absolute; right: 4px; top: 4px; background: rgba(0,0,0,.5); color: #fff; border-radius: 4px;
  font-size: 11px; padding: 1px 5px; }
.qr-box { text-align: center; }
.qr-box img { width: 220px; height: 220px; background: #f7f8fb; border: 1px solid var(--border); border-radius: 10px; }
.copy-row { display: flex; gap: 8px; margin-top: 8px; }
.copy-row input { flex: 1; font-family: monospace; font-size: 12px; }
