* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --brand: #fa5151;
  --brand-deep: #e0413f;
  --ink: #1f2329;
  --ink-2: #646a73;
  --ink-3: #8f959e;
  --line: #e7e9ec;
  --bg: #f5f6f8;
  --side: #1f2733;
  --side-2: #2b3543;
  --ok: #2faa5e;
  --warn: #e6a23c;
}
body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  font-size: 14px;
}
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 14px; }
.hidden { display: none !important; }

/* ---------- 登录 ---------- */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #2b3543, #1f2733);
}
.login-card {
  width: 360px; background: #fff; border-radius: 14px; padding: 36px 32px;
  box-shadow: 0 20px 50px rgba(0,0,0,.25);
}
.login-card h1 { font-size: 20px; margin-bottom: 4px; text-align: center; }
.login-card .sub { color: var(--ink-3); font-size: 13px; margin-bottom: 26px; text-align: center; }
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; color: var(--ink-2); margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px;
  outline: none; transition: border-color .15s;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--brand); }
.btn-primary {
  width: 100%; padding: 11px; border: none; border-radius: 8px; background: var(--brand);
  color: #fff; font-size: 15px; font-weight: 600; transition: background .15s;
}
.btn-primary:hover { background: var(--brand-deep); }
.err { color: var(--brand); font-size: 13px; min-height: 18px; margin-top: 8px; }

/* ---------- 框架 ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar { width: 210px; background: var(--side); color: #cdd3db; flex-shrink: 0; display: flex; flex-direction: column; }
.brand { padding: 20px 22px; font-size: 17px; font-weight: 700; color: #fff; display: flex; align-items: center; gap: 10px; }
.brand .logo { width: 26px; height: 26px; }
.nav { flex: 1; padding: 8px 0; }
.nav-item {
  display: flex; align-items: center; gap: 12px; padding: 12px 22px; color: #c2c9d2;
  font-size: 14px; cursor: pointer; border-left: 3px solid transparent; position: relative;
}
.nav-item:hover { background: var(--side-2); color: #fff; }
.nav-item.active { background: var(--side-2); color: #fff; border-left-color: var(--brand); }
.nav-item .ico { width: 18px; height: 18px; flex-shrink: 0; }
.nav-badge {
  margin-left: auto; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--brand); color: #fff; font-size: 11px; line-height: 18px; text-align: center;
}
.side-foot { padding: 16px 22px; border-top: 1px solid rgba(255,255,255,.08); font-size: 12px; color: #7a828d; }
.side-foot a { color: #9aa3ad; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 58px; background: #fff; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; padding: 0 24px;
}
.topbar .title { font-size: 16px; font-weight: 600; }
.topbar .user { display: flex; align-items: center; gap: 14px; color: var(--ink-2); font-size: 13px; }
.logout { padding: 6px 14px; border: 1px solid var(--line); background: #fff; border-radius: 7px; color: var(--ink-2); }
.logout:hover { border-color: var(--brand); color: var(--brand); }
.content { padding: 24px; flex: 1; overflow: auto; }

/* ---------- 概览卡片 ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 16px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 20px; }
.stat .label { color: var(--ink-3); font-size: 13px; }
.stat .num { font-size: 30px; font-weight: 700; margin-top: 8px; }
.stat.alert .num { color: var(--brand); }

/* ---------- 工具条 ---------- */
.toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar .grow { flex: 1; }
.btn {
  padding: 8px 16px; border: 1px solid var(--line); background: #fff; border-radius: 8px;
  color: var(--ink); font-size: 13px; transition: all .15s;
}
.btn:hover { border-color: var(--brand); color: var(--brand); }
.btn.solid { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn.solid:hover { background: var(--brand-deep); color: #fff; }
.btn.sm { padding: 5px 12px; font-size: 12px; }
.btn.ok { color: var(--ok); border-color: #bfe6cd; }
.btn.ok:hover { background: var(--ok); color: #fff; }
.btn.danger { color: var(--brand); }
.btn.danger:hover { background: var(--brand); color: #fff; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #fff; }
.seg button { padding: 7px 14px; border: none; background: #fff; color: var(--ink-2); font-size: 13px; border-right: 1px solid var(--line); }
.seg button:last-child { border-right: none; }
.seg button.on { background: var(--brand); color: #fff; }

/* ---------- 表格 ---------- */
.card { background: #fff; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 13px 16px; text-align: left; border-bottom: 1px solid var(--line); font-size: 13px; vertical-align: middle; }
th { background: #fafbfc; color: var(--ink-2); font-weight: 600; white-space: nowrap; }
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #fafbfc; }
.thumb { width: 50px; height: 50px; border-radius: 8px; background: #f5f6f8 center/cover no-repeat; border: 1px solid var(--line); }
.muted { color: var(--ink-3); }
.price-retail { color: var(--ink); font-weight: 600; }
.price-wholesale { color: var(--brand); font-weight: 600; }
.tag { display: inline-block; padding: 2px 9px; border-radius: 6px; font-size: 12px; }
.tag.on { background: #eaf7ef; color: var(--ok); }
.tag.off { background: #f1f2f4; color: var(--ink-3); }
.tag.pending { background: #fdf3e6; color: var(--warn); }
.tag.approved { background: #eaf7ef; color: var(--ok); }
.tag.rejected { background: #fbecec; color: var(--brand); }
.tag.badge { background: #fdecec; color: var(--brand); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.empty { padding: 50px; text-align: center; color: var(--ink-3); }

/* ---------- 弹窗 ---------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: center; justify-content: center; z-index: 50;
}
.modal { background: #fff; border-radius: 14px; width: 600px; max-width: 92vw; max-height: 90vh; display: flex; flex-direction: column; }
.modal-head { padding: 18px 22px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; }
.modal-head h3 { font-size: 16px; }
.modal-x { width: 30px; height: 30px; border: none; background: #f1f2f4; border-radius: 8px; color: var(--ink-2); font-size: 18px; line-height: 1; }
.modal-body { padding: 22px; overflow: auto; }
.modal-foot { padding: 16px 22px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 12px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.check { display: flex; align-items: center; gap: 8px; }
.check input { width: auto; }

/* 图片上传 */
.upload { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.upload .preview { width: 84px; height: 84px; border-radius: 10px; border: 1px solid var(--line); background: #f5f6f8 center/cover no-repeat; }
.upload-list { display: flex; gap: 10px; flex-wrap: wrap; }
.upload-list .item { position: relative; width: 72px; height: 72px; border-radius: 8px; border: 1px solid var(--line); background: #f5f6f8 center/cover no-repeat; }
.upload-list .item .del { position: absolute; top: -7px; right: -7px; width: 20px; height: 20px; border-radius: 50%; background: var(--brand); color: #fff; border: 2px solid #fff; font-size: 12px; line-height: 16px; text-align: center; cursor: pointer; }
.hint { color: var(--ink-3); font-size: 12px; margin-top: 6px; }

/* 详情查看 */
.detail-view .dv-img { width: 100%; max-width: 280px; border-radius: 12px; border: 1px solid var(--line); display: block; margin-bottom: 16px; }
.detail-view h2 { font-size: 18px; margin-bottom: 10px; }
.dv-prices { display: flex; gap: 24px; margin: 12px 0 18px; }
.dv-prices .blk .k { font-size: 12px; color: var(--ink-3); }
.dv-prices .blk .v { font-size: 22px; font-weight: 700; }
.dv-prices .blk .v.w { color: var(--brand); }
.dv-text { color: var(--ink-2); line-height: 1.8; white-space: pre-wrap; }
.dv-gallery { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.dv-gallery img { width: 90px; border-radius: 8px; border: 1px solid var(--line); }

.toast {
  position: fixed; top: 20px; left: 50%; transform: translateX(-50%); z-index: 100;
  background: rgba(31,35,41,.92); color: #fff; padding: 10px 20px; border-radius: 8px; font-size: 13px;
  opacity: 0; transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(4px); }
