/* 南粤精选荟 - 小程序运营管理后台
   设计语言: 简约清新, 主色与小程序端一致 (#ff6b6b) */

* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --primary: #ff6b6b;
  --primary-dark: #ee5253;
  --primary-light: #fff1f1;
  --text: #2d3436;
  --text-sub: #636e72;
  --text-muted: #b2bec3;
  --border: #ebedf0;
  --bg: #f7f8fa;
  --card: #fff;
  --green: #00b894;
  --orange: #fdcb6e;
  --blue: #0984e3;
  --red: #d63031;
  --radius: 10px;
  --shadow: 0 2px 12px rgba(0, 0, 0, .06);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Microsoft YaHei', 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
}

/* ============ 登录页 ============ */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #b7e4c7 0%, #d8f3dc 50%, #f2faf4 100%);
}

.login-box {
  width: 380px;
  background: var(--card);
  border-radius: 16px;
  padding: 48px 40px 40px;
  box-shadow: 0 12px 40px rgba(255, 107, 107, .16);
}

.login-logo {
  text-align: center;
  margin-bottom: 32px;
}

.login-logo .name {
  font-size: 30px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 1px;
}

.login-logo .sub {
  font-size: 26px;
  color: var(--text-muted);
  margin-top: 8px;
}

/* 登录按钮用绿色，与浅绿页面呼应（不影响后台内部的红色主题） */
.login-box .btn-primary { background: #00b894; border-color: #00b894; }
.login-box .btn-primary:hover { background: #00a383; border-color: #00a383; }

/* ============ 布局 ============ */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 200px;
  background: #fff;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  overflow-y: auto;
}

.sidebar-brand {
  padding: 20px 18px;
  border-bottom: 1px solid var(--border);
  font-size: 15px;
  font-weight: 600;
  color: var(--primary);
}

.sidebar-brand small {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 400;
  margin-top: 2px;
}

.menu-group-title {
  padding: 14px 18px 6px;
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 1px;
}

.menu-item {
  padding: 10px 18px;
  cursor: pointer;
  color: var(--text-sub);
  display: flex;
  align-items: center;
  border-left: 3px solid transparent;
  transition: all .15s;
  font-size: 14px;
}

.menu-item:hover { background: var(--bg); color: var(--text); }

.menu-item.active {
  background: var(--primary-light);
  color: var(--primary);
  border-left-color: var(--primary);
  font-weight: 500;
}

.main { flex: 1; margin-left: 200px; display: flex; flex-direction: column; min-width: 0; }

.topbar {
  height: 56px;
  background: #fff;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar .title { font-size: 16px; font-weight: 600; }
.topbar .right { display: flex; align-items: center; gap: 14px; font-size: 13px; color: var(--text-sub); }

.content { padding: 20px 24px 40px; flex: 1; }

/* ============ 卡片 / 按钮 ============ */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
  margin-bottom: 16px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 7px 16px;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text);
  transition: all .15s;
  white-space: nowrap;
}

