/* ============ 当面付反扫收银台 · SaaS 蓝白主题 ============ */
:root {
  --brand: #2563eb;
  --brand-hover: #3b82f6;
  --brand-active: #1d4ed8;
  --brand-light: #eff6ff;
  --sidebar-bg: #ffffff;
  --sidebar-text: #4b5563;
  --sidebar-active: #2563eb;
  --sidebar-width: 228px;
  --bg: #f6f8fa;
  --text: #1f2937;
  --text-2: #6b7280;
  --border: #e5e7eb;
  --shadow: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,.06);
  --radius: 10px;
  --radius-sm: 6px;

  --el-color-primary: #2563eb;
  --el-color-primary-light-3: #3b82f6;
  --el-color-primary-light-5: #60a5fa;
  --el-color-primary-light-7: #93c5fd;
  --el-color-primary-light-8: #bfdbfe;
  --el-color-primary-light-9: #eff6ff;
  --el-color-primary-dark-2: #1d4ed8;
  --el-border-radius-base: 6px;
  --el-border-radius-small: 6px;
  --el-font-family: "Inter","PingFang SC","HarmonyOS Sans SC","Microsoft YaHei",-apple-system,"Segoe UI",sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; background: var(--bg); color: var(--text); font-family: var(--el-font-family); font-size: 14px; -webkit-font-smoothing: antialiased; }
