/* 贝维好物 · 电商平台共用样式（商城前台 + 商家后台） */
:root {
  --bg: #f5f7fb; --card: #ffffff; --text: #0f172a; --muted: #64748b;
  --line: #e8edf5; --primary: #4f46e5; --primary2: #2563eb; --price: #e11d48;
  --ok: #16a34a; --warn: #d97706; --danger: #dc2626;
  --shadow: 0 8px 28px rgba(15, 23, 42, .07);
  --shadow-lg: 0 20px 60px rgba(15, 23, 42, .16);
  --radius: 16px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.6;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
}
a { color: var(--primary2); text-decoration: none; }
button, input, select, textarea { font-family: inherit; font-size: 14px; }
button { cursor: pointer; }
.hidden { display: none !important; }

/* ===== 顶部导航 ===== */
.topbar { position: sticky; top: 0; z-index: 40; background: rgba(255,255,255,.94); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); }
.topbar .inner { max-width: 1200px; margin: 0 auto; padding: 12px 20px; display: flex; align-items: center; gap: 20px; }
.logo { font-size: 19px; font-weight: 800; letter-spacing: .5px; white-space: nowrap; display: flex; align-items: center; gap: 8px; }
.logo .mark { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; color: #fff; font-size: 18px; background: linear-gradient(135deg, #6366f1, #2563eb); }
.logo small { display: block; font-size: 10px; font-weight: 500; color: var(--muted); letter-spacing: 1px; }
.searchbox { flex: 1; display: flex; align-items: center; gap: 8px; background: #f1f5fb; border: 1px solid var(--line); border-radius: 999px; padding: 7px 16px; max-width: 420px; }
.searchbox input { flex: 1; border: 0; outline: 0; background: transparent; }
.searchbox .ico { color: var(--muted); }
.nav-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.nav-actions .linkbtn { background: none; border: 0; color: var(--text); padding: 7px 10px; border-radius: 9px; font-weight: 600; }
.nav-actions .linkbtn:hover { background: #eef2ff; color: var(--primary); }
.cartbtn { position: relative; }
.cartbtn .dot { position: absolute; top: -3px; right: -3px; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 9px; background: var(--price); color: #fff; font-size: 11px; line-height: 18px; text-align: center; font-weight: 700; }

/* ===== 通用元素 ===== */
.wrap { max-width: 1200px; margin: 0 auto; padding: 22px 20px 60px; }
.notice { display: flex; gap: 10px; align-items: flex-start; background: #fffbeb; border: 1px solid #fde68a; color: #92400e; border-radius: 12px; padding: 11px 15px; font-size: 13px; margin-bottom: 18px; }
.notice b { color: #b45309; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid transparent; border-radius: 10px; padding: 9px 16px; font-weight: 700; background: var(--primary); color: #fff; transition: .15s; white-space: nowrap; }
.btn:hover { filter: brightness(1.08); transform: translateY(-1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn-ghost { background: #fff; color: var(--text); border-color: var(--line); }
.btn-ghost:hover { border-color: var(--primary); color: var(--primary); }
.btn-sm { padding: 5px 11px; font-size: 12px; border-radius: 8px; }
.btn-danger { background: var(--danger); }
.btn-ok { background: var(--ok); }
.btn-block { width: 100%; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.sec-title { display: flex; align-items: center; justify-content: space-between; margin: 4px 0 16px; }
.sec-title h2 { font-size: 20px; margin: 0; }
.sec-title .sub { color: var(--muted); font-size: 13px; }
.muted { color: var(--muted); }
.price { color: var(--price); font-weight: 800; }
.price .cur { font-size: .75em; }
.price-old { color: #94a3b8; text-decoration: line-through; font-size: 12px; margin-left: 6px; font-weight: 400; }
.tag { display: inline-block; font-size: 11px; padding: 2px 7px; border-radius: 6px; background: #eef2ff; color: var(--primary); margin-right: 5px; }
.tag.hot { background: #fff1f2; color: var(--price); }
.tag.ok { background: #ecfdf5; color: var(--ok); }
.tag.warn { background: #fffbeb; color: var(--warn); }
.empty { text-align: center; padding: 54px 20px; color: var(--muted); }
.empty .big { font-size: 44px; display: block; margin-bottom: 10px; }
.divider { height: 1px; background: var(--line); margin: 16px 0; }

/* ===== 商品列表 ===== */
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.chip { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 6px 15px; font-weight: 600; color: var(--muted); }
.chip.on { background: var(--primary); color: #fff; border-color: var(--primary); }
.sorts { display: flex; gap: 6px; align-items: center; }
.grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
@media (max-width: 1000px) { .grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 720px) { .grid { grid-template-columns: repeat(2, 1fr); } .topbar .inner { flex-wrap: wrap; } .searchbox { order: 3; max-width: none; width: 100%; } }
.product { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); display: flex; flex-direction: column; transition: .18s; }
.product:hover { transform: translateY(-3px); box-shadow: 0 14px 34px rgba(15,23,42,.12); }
.cover { height: 148px; display: grid; place-items: center; font-size: 66px; cursor: pointer; position: relative; }
.cover.violet { background: linear-gradient(135deg, #ede9fe, #c4b5fd); }
.cover.blue { background: linear-gradient(135deg, #dbeafe, #93c5fd); }
.cover.cyan { background: linear-gradient(135deg, #cffafe, #67e8f9); }
.cover.green { background: linear-gradient(135deg, #dcfce7, #86efac); }
.cover.orange { background: linear-gradient(135deg, #ffedd5, #fdba74); }
.cover.brown { background: linear-gradient(135deg, #f5e6d3, #d6b08c); }
.cover .stock { position: absolute; right: 9px; top: 9px; background: rgba(255,255,255,.9); border-radius: 7px; font-size: 11px; padding: 2px 7px; color: var(--muted); }
.p-body { padding: 13px 14px 15px; display: flex; flex-direction: column; flex: 1; }
.p-title { font-weight: 700; font-size: 15px; margin: 0 0 3px; cursor: pointer; }
.p-sub { color: var(--muted); font-size: 12px; min-height: 20px; }
.p-tags { margin: 7px 0; min-height: 22px; }
.p-foot { margin-top: auto; display: flex; align-items: flex-end; justify-content: space-between; gap: 8px; }
.p-price { font-size: 20px; }
.p-sales { color: var(--muted); font-size: 11px; display: block; margin-bottom: 4px; }

/* ===== 表单 / 弹窗 ===== */
.field { margin-bottom: 13px; }
.field label { display: block; font-size: 12px; font-weight: 700; color: var(--muted); margin-bottom: 5px; }
.input, .select, .textarea { width: 100%; border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 9px 12px; outline: none; color: var(--text); }
.input:focus, .select:focus, .textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,70,229,.1); }
.textarea { min-height: 76px; resize: vertical; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; min-width: 0; }
.mask { position: fixed; inset: 0; z-index: 90; background: rgba(15,23,42,.48); display: flex; align-items: center; justify-content: center; padding: 18px; }
.modal { background: #fff; border-radius: 18px; width: min(460px, 96vw); max-height: 88vh; overflow: auto; box-shadow: var(--shadow-lg); }
.modal.wide { width: min(680px, 96vw); }
.modal-head { padding: 17px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; }
.modal-head h3 { margin: 0; font-size: 17px; }
.modal-head .x { background: none; border: 0; font-size: 22px; color: var(--muted); line-height: 1; }
.modal-body { padding: 20px; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 9px; }
.hint { font-size: 12px; color: var(--muted); margin-top: 5px; }
.alert { border-radius: 10px; padding: 10px 13px; font-size: 13px; margin-bottom: 14px; }
.alert.err { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }
.alert.info { background: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe; }
.alert.ok { background: #ecfdf5; color: #15803d; border: 1px solid #a7f3d0; }
.toast { position: fixed; left: 50%; bottom: 32px; transform: translateX(-50%); z-index: 120; background: rgba(15,23,42,.94); color: #fff; padding: 11px 20px; border-radius: 10px; box-shadow: var(--shadow-lg); font-weight: 600; }

/* ===== 购物车 / 结算 / 订单 ===== */
.line-item { display: flex; align-items: center; gap: 14px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.line-item:last-child { border-bottom: 0; }
.thumb { width: 64px; height: 64px; border-radius: 12px; display: grid; place-items: center; font-size: 32px; flex-shrink: 0; cursor: pointer; }
.li-main { flex: 1; min-width: 0; }
.li-title { font-weight: 700; }
.qty { display: inline-flex; align-items: center; gap: 0; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.qty button { width: 28px; height: 28px; border: 0; background: #f8fafc; font-size: 16px; }
.qty span { min-width: 32px; text-align: center; font-weight: 700; }
.totalbar { display: flex; align-items: center; justify-content: flex-end; gap: 18px; padding: 16px 0 0; border-top: 1px solid var(--line); margin-top: 8px; }
.totalbar .sum { font-size: 22px; font-weight: 800; color: var(--price); }
.pay-options { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.pay-opt { border: 1px solid var(--line); border-radius: 12px; padding: 12px; display: flex; gap: 10px; align-items: flex-start; cursor: pointer; background: #fff; }
.pay-opt.on { border-color: var(--primary); background: #f5f4ff; box-shadow: 0 0 0 2px rgba(79,70,229,.12); }
.pay-opt .ico { font-size: 22px; }
.pay-opt .nm { font-weight: 700; }
.pay-opt .ds { font-size: 11px; color: var(--muted); }
.order-card { padding: 16px 18px; margin-bottom: 14px; }
.order-head { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--line); padding-bottom: 10px; margin-bottom: 10px; font-size: 13px; }
.status { font-weight: 700; }
.status.pending_pay { color: var(--warn); }
.status.paid { color: var(--primary2); }
.status.shipped { color: #0891b2; }
.status.completed { color: var(--ok); }
.status.cancelled { color: #94a3b8; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.tabs .chip { border-radius: 9px; }
.detail-grid { display: grid; grid-template-columns: 1.1fr .9fr; gap: 18px; }
@media (max-width: 800px) { .detail-grid { grid-template-columns: 1fr; } .pay-options { grid-template-columns: 1fr; } }
.detail-cover { height: 300px; border-radius: 16px; display: grid; place-items: center; font-size: 130px; }

/* ===== 客服浮窗 ===== */
.chat-fab { position: fixed; right: 20px; bottom: 22px; z-index: 60; width: 54px; height: 54px; border-radius: 50%; border: 0; background: linear-gradient(135deg, #6366f1, #2563eb); color: #fff; font-size: 23px; box-shadow: 0 10px 28px rgba(79,70,229,.4); }
.chat-panel { position: fixed; right: 20px; bottom: 88px; z-index: 60; width: min(360px, 92vw); height: min(520px, 74vh); background: #fff; border-radius: 18px; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; overflow: hidden; }
.chat-head { background: linear-gradient(135deg, #4f46e5, #2563eb); color: #fff; padding: 13px 16px; display: flex; justify-content: space-between; align-items: center; }
.chat-head b { font-size: 15px; }
.chat-head button { background: none; border: 0; color: #fff; font-size: 20px; }
.chat-body { flex: 1; overflow: auto; padding: 14px; background: #f8fafc; }
.bubble { max-width: 84%; padding: 9px 12px; border-radius: 13px; margin-bottom: 10px; white-space: pre-wrap; word-break: break-word; font-size: 13px; }
.bubble.me { margin-left: auto; background: var(--primary); color: #fff; border-bottom-right-radius: 3px; }
.bubble.ai { background: #fff; border: 1px solid var(--line); border-bottom-left-radius: 3px; }
.bubble.sys { background: transparent; color: var(--muted); text-align: center; font-size: 11px; max-width: 100%; }
.bubble .who { font-size: 10px; opacity: .7; display: block; margin-bottom: 2px; }
.chat-foot { border-top: 1px solid var(--line); padding: 10px; display: flex; gap: 8px; }
.chat-foot input { flex: 1; border: 1px solid var(--line); border-radius: 9px; padding: 8px 10px; outline: none; }

/* ===== 商家后台 ===== */
.admin-login { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(135deg, #eef2ff, #e0f2fe); }
.admin-login .box { width: min(400px, 92vw); padding: 30px; }
.admin-login h2 { margin: 0 0 6px; }
.admin-login .sub { color: var(--muted); margin-bottom: 22px; font-size: 13px; }
.layout { display: flex; min-height: 100vh; }
.side { width: 218px; flex-shrink: 0; background: #111827; color: #cbd5e1; padding: 18px 12px; }
.side .brand { color: #fff; font-weight: 800; font-size: 16px; padding: 6px 10px 20px; display: flex; align-items: center; gap: 8px; }
.side .brand .mark { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; background: linear-gradient(135deg,#6366f1,#2563eb); }
.side a { display: block; color: #cbd5e1; padding: 10px 12px; border-radius: 9px; margin-bottom: 3px; font-weight: 600; cursor: pointer; }
.side a:hover { background: #1f2937; color: #fff; }
.side a.on { background: #312e81; color: #fff; }
.side .foot { margin-top: 26px; padding: 12px 10px; border-top: 1px solid #1f2937; font-size: 11px; color: #64748b; }
.main { flex: 1; min-width: 0; }
.main-head { background: #fff; border-bottom: 1px solid var(--line); padding: 15px 24px; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.main-head h1 { margin: 0; font-size: 19px; }
.main-body { padding: 22px 24px 60px; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 20px; }
@media (max-width: 1000px) { .stats { grid-template-columns: repeat(2, 1fr); } .side { width: 64px; } .side a span, .side .brand b, .side .foot { display: none; } }
.stat { padding: 16px 18px; }
.stat .k { color: var(--muted); font-size: 12px; }
.stat .v { font-size: 26px; font-weight: 800; margin-top: 4px; }
.stat .v.red { color: var(--price); }
.stat .v.blue { color: var(--primary2); }
.stat .v.green { color: var(--ok); }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th, .table td { padding: 11px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.table th { color: var(--muted); font-weight: 700; background: #f8fafc; font-size: 12px; }
.table tr:last-child td { border-bottom: 0; }
.table .thumb { width: 38px; height: 38px; font-size: 20px; border-radius: 8px; }
.table-wrap { overflow-x: auto; }
.pane { padding: 20px; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.filters .input, .filters .select { width: auto; min-width: 150px; }
.chat-admin { display: grid; grid-template-columns: 260px 1fr; gap: 14px; min-height: 520px; }
@media (max-width: 900px) { .chat-admin { grid-template-columns: 1fr; } }
.sess-list { border-right: 1px solid var(--line); overflow: auto; max-height: 560px; }
.sess { padding: 12px 14px; border-bottom: 1px solid var(--line); cursor: pointer; }
.sess:hover { background: #f8fafc; }
.sess.on { background: #eef2ff; border-left: 3px solid var(--primary); }
.sess .nm { font-weight: 700; }
.sess .last { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msg-list { height: 380px; overflow: auto; padding: 16px; background: #f8fafc; }
.bubble.staff { margin-left: auto; background: #dbeafe; border-bottom-right-radius: 3px; }
.mat-list { margin: 0; padding-left: 20px; }
.mat-list li { margin-bottom: 5px; }
.mat-card { padding: 18px; margin-bottom: 14px; }
.mat-card h3 { margin: 0 0 8px; font-size: 16px; }
.env-code { font-family: ui-monospace, Consolas, monospace; font-size: 12px; background: #f1f5f9; border-radius: 6px; padding: 1px 5px; }
.footer-note { text-align: center; color: #94a3b8; font-size: 12px; padding: 26px 12px 34px; }