.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); color: #fff; }
.btn-danger { color: var(--red); border-color: #ffd6d6; }
.btn-danger:hover { background: var(--red); border-color: var(--red); color: #fff; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 8px 11px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  outline: none;
  font-family: inherit;
  background: #fff;
  color: var(--text);
}

.form-input:focus, .form-select:focus, .form-textarea:focus { border-color: var(--primary); }
.form-textarea { min-height: 90px; resize: vertical; line-height: 1.7; }

/* ============ 表格 ============ */
.table-wrap { overflow-x: auto; }

table.grid { width: 100%; border-collapse: collapse; font-size: 13px; }

table.grid th {
  text-align: left;
  padding: 11px 12px;
  background: #fafbfc;
  color: var(--text-sub);
  font-weight: 500;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

table.grid td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

table.grid tr:hover td { background: #fcfcfd; }

.thumb { width: 46px; height: 46px; border-radius: 6px; object-fit: cover; background: var(--bg); }

/* 列表内直接编辑排序: 数字越小越靠前 */
.sort-input {
  width: 68px;
  padding: 5px 6px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  text-align: center;
  background: #fff;
  color: var(--text);
}
.sort-input:focus { border-color: var(--primary); outline: none; }

.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  line-height: 1.6;
}

.tag-green { background: #e8f9f4; color: var(--green); }
.tag-red { background: #ffeaea; color: var(--red); }
.tag-orange { background: #fff6e5; color: #e17055; }
.tag-blue { background: #e8f2fd; color: var(--blue); }
.tag-gray { background: #f1f2f6; color: var(--text-muted); }

.money { color: var(--primary); font-weight: 600; }
.muted { color: var(--text-muted); }
.nowrap { white-space: nowrap; }

/* ============ 筛选栏 ============ */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 14px;
}

.toolbar .form-input, .toolbar .form-select { width: auto; min-width: 130px; }

/* 工具栏内联复选框(如「显示已停用」) */
.chk-inline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 10px;
  height: 34px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: var(--text-regular);
  font-size: 13px;
  cursor: pointer;
  user-select: none;
}
.chk-inline:hover { border-color: var(--primary); color: var(--primary); }
.chk-inline input { margin: 0; cursor: pointer; }

/* ============ 弹窗 ============ */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .45);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  z-index: 100;
  padding: 24px 20px;
  overflow-y: auto;
}

.modal {
  background: #fff;
  border-radius: 12px;
  width: 100%;
  max-width: 640px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .2);
  animation: pop .18s ease-out;
}

.modal.wide { max-width: 880px; }
/* 含富文本编辑器的弹窗再宽一档, 图文排版才看得清 */
.modal.xwide { max-width: 1180px; }

@keyframes pop {
  from { opacity: 0; transform: translateY(-14px); }
  to { opacity: 1; transform: none; }
}

.modal-head {
  padding: 16px 22px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 15px;
  font-weight: 600;
}

.modal-close { cursor: pointer; color: var(--text-muted); font-size: 20px; line-height: 1; }
.modal-close:hover { color: var(--text); }

.modal-body { padding: 20px 22px; max-height: calc(100vh - 150px); overflow-y: auto; }

.modal-foot {
  padding: 14px 22px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.form-row { margin-bottom: 16px; }

.form-label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  color: var(--text-sub);
}

.form-label .req { color: var(--primary); }
.form-tip { font-size: 12px; color: var(--text-muted); margin-top: 5px; line-height: 1.5; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }

/* V4 折扣输入组: 折扣% 与 元/盒 双向联动 */
.rate-pair {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.rate-pair .form-input { flex: 1 1 90px; min-width: 80px; }
.rate-sign { font-size: 13px; color: var(--text-muted); white-space: nowrap; }
.rate-preview {
  flex: 1 1 100%;
  font-size: 12px;
  color: var(--primary);
  line-height: 1.5;
}

/* 图片上传 */
.img-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.img-slot {
  width: 84px;
  height: 84px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  position: relative;
  overflow: hidden;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 24px;
  background: #fafbfc;
}

.img-slot:hover { border-color: var(--primary); color: var(--primary); }
.img-slot img { width: 100%; height: 100%; object-fit: cover; }

.img-slot .del {
  position: absolute;
  top: 0;
  right: 0;
  width: 20px;
  height: 20px;
  background: rgba(0, 0, 0, .55);
  color: #fff;
  font-size: 13px;
  line-height: 20px;
  text-align: center;
  cursor: pointer;
}

.img-slot .main-badge {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(255, 107, 107, .9);
  color: #fff;
  font-size: 11px;
  text-align: center;
  line-height: 18px;
}

/* ============ 概览 ============ */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.stat-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
}

.stat-card .label { font-size: 13px; color: var(--text-sub); }
.stat-card .value { font-size: 26px; font-weight: 600; margin-top: 6px; }
.stat-card .value.warn { color: var(--primary); }
.stat-card .sub { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* 明细/报表页: 汇总行 */
.summary-bar {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--border, #eee);
  font-size: 13px;
  color: var(--text-sub);
}
.summary-bar b { font-size: 18px; color: var(--primary); margin-right: 4px; }

/* 可下钻的概况卡片 */
.stat-card-link {
  cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease;
  border: 1px solid transparent;
}
.stat-card-link:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(0, 0, 0, .10);
  border-color: #ffd6cc;
}
.stat-card-link .link-hint {
  font-size: 11px;
  color: var(--primary);
  opacity: .75;
}
.stat-card-link:hover .link-hint { opacity: 1; }

/* ============ 提示 ============ */
.toast {
  position: fixed;
  top: 76px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(45, 52, 54, .94);
  color: #fff;
  padding: 10px 22px;
  border-radius: 8px;
  z-index: 200;
  font-size: 14px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .18);
}

.toast.error { background: var(--red); }
.toast.success { background: var(--green); }

.empty { text-align: center; padding: 50px 0; color: var(--text-muted); }

.loading { text-align: center; padding: 40px 0; color: var(--text-muted); }

.pager {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  font-size: 13px;
  color: var(--text-sub);
}

.link { color: var(--blue); cursor: pointer; }
.link:hover { text-decoration: underline; }

.kv-row { display: grid; grid-template-columns: 110px 1fr; padding: 7px 0; border-bottom: 1px dashed var(--border); }
.kv-row .k { color: var(--text-sub); }
.kv-row:last-child { border-bottom: none; }

@media (max-width: 900px) {
  .sidebar { width: 64px; }
  .sidebar-brand span, .menu-group-title, .menu-item span { display: none; }
  .main { margin-left: 64px; }
  .form-grid { grid-template-columns: 1fr; }
}

/* 侧边栏底部版本号: 用于确认浏览器端是否加载到最新后台代码 */
.sidebar-version {
  margin-top: auto;
  padding: 14rpx 24rpx;
  font-size: 20rpx;
  color: #999;
  line-height: 1.6;
  border-top: 1px solid #2a2f3a;
}

.sidebar-version b {
  color: #ddd;
  font-weight: 600;
}

.sidebar-version.warn {
  color: #e6a23c;
}

.sidebar-version.ok {
  color: #888;
}

/* 设置页: 英文键名降为小字, 中文名为主 */
.key-en {
  color: #bbb;
  font-size: 12px;
}

/* 脱敏标记 */
.tag-secret {
  display: inline-block;
  margin-right: 6px;
  padding: 1px 6px;
  border-radius: 3px;
  background: #eaf7ea;
  color: #1aad19;
  font-size: 12px;
}

/* ===== 待办事项(数据概况页) ===== */
.todo-title { color: #636e72; margin-bottom: 8px; font-size: 14px; }
.todo-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 8px; border-top: 1px solid #f1f2f6;
  cursor: pointer; border-radius: 4px;
}
.todo-row:first-of-type { border-top: none; }
.todo-row:hover { background: #f7f9fc; }
.todo-label { flex: 1; font-size: 14px; color: #2d3436; }
.todo-badge {
  min-width: 26px; height: 20px; line-height: 20px; text-align: center;
  padding: 0 7px; border-radius: 10px; background: #f1f2f6; color: #8395a7;
  font-size: 12px; font-weight: 600;
}
.todo-badge.danger { background: #ffecec; color: #e74c3c; }
.todo-go { font-size: 12px; color: #0984e3; }

/* ===== 富文本编辑器(wangEditor)适配 =====
   商品详情 / 分销合作协议共用; 编辑器本体已本地化到 /admin/vendor/wangeditor/ */
.rt-shell { width: 100%; }

/* 工具栏贴上边框、编辑区接下边框, 拼成一个整体(默认样式是两段灰边, 在弹窗里很突兀) */
.rt-shell .w-e-toolbar {
  border: 1px solid var(--border) !important;
  border-bottom: none !important;
  border-radius: 8px 8px 0 0;
  background: #fafbfc !important;
  flex-wrap: wrap;
}
.rt-shell .w-e-text-container {
  border: 1px solid var(--border) !important;
  border-radius: 0 0 8px 8px;
  /* wangEditor 的 config.height 实测不生效, 用 CSS 锁死高度更可靠;
     必须 >=300px, 否则它自己会告警 hoverbar 定位异常 */
  height: 420px !important;
  background: #fff !important;
}
/* 图片强制撑满: 小程序 <rich-text> 的 img 不自适应宽度, 不锁死会溢出屏幕。
   编辑器里也按 100% 显示 -> 所见即所得, 保存时 rtNormalize 再统一成 width="100%"。 */
.rt-shell .w-e-text-container .w-e-image-container { width: 100% !important; display: block !important; }
.rt-shell .w-e-text-container .w-e-image-container img { width: 100% !important; height: auto !important; }
.rt-shell .w-e-bar-item-menus-container { z-index: 120; }

/* 编辑器没加载出来时的降级提示 */
.rt-degrade {
  margin-bottom: 8px; padding: 6px 10px; border-radius: 6px;
  background: #fff8e1; color: #b7791f; font-size: 13px;
}

/* 整行字段(富文本编辑器需要完整宽度) */
.form-grid .span2 { grid-column: 1 / -1; }