#app { min-height: 100vh; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- 登录页 ---------- */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 50%, #bfdbfe 100%); padding: 20px; position: relative; }
.login-card { width: 380px; max-width: 100%; background: #fff; border-radius: 14px; box-shadow: 0 20px 60px rgba(37,99,235,.14); padding: 36px 34px 28px; }
.login-brand { text-align: center; margin-bottom: 28px; }
.login-brand .logo { width: 52px; height: 52px; border-radius: 14px; background: linear-gradient(135deg,#2563eb,#1d4ed8); display: inline-flex; align-items: center; justify-content: center; color: #fff; font-size: 24px; box-shadow: 0 8px 20px rgba(37,99,235,.28); }
.login-brand h1 { margin: 14px 0 4px; font-size: 20px; color: #1f2937; font-weight: 700; }
.login-brand p { margin: 0; font-size: 13px; color: #9ca3af; }
.login-footer { margin-top: 20px; text-align: center; font-size: 12px; color: #9ca3af; }

/* ---------- 后台布局 ---------- */
.admin-shell { display: flex; min-height: 100vh; }
.sidebar { width: var(--sidebar-width); flex: none; background: var(--sidebar-bg); color: var(--sidebar-text); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; border-right: 1px solid var(--border); }
.side-logo { height: 60px; display: flex; align-items: center; gap: 10px; padding: 0 18px; border-bottom: 1px solid var(--border); flex: none; }
.side-logo .logo { width: 32px; height: 32px; border-radius: 8px; background: linear-gradient(135deg,#2563eb,#3b82f6); display: inline-flex; align-items: center; justify-content: center; font-size: 16px; color: #fff; }
.side-logo b { font-size: 15px; color: #1f2937; letter-spacing: .3px; }
.side-menu { flex: 1; padding: 14px 10px; overflow-y: auto; }
.side-menu .menu-item { display: flex; align-items: center; gap: 10px; padding: 10px 14px; margin-bottom: 2px; border-radius: 8px; color: var(--sidebar-text); cursor: pointer; font-size: 14px; font-weight: 500; transition: all .15s; user-select: none; }
.side-menu .menu-item:hover { background: #f3f4f6; color: #1f2937; }
.side-menu .menu-item.active { background: var(--brand-light); color: var(--brand); font-weight: 600; }
.side-menu .menu-item.active .el-icon { color: var(--brand); }
.side-user { padding: 12px 16px; border-top: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; flex: none; font-size: 13px; color: var(--sidebar-text); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { height: 60px; 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 h2 { margin: 0; font-size: 16px; color: #1f2937; font-weight: 600; }
.topbar .date { font-size: 13px; color: #9ca3af; }
.content { padding: 22px 24px; flex: 1; }

/* ---------- 通用卡片 ---------- */
.ep-card { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 18px; }
.card-title { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.card-title h3 { margin: 0; font-size: 15px; color: #1f2937; font-weight: 600; }
.card-title .sub { font-size: 12px; color: #9ca3af; }

/* ---------- 统计卡片 ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; margin-bottom: 18px; }
@media (max-width: 1200px) { .stat-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px) { .stat-grid { grid-template-columns: 1fr; } }
.stat-card { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; display: flex; align-items: center; gap: 16px; box-shadow: var(--shadow); }
.stat-icon { width: 44px; height: 44px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 20px; flex: none; }
.stat-info .label { font-size: 12px; color: #9ca3af; font-weight: 500; text-transform: uppercase; letter-spacing: .3px; }
.stat-info .value { font-size: 24px; font-weight: 700; color: #1f2937; margin-top: 2px; line-height: 1.2; }
.stat-info .value small { font-size: 13px; color: #9ca3af; font-weight: 400; margin-left: 3px; }

/* ---------- 图表容器（修复 ApexCharts 不显示问题） ---------- */
#chartRevenue, #chartStatus, #chartOrders { min-height: 300px; width: 100%; }

/* ---------- 工具条 / 表格 ---------- */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.mono { font-family: "SF Mono","Fira Code","Consolas",monospace; cursor: pointer; color: var(--brand); font-weight: 500; }
.tag-status { font-weight: 500; }
.op-btn { margin-right: 4px; }
.el-table th.el-table__cell { background: #f9fafb !important; color: #374151; font-weight: 600; font-size: 12px; }
.el-table .cell { line-height: 1.6; }
.el-table--striped .el-table__body tr.el-table__row--striped td { background: #fafbfc; }

/* ---------- 顶部列表（热销商品） ---------- */
.top-list .top-item { display: flex; align-items: center; gap: 10px; padding: 9px 4px; border-bottom: 1px dashed #f3f4f6; }
.top-list .top-item:last-child { border-bottom: none; }
.top-rank { width: 22px; height: 22px; border-radius: 6px; background: var(--brand-light); color: var(--brand); font-size: 12px; display: inline-flex; align-items: center; justify-content: center; font-weight: 600; flex: none; }
.top-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; color: #374151; }
.top-val { font-weight: 600; color: #1f2937; }

/* ---------- 弹窗内 ---------- */
.link-summary { background: #f9fafb; border: 1px solid var(--border); border-radius: 8px; padding: 12px 16px; margin-bottom: 14px; display: flex; justify-content: space-between; align-items: center; }
.link-amount { font-size: 22px; font-weight: 700; color: var(--brand); }
.scan-tip { text-align: center; font-size: 12px; color: #9ca3af; margin-top: 10px; }
.pay-ctrl { margin-top: 12px; }
.scan-box { position: relative; width: 100%; max-width: 360px; margin: 0 auto; border-radius: 10px; overflow: hidden; background: #0f172a; }
.scan-box video { width: 100%; height: 260px; object-fit: cover; display: block; }
.scan-frame { position: absolute; left: 50%; top: 50%; width: 74%; height: 58%; transform: translate(-50%,-50%); border: 2px solid rgba(255,255,255,.75); border-radius: 10px; box-shadow: 0 0 0 9999px rgba(15,23,42,.35); }
.scan-line { position: absolute; left: 4%; right: 4%; height: 3px; background: linear-gradient(90deg,transparent,#60a5fa,#fff,#60a5fa,transparent); box-shadow: 0 0 12px rgba(96,165,250,.9); animation: scanmove 2.2s ease-in-out infinite; }
@keyframes scanmove { 0% { top: 6%; } 50% { top: 90%; } 100% { top: 6%; } }

/* ---------- 密钥输入框 ---------- */
.mono-area textarea { font-family: "SF Mono","Fira Code","Consolas",monospace !important; font-size: 12px; line-height: 1.6; }
.help-text { font-size: 13px; line-height: 1.9; color: #4b5563; }
.help-text b { color: var(--brand); }

/* ---------- 响应式 · 移动端适配 ---------- */

/* 手机端遮罩层 */
.sidebar-overlay { display: none; position: fixed; inset: 0; z-index: 99; background: rgba(0,0,0,.35); opacity: 0; transition: opacity .25s; }
.sidebar-overlay.show { display: block; opacity: 1; }

/* 汉堡菜单按钮 */
.menu-toggle { display: none; width: 34px; height: 34px; border: none; background: transparent; border-radius: 6px; cursor: pointer; align-items: center; justify-content: center; color: #4b5563; flex: none; }
.menu-toggle:hover { background: #f3f4f6; }
.topbar-left { display: flex; align-items: center; gap: 8px; }

@media (max-width: 900px) {
  .menu-toggle { display: inline-flex; }

  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; z-index: 100; transform: translateX(-100%); transition: transform .25s; box-shadow: 4px 0 20px rgba(0,0,0,.08); }
  .sidebar.open { transform: translateX(0); }

  .topbar { padding: 0 14px; }
  .topbar .date { font-size: 11px; }

  .content { padding: 14px; }

  .ep-card { padding: 14px; }
  .card-title h3 { font-size: 14px; }

  /* 统计卡片已通过 stat-grid 响应式处理 */
  .stat-grid { gap: 12px; }

  /* 图表容器 */
  #chartRevenue, #chartStatus, #chartOrders { min-height: 220px; }

  /* 表格横向滚动 */
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .table-wrap .el-table { min-width: 640px; }

  /* 工具条纵向排列 */
  .toolbar { flex-direction: column; align-items: stretch; }
  .toolbar .el-input { width: 100% !important; }
  .toolbar .el-select { width: 100% !important; }

  /* 弹窗适配 */
  .el-dialog { width: 92% !important; max-width: 92% !important; }
  .el-dialog__body { padding: 16px 14px !important; }

  /* 密钥输入框 */
  .mono-area { max-width: 100% !important; }

  /* 扫描弹窗内的摄像头 */
  .scan-box { max-width: 100%; }
}

@media (max-width: 480px) {
  .content { padding: 10px; }
  .ep-card { padding: 12px; border-radius: 8px; margin-bottom: 12px; }
  .stat-grid { gap: 10px; }
  .stat-card { padding: 14px; gap: 12px; }
  .stat-info .value { font-size: 20px; }
  .stat-icon { width: 38px; height: 38px; font-size: 17px; }
  .login-card { padding: 28px 20px 24px; box-shadow: 0 10px 40px rgba(37,99,235,.12); }
  .login-brand h1 { font-size: 18px; }
  .order-amount .val big { font-size: 24px; }
  #chartRevenue, #chartStatus, #chartOrders { min-height: 200px; }
}

/* ============ 商品管理样式 ============ */
.prod-thumb {
  width: 56px;
  height: 56px;
  border-radius: 8px;
  background: #f0f4f8;
  border: 1px solid #e5e7eb;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.prod-thumb img { width: 100% !important; height: 100% !important; object-fit: cover; display: block; }
.prod-thumb svg { width: 22px; height: 22px; color: #c7d2fe; }

/* 兜底：任何商品图片都不允许超出容器，避免大图错位 */
.prod-thumb img,
.prod-upload-preview img { max-width: 100% !important; max-height: 100% !important; }

.prod-upload { display: flex; gap: 14px; align-items: flex-start; width: 100%; }
.prod-upload-preview {
  width: 92px;
  height: 92px;
  border-radius: 10px;
  background: #f0f4f8;
  border: 1px dashed #cbd5e1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex: none;
}
.prod-upload-preview img { width: 100%; height: 100%; object-fit: cover; display: block; }
.prod-upload-preview svg { width: 30px; height: 30px; color: #c7d2fe; }
.prod-upload-actions { flex: 1; min-width: 0; }
.prod-upload-actions .hint { font-size: 12px; color: #9ca3af; margin: 6px 0 0; }
.spec-tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  background: #f0f4f8;
  color: #4b5563;
  margin: 2px 4px 2px 0;
  white-space: nowrap;
}
.spec-edit-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
@media (max-width: 480px) {
  .spec-edit-row { flex-direction: column; }
  .spec-edit-row .el-input,
  .spec-edit-row .el-input-number { width: 100% !important; }
}