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

[hidden] { display: none !important; }

body {
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", system-ui, sans-serif;
  background: #f2f7fa;
  color: #2c3e50;
  min-height: 100vh;
}

.container { max-width: 1000px; margin: 0 auto; padding: 0 20px; }

/* 头部 */
.site-header {
  background: linear-gradient(135deg, #6ec6e8, #8fd3c7);
  color: #fff;
  padding: 14px 0;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .08);
}
.header-inner { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; justify-content: space-between; }
.site-header h1 { font-size: 22px; }
.logo { color: #fff; text-decoration: none; font-size: 22px; font-weight: 700; white-space: nowrap; }
.nav-links { display: flex; gap: 16px; }
.nav-links a { color: #fff; text-decoration: none; font-size: 15px; opacity: .92; }
.nav-links a:hover { opacity: 1; text-decoration: underline; }
.header-right { display: flex; align-items: center; gap: 12px; margin-left: auto; flex-wrap: wrap; }
.search-input {
  border: none;
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 14px;
  width: 200px;
  outline: none;
  background: rgba(255, 255, 255, .92);
}
.search-input:focus { background: #fff; box-shadow: 0 0 0 2px rgba(255, 255, 255, .5); }
.admin-link { color: #fff; text-decoration: none; opacity: .9; font-size: 14px; }
.admin-link:hover { opacity: 1; text-decoration: underline; }

.section-title { margin: 28px 0 16px; font-size: 18px; }

/* 商品卡片 */
.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  padding-bottom: 40px;
}
.product-card {
  background: #fff;
  border-radius: 16px;
  padding: 22px 18px;
  box-shadow: 0 2px 8px rgba(80, 120, 160, .08);
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: transform .15s, box-shadow .15s;
}
.product-card:hover { transform: translateY(-3px); box-shadow: 0 6px 16px rgba(80, 120, 160, .14); }
.product-name { font-size: 16px; font-weight: 600; word-break: break-all; }
.product-price { color: #2e86de; font-size: 20px; font-weight: 700; }
.empty-tip { color: #999; text-align: center; margin: 60px 0; }

/* 商品介绍 */
.product-desc { font-size: 13px; color: #888; line-height: 1.6; white-space: pre-wrap; word-break: break-word; }

textarea {
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  resize: vertical;
  width: 100%;
}
textarea:focus { border-color: #4a90e2; }
#addDesc { flex-basis: 100%; }
.prod-table td textarea { margin-top: 6px; font-size: 13px; }

/* 按钮 */
.btn {
  border: none;
  border-radius: 8px;
  padding: 9px 18px;
  font-size: 14px;
  cursor: pointer;
  transition: filter .15s;
}
.btn:hover { filter: brightness(1.08); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: #4a90e2; color: #fff; }
.btn-danger { background: #e74c3c; color: #fff; }
.btn-light { background: rgba(255, 255, 255, .25); color: #fff; }
.buy-btn { margin-top: auto; }

/* 弹窗 */
.modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, .55); }
.modal-box {
  position: relative;
  background: #fff;
  border-radius: 14px;
  padding: 28px 32px;
  text-align: center;
  max-width: 340px;
  width: calc(100% - 40px);
  box-shadow: 0 10px 40px rgba(0, 0, 0, .25);
}
.modal-close {
  position: absolute;
  top: 8px;
  right: 12px;
  border: none;
  background: none;
  font-size: 24px;
  color: #999;
  cursor: pointer;
}
.modal-close:hover { color: #333; }
.modal-box h3 { font-size: 18px; margin-bottom: 6px; word-break: break-all; }
.pay-price { color: #2e86de; font-size: 26px; font-weight: 700; margin-bottom: 14px; }
.pay-qr { width: 220px; height: 220px; object-fit: contain; border: 1px solid #eee; border-radius: 8px; background: #fafafa; }
.pay-hint { margin-top: 14px; color: #888; font-size: 13px; }

/* 后台 */
.admin-main { padding: 24px 0 60px; display: flex; flex-direction: column; gap: 20px; }
.panel {
  background: #fff;
  border-radius: 14px;
  padding: 20px 22px;
  box-shadow: 0 2px 8px rgba(80, 120, 160, .08);
}
.panel h2 { font-size: 17px; margin-bottom: 14px; }
.inline-form { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

input[type="text"], input[type="password"], input[type="number"] {
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 14px;
  outline: none;
  min-width: 0;
}
input:focus { border-color: #4a90e2; }
#addName { flex: 1; min-width: 180px; }
#addPrice { width: 130px; }

.prod-table { width: 100%; border-collapse: collapse; }
.prod-table th, .prod-table td { text-align: left; padding: 8px 6px; border-bottom: 1px solid #f0f0f0; }
.prod-table th { color: #999; font-size: 13px; font-weight: 500; }
.prod-table input { width: 100%; }
.prod-table td:last-child { white-space: nowrap; }
.prod-table .btn { padding: 6px 12px; font-size: 13px; margin-right: 6px; }

.qr-row { margin-bottom: 12px; }
.qr-preview { width: 160px; height: 160px; object-fit: contain; border: 1px solid #eee; border-radius: 8px; background: #fafafa; }

.muted { color: #999; }
.small { font-size: 12px; margin-top: 8px; }
.muted-link { color: #bbb; font-size: 13px; text-decoration: none; }
.muted-link:hover { color: #fff; }
.error { color: #e74c3c; font-size: 13px; min-height: 18px; }

/* 登录卡片 */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #6ec6e8, #8fd3c7); }
.login-card {
  background: #fff;
  border-radius: 14px;
  padding: 36px 34px;
  width: 340px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, .2);
}
.login-card h1 { font-size: 20px; text-align: center; margin-bottom: 6px; }
.login-card .muted-link { color: #aaa; text-align: center; }
.login-card .muted-link:hover { color: #666; }

/* 提示条 */
.toast {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  background: #333;
  color: #fff;
  padding: 10px 22px;
  border-radius: 22px;
  font-size: 14px;
  z-index: 200;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .3);
}

/* ---------- 客服聊天 ---------- */
.chat-fab {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 90;
  border: none;
  border-radius: 999px;
  background: #4a90e2;
  color: #fff;
  font-size: 15px;
  padding: 12px 20px;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0, 0, 0, .25);
}
.chat-fab:hover { filter: brightness(1.08); }

.chat-box {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 95;
  width: 320px;
  max-width: calc(100vw - 32px);
  height: 420px;
  max-height: 70vh;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, .25);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.chat-header {
  background: linear-gradient(135deg, #6ec6e8, #8fd3c7);
  color: #fff;
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 600;
}
.chat-close { border: none; background: none; color: #fff; font-size: 20px; cursor: pointer; }
.chat-msgs {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: #f7f7f9;
}
.chat-hint { text-align: center; color: #aaa; font-size: 12px; margin-top: 20px; }
.chat-row { display: flex; }
.chat-row.me { justify-content: flex-end; }
.chat-bubble {
  max-width: 78%;
  padding: 8px 12px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .08);
}
.chat-row.me .chat-bubble { background: #4a90e2; color: #fff; }
.chat-time { font-size: 10px; opacity: .6; margin-top: 4px; text-align: right; }
.chat-input-row { display: flex; gap: 8px; padding: 10px; border-top: 1px solid #eee; }
.chat-input-row input { flex: 1; }
.chat-input-row .btn { padding: 8px 14px; white-space: nowrap; }

/* 后台客服 */
.chat-badge {
  display: inline-block;
  background: #e74c3c;
  color: #fff;
  border-radius: 999px;
  font-size: 12px;
  padding: 1px 8px;
  margin-left: 6px;
  vertical-align: middle;
}
.chat-admin { display: flex; gap: 16px; }
.session-list {
  width: 240px;
  flex-shrink: 0;
  border: 1px solid #f0f0f0;
  border-radius: 10px;
  overflow-y: auto;
  max-height: 380px;
}
.session-item { padding: 10px 12px; border-bottom: 1px solid #f5f5f5; cursor: pointer; }
.session-item:hover { background: #fafafa; }
.session-item.active { background: #eef5fc; border-left: 3px solid #4a90e2; }
.session-name { font-size: 14px; font-weight: 600; display: flex; justify-content: space-between; align-items: center; }
.session-preview {
  font-size: 12px;
  color: #999;
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.session-unread { background: #e74c3c; color: #fff; border-radius: 999px; font-size: 11px; padding: 0 6px; }
.chat-conv { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.conv-msgs {
  flex: 1;
  border: 1px solid #f0f0f0;
  border-radius: 10px;
  padding: 12px;
  overflow-y: auto;
  max-height: 320px;
  min-height: 280px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: #f7f7f9;
}
.chat-conv .chat-input-row { padding: 10px 0 0; border-top: none; }

@media (max-width: 700px) {
  .chat-admin { flex-direction: column; }
  .session-list { width: 100%; max-height: 160px; }
}

/* ---------- 店铺背景图 ---------- */
body.with-bg {
  background-size: cover;
  background-position: center;
  background-attachment: fixed;
}
body.with-bg .section-title { color: #fff; text-shadow: 0 1px 6px rgba(0, 0, 0, .55); }
body.with-bg .empty-tip { color: #fff; text-shadow: 0 1px 6px rgba(0, 0, 0, .55); }

/* ---------- 商品图片 ---------- */
.product-img {
  width: calc(100% + 36px);
  margin: -22px -18px 0;
  height: 150px;
  object-fit: cover;
  border-radius: 12px 12px 0 0;
}
.prod-thumb {
  width: 56px;
  height: 56px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid #eee;
  display: block;
  margin-bottom: 6px;
}
.prod-img-ops { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.prod-img-ops .btn { padding: 4px 10px; font-size: 12px; margin-right: 0; }
.prod-table input[type="file"], #addImage { font-size: 12px; max-width: 180px; }

/* ---------- 店铺公告 ---------- */
.notice-card {
  background: rgba(255, 255, 255, .88);
  border: 1px solid rgba(255, 255, 255, .7);
  border-radius: 16px;
  padding: 16px 20px;
  margin-top: 20px;
  box-shadow: 0 2px 10px rgba(80, 120, 160, .1);
}
.notice-title { font-size: 15px; font-weight: 700; color: #2e86de; margin-bottom: 6px; }
.notice-body {
  font-size: 14px;
  color: #4a5a6a;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
}
#noticeInput { flex: 1; min-width: 200px; }

/* ---------- 声音提醒开关 ---------- */
.sound-toggle {
  font-size: 13px;
  color: #999;
  font-weight: normal;
  margin-left: 10px;
  cursor: pointer;
  user-select: none;
}
.sound-toggle input { vertical-align: -1px; margin-right: 2px; }

/* ---------- 聊天图片 / 视频 ---------- */
.chat-img {
  max-width: 180px;
  max-height: 180px;
  border-radius: 8px;
  display: block;
  cursor: zoom-in;
}
.chat-video {
  max-width: 210px;
  border-radius: 8px;
  display: block;
  background: #000;
}
.attach-btn {
  border: none;
  background: none;
  font-size: 18px;
  cursor: pointer;
  padding: 0 4px;
  color: #888;
  line-height: 1;
}
.attach-btn:hover { color: #4a90e2; }

/* ---------- 商品分类 ---------- */
.cat-tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.cat-tab {
  padding: 7px 16px;
  border-radius: 999px;
  border: 1px solid #cfe3f7;
  background: #fff;
  color: #4a90e2;
  cursor: pointer;
  font-size: 14px;
  transition: background .15s, color .15s;
}
.cat-tab:hover { background: #e3eefb; }
.cat-tab.active { background: #4a90e2; color: #fff; border-color: #4a90e2; }

.cat-list { margin-bottom: 12px; }
.cat-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #eef5fc;
  border: 1px solid #cfe3f7;
  color: #4a90e2;
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 13px;
  margin: 0 8px 8px 0;
}
.cat-x { border: none; background: none; color: #e74c3c; cursor: pointer; font-size: 15px; padding: 0 0 0 2px; line-height: 1; }

select {
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 14px;
  background: #fff;
  outline: none;
}
select:focus { border-color: #4a90e2; }
.prod-table select { width: 100%; }

/* ---------- 订单 ---------- */
.pay-orderno { font-size: 14px; color: #666; margin-bottom: 12px; }
.pay-orderno b { color: #2e86de; letter-spacing: 1px; user-select: all; }
.order-query-row { display: flex; gap: 8px; margin-top: 12px; }
.order-query-row input { flex: 1; }
.order-query-row .btn { white-space: nowrap; }
.order-result { margin-top: 10px; text-align: left; }
.order-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 2px;
  border-bottom: 1px solid #f0f4f8;
  font-size: 14px;
}
.order-row:last-child { border-bottom: none; }
.order-key { color: #999; flex-shrink: 0; }
.order-val { word-break: break-all; text-align: right; }
.status-pending { color: #e8a13a; }
.status-paid { color: #2faf7d; }
.status-cancelled { color: #999; }
.order-table select { width: auto; font-size: 13px; padding: 5px 8px; }

@media (max-width: 700px) {
  .search-input { width: 140px; }
  .order-table { display: block; overflow-x: auto; }
}

/* ---------- 付款截图 ---------- */
.pay-shot { margin-top: 14px; }
.pay-shot .btn { width: 100%; }
.pay-shot-msg { font-size: 13px; margin-top: 8px; min-height: 18px; }
.pay-shot-msg.ok-text { color: #2e7d32; }
.pay-shot-msg.error-text { color: #e74c3c; }
.order-shot-thumb { max-width: 120px; max-height: 120px; border-radius: 8px; border: 1px solid #eee; display: block; }
.order-shot { width: 48px; height: 48px; object-fit: cover; border-radius: 6px; border: 1px solid #eee; display: block; cursor: zoom-in; }

/* ---------- 图片大图预览 ---------- */
.img-modal-img {
  position: relative;
  max-width: 90vw;
  max-height: 88vh;
  border-radius: 10px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, .4);
  cursor: zoom-out;
  background: #fff;
}

/* ---------- 买家登录 / 注册 ---------- */
.auth-tabs { display: flex; gap: 8px; margin: 14px 0 12px; }
.auth-tab {
  flex: 1;
  padding: 8px 0;
  border: 1px solid #ddd;
  border-radius: 8px;
  background: #f5f6fa;
  color: #666;
  font-size: 14px;
  cursor: pointer;
}
.auth-tab.active { background: #2e86de; border-color: #2e86de; color: #fff; }
.auth-input {
  width: 100%;
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 14px;
  margin-bottom: 10px;
  outline: none;
}
.auth-input:focus { border-color: #2e86de; }
.auth-submit { width: 100%; }

.user-login-btn {
  border: 1px solid rgba(255, 255, 255, .6);
  background: rgba(255, 255, 255, .15);
  color: #fff;
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 13px;
  cursor: pointer;
}
.user-login-btn:hover { background: rgba(255, 255, 255, .28); }
.user-hi { color: #fff; font-size: 13px; margin: 0 8px 0 10px; opacity: .95; }
.user-logout {
  border: none;
  background: rgba(255, 255, 255, .2);
  color: #fff;
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 12px;
  cursor: pointer;
}
.user-logout:hover { background: rgba(255, 255, 255, .32); }
