/* ==========================================================================
 * 庄里人！就是占！—— 商家移动端 H5 全局样式
 * 主色调：深红 #B03A2E（商务风）；移动端优先，适配 375px 宽
 * ========================================================================== */

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

:root {
  --primary: #B03A2E;        /* 主色 深红 */
  --primary-dark: #8E2D23;   /* 主色加深（按下态） */
  --primary-light: #F7E8E6;  /* 主色浅底 */
  --text-main: #2C2C2C;
  --text-sub: #8A8A8A;
  --border: #E8E0DE;
  --bg: #F6F4F3;
  --success: #2E7D32;
  --warning: #C77800;
  --danger: #B03A2E;
}

html, body {
  font-size: 14px;
  color: var(--text-main);
  background: var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* 页面容器：移动端优先，桌面浏览器居中显示 420px 宽度便于调试 */
#app { max-width: 420px; margin: 0 auto; min-height: 100vh; background: var(--bg); position: relative; }

.page { min-height: 100vh; padding-bottom: 64px; /* 给底部 tab 留位 */ }
.page.no-tab { padding-bottom: 0; }

/* ---------- 通用顶部栏 ---------- */
.navbar {
  background: var(--primary);
  color: #fff;
  padding: 14px 16px;
  font-size: 17px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 20;
}
.navbar .nav-back { color: #fff; font-size: 14px; cursor: pointer; opacity: .9; }
.navbar .nav-right { font-size: 13px; font-weight: 400; cursor: pointer; opacity: .95; }

/* ---------- 卡片 ---------- */
.card {
  background: #fff;
  border-radius: 10px;
  margin: 12px;
  padding: 14px;
  box-shadow: 0 1px 4px rgba(140, 60, 50, .06);
}
.card-title { font-size: 15px; font-weight: 600; margin-bottom: 10px; }
.card-title .sub { font-size: 12px; color: var(--text-sub); font-weight: 400; margin-left: 6px; }

/* ---------- 按钮 ---------- */
.btn {
  display: block;
  width: 100%;
  border: none;
  border-radius: 8px;
  padding: 12px;
  font-size: 15px;
  background: var(--primary);
  color: #fff;
  cursor: pointer;
  text-align: center;
}
.btn:active { background: var(--primary-dark); }
.btn[disabled] { opacity: .55; pointer-events: none; /* 防重复提交 */ }
.btn-plain { background: #fff; color: var(--primary); border: 1px solid var(--primary); }
.btn-grey { background: #EFE9E7; color: var(--text-main); }
.btn-sm { display: inline-block; width: auto; padding: 6px 14px; font-size: 13px; border-radius: 6px; }
.btn-danger { background: var(--danger); }

/* ---------- 表单 ---------- */
.form-item { margin-bottom: 14px; }
.form-label { font-size: 13px; color: var(--text-main); margin-bottom: 6px; display: block; font-weight: 500; }
.form-label .req { color: var(--danger); margin-right: 2px; }
.form-input, .form-select, .form-textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 14px;
  background: #fff;
  color: var(--text-main);
  outline: none;
}
.form-input:focus, .form-select:focus, .form-textarea:focus { border-color: var(--primary); }
.form-textarea { resize: none; min-height: 72px; }
.form-tip { font-size: 12px; color: var(--text-sub); margin-top: 4px; line-height: 1.5; }

/* 行业选择"非学科培训"的显著警告提示 */
.warn-banner {
  background: #FDF3E7;
  border: 1px solid #E8B36A;
  color: #9A5B00;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.6;
  margin-top: 8px;
  font-weight: 600;
}
.error-banner {
  background: var(--primary-light);
  border: 1px solid var(--primary);
  color: var(--primary-dark);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.6;
  margin: 12px;
}

/* ---------- 单选组（行业/行政区） ---------- */
.radio-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.radio-grid .radio-item {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 13px;
  background: #fff;
  cursor: pointer;
}
.radio-grid .radio-item.active { border-color: var(--primary); color: var(--primary); background: var(--primary-light); font-weight: 600; }

/* ---------- 图片上传 ---------- */
.upload-row { display: flex; flex-wrap: wrap; gap: 8px; }
.upload-cell {
  width: 72px; height: 72px;
  border: 1px dashed #C9B7B3;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-sub); font-size: 24px;
  position: relative; overflow: hidden;
  background: #FBF9F8;
  cursor: pointer;
}
.upload-cell img { width: 100%; height: 100%; object-fit: cover; }
.upload-cell .del {
  position: absolute; top: 0; right: 0;
  background: rgba(0,0,0,.55); color: #fff;
  font-size: 12px; width: 20px; height: 20px; line-height: 20px;
  text-align: center; border-radius: 0 8px 0 8px; cursor: pointer;
}
.upload-cell.uploading::after { content: '…'; position: absolute; }

/* ---------- 底部 Tab 导航 ---------- */
.tabbar {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 420px;
  background: #fff;
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 30;
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar .tab-item {
  flex: 1; text-align: center; padding: 8px 0 6px;
  color: var(--text-sub); font-size: 11px; cursor: pointer;
}
.tabbar .tab-item .icon { font-size: 20px; display: block; margin-bottom: 2px; }
.tabbar .tab-item.active { color: var(--primary); font-weight: 600; }

/* ---------- 统计卡片（dashboard） ---------- */
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat-box {
  background: #fff; border-radius: 10px; padding: 14px;
  box-shadow: 0 1px 4px rgba(140,60,50,.06);
}
.stat-box .num { font-size: 24px; font-weight: 700; color: var(--primary); }
.stat-box .label { font-size: 12px; color: var(--text-sub); margin-top: 4px; }

/* ---------- 列表行 ---------- */
.list-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 0; border-bottom: 1px solid var(--border);
}
.list-row:last-child { border-bottom: none; }
.list-row .row-main { flex: 1; min-width: 0; }
.list-row .row-title { font-size: 14px; font-weight: 500; }
.list-row .row-sub { font-size: 12px; color: var(--text-sub); margin-top: 3px; line-height: 1.5; }

/* ---------- 状态徽标 ---------- */
.badge { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 10px; }
.badge-pending { background: #FDF3E7; color: var(--warning); }
.badge-approved { background: #E8F3E9; color: var(--success); }
.badge-rejected { background: var(--primary-light); color: var(--danger); }
.badge-on { background: #E8F3E9; color: var(--success); }
.badge-off { background: #EFE9E7; color: var(--text-sub); }

/* ---------- 筛选 tab（预约/台账） ---------- */
.filter-tabs { display: flex; gap: 8px; padding: 12px 12px 0; }
.filter-tabs .f-tab {
  flex: 1; text-align: center; padding: 8px 0;
  background: #fff; border-radius: 8px; font-size: 13px;
  color: var(--text-sub); cursor: pointer; border: 1px solid var(--border);
}
.filter-tabs .f-tab.active { background: var(--primary); color: #fff; border-color: var(--primary); font-weight: 600; }

/* ---------- 核销页 ---------- */
.verify-hero { text-align: center; padding: 24px 16px 8px; }
.scan-box {
  margin: 12px; border-radius: 12px; overflow: hidden;
  background: #1a1a1a; position: relative; min-height: 260px;
  display: flex; align-items: center; justify-content: center; color: #bbb; font-size: 13px;
}
.scan-box video { width: 100%; display: block; }
.scan-tip { text-align: center; color: var(--text-sub); font-size: 12px; padding: 8px 16px; line-height: 1.6; }

/* 核销结果大字弹层 */
.verify-result-mask {
  position: fixed; inset: 0; background: rgba(0,0,0,.55);
  display: flex; align-items: center; justify-content: center; z-index: 100;
}
.verify-result {
  background: #fff; border-radius: 14px; width: 82%; max-width: 340px;
  padding: 28px 20px; text-align: center;
}
.verify-result .big { font-size: 34px; font-weight: 800; color: var(--success); margin: 8px 0; }
.verify-result .big.fail { color: var(--danger); font-size: 20px; }
.verify-result .amount { font-size: 40px; font-weight: 800; color: var(--primary); }
.verify-result .meta { font-size: 13px; color: var(--text-sub); margin: 6px 0 16px; line-height: 1.6; }

/* ---------- 我的页菜单 ---------- */
.menu-cell {
  display: flex; align-items: center; justify-content: space-between;
  padding: 15px 0; border-bottom: 1px solid var(--border);
  font-size: 15px; cursor: pointer;
}
.menu-cell:last-child { border-bottom: none; }
.menu-cell .arrow { color: #C9B7B3; }

/* ---------- 空态 ---------- */
.empty { text-align: center; color: var(--text-sub); font-size: 13px; padding: 40px 0; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; top: 18%; left: 50%; transform: translateX(-50%);
  background: rgba(30, 20, 18, .88); color: #fff;
  padding: 10px 18px; border-radius: 8px; font-size: 14px;
  z-index: 999; max-width: 80%; text-align: center;
  opacity: 0; pointer-events: none; transition: opacity .25s;
}
.toast.show { opacity: 1; }

/* ---------- 加载态 ---------- */
.loading { text-align: center; color: var(--text-sub); padding: 24px 0; font-size: 13px; }

/* 开关 */
.switch { position: relative; width: 46px; height: 26px; flex: none; }
.switch input { display: none; }
.switch .slider {
  position: absolute; inset: 0; background: #D8CFCB; border-radius: 26px; transition: .2s;
}
.switch .slider::before {
  content: ''; position: absolute; width: 22px; height: 22px; border-radius: 50%;
  background: #fff; top: 2px; left: 2px; transition: .2s;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.switch input:checked + .slider { background: var(--primary); }
.switch input:checked + .slider::before { transform: translateX(20px); }

/* ==========================================================================
 * V2 新增样式
 * ========================================================================== */

/* ---------- 券型选择卡片（发券页） ---------- */
.ct-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ct-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  cursor: pointer;
  background: #fff;
}
.ct-card .ct-name { font-size: 14px; font-weight: 600; }
.ct-card .ct-desc { font-size: 11px; color: var(--text-sub); margin-top: 3px; }
.ct-card.active { border-width: 2px; padding: 9px 11px; font-weight: 600; }
.ct-card.disabled { opacity: .45; pointer-events: none; /* 编辑模式锁定券型 */ }
/* 六券型配色（卡片选中态边框/底色与列表标签共用同一色系） */
.ct-card.ct-cash.active { border-color: #B03A2E; background: #F7E8E6; }
.ct-card.ct-cash.active .ct-name { color: #B03A2E; }
.ct-card.ct-fullred.active { border-color: #C77800; background: #FDF3E7; }
.ct-card.ct-fullred.active .ct-name { color: #C77800; }
.ct-card.ct-experience.active { border-color: #1565C0; background: #E8F0FB; }
.ct-card.ct-experience.active .ct-name { color: #1565C0; }
.ct-card.ct-discount.active { border-color: #6A3FA0; background: #F1EAF9; }
.ct-card.ct-discount.active .ct-name { color: #6A3FA0; }
.ct-card.ct-friend.active { border-color: #2E7D32; background: #E8F3E9; }
.ct-card.ct-friend.active .ct-name { color: #2E7D32; }
.ct-card.ct-holiday.active { border-color: #9A5B00; background: #FBF3E0; }
.ct-card.ct-holiday.active .ct-name { color: #9A5B00; }

/* ---------- 券型标签（券管理列表，配色与卡片一致） ---------- */
.ct-tag { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 4px; font-weight: 600; }
.ct-tag-cash { background: #F7E8E6; color: #B03A2E; }
.ct-tag-fullred { background: #FDF3E7; color: #C77800; }
.ct-tag-experience { background: #E8F0FB; color: #1565C0; }
.ct-tag-discount { background: #F1EAF9; color: #6A3FA0; }
.ct-tag-friend { background: #E8F3E9; color: #2E7D32; }
.ct-tag-holiday { background: #FBF3E0; color: #9A5B00; }

/* 主推中标 */
.badge-featured { background: var(--primary); color: #fff; }

/* ---------- 上传进度条（宣传视频） ---------- */
.progress-wrap {
  position: relative;
  height: 34px;
  background: #EFE9E7;
  border-radius: 8px;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  background: var(--primary);
  border-radius: 8px;
  transition: width .2s;
  min-width: 0;
}
.progress-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: #fff;
  /* 白字 + 深色描边：进度条经过前后都清晰可读 */
  text-shadow: 0 0 3px rgba(44, 44, 44, .9), 0 0 3px rgba(44, 44, 44, .9);
}

/* ---------- 高峰时段柱状图（数据中心，纯 CSS，24 列） ---------- */
.hourly-chart {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 130px;
  padding-top: 6px;
}
.hc-col { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; }
.hc-bar-wrap {
  height: 100px;
  width: 100%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.hc-bar {
  width: 70%;
  max-width: 14px;
  background: #E0B8B2;        /* 普通时段：主色浅色 */
  border-radius: 3px 3px 0 0;
}
.hc-bar.peak { background: var(--primary); /* 峰值时段：主色高亮 */ }
.hc-label {
  font-size: 9px;
  color: var(--text-sub);
  margin-top: 4px;
  height: 12px;
  line-height: 12px;
}

/* ============ V4 经营分析（搜索/分享/佣金）============ */
.sub-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
  margin: 14px 0 8px;
}

/* 横向条形图（纯 CSS，无图表库） */
.bar-list { display: flex; flex-direction: column; gap: 8px; }
.bar-row { display: flex; align-items: center; }
.bar-rank {
  width: 18px;
  height: 18px;
  line-height: 18px;
  text-align: center;
  font-size: 11px;
  color: #fff;
  background: #FFB800;
  border-radius: 5px;
  margin-right: 8px;
  flex-shrink: 0;
}
.bar-row:nth-child(n+4) .bar-rank { background: #D9D9D9; }
.bar-main { flex: 1; min-width: 0; }
.bar-label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 3px;
}
.bar-name {
  font-size: 12px;
  color: var(--text-main);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  max-width: 55%;
}
.bar-val { font-size: 11px; color: var(--text-sub); flex-shrink: 0; }
.bar-val em { font-style: normal; color: var(--primary); }
.bar-track {
  height: 6px;
  background: #F2F3F5;
  border-radius: 3px;
  overflow: hidden;
}
.bar-fill {
  height: 6px;
  border-radius: 3px;
  background: linear-gradient(90deg, #FFB800, #FF6A00);
  transition: width .3s ease;
}

/* 转化漏斗 */
.funnel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #FFF9F4;
  border-radius: 10px;
  padding: 12px 8px;
  margin: 12px 0 4px;
}
.funnel-step {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 0;
}
.fs-num { font-size: 16px; font-weight: 700; color: #FF6A00; line-height: 20px; }
.fs-label { font-size: 10px; color: var(--text-sub); margin-top: 2px; }
.fs-rate { font-size: 9px; color: #07A35A; }
.funnel-arrow { color: #FFD3B0; font-size: 14px; flex-shrink: 0; }

/* 数据表 */
.table-wrap { overflow-x: auto; margin-top: 6px; }
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.data-table th,
.data-table td {
  padding: 8px 6px;
  border-bottom: 1px solid #F0F1F2;
  text-align: left;
  white-space: nowrap;
}
.data-table th { font-weight: 600; color: var(--text-sub); background: #FAFBFC; }
.data-table td { color: var(--text-main); }
.data-table .tr { text-align: right; }

/* 空数据提示：说明原因，避免以为页面坏了 */
.empty-tip {
  padding: 28px 12px;
  text-align: center;
  color: var(--text-sub);
  font-size: 12px;
  line-height: 1.7;
}
.empty-tip .empty-emoji { font-size: 28px; margin-bottom: 8px; }
.empty-tip .empty-sub { font-size: 11px; color: #B8B8B8; margin-top: 4px; }

/* 说明文字 */
.note {
  font-size: 11px;
  color: var(--text-sub);
  line-height: 1.6;
  background: #F7F8FA;
  border-radius: 8px;
  padding: 10px;
  margin-top: 12px;
}

/* ==========================================================================
 * V6 电子签约（入驻申请页）
 * ========================================================================== */
.contract-box {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 10px;
  background: #FBF9F8;
}
.contract-box .contract-title {
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  margin-bottom: 8px;
}
.contract-box .contract-body {
  font-size: 12px;
  color: var(--text-sub);
  line-height: 1.8;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 200px;
  overflow-y: auto;
}
.agree-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 13px;
  line-height: 1.6;
  cursor: pointer;
  user-select: none;
}
.agree-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin-top: 2px;
  flex-shrink: 0;
  accent-color: var(--primary);
}

/* ==========================================================================
 * 桌面端适配：电脑浏览器打开时加宽表单，提升录入与上传体验
 * （移动端仍保持 420px 窄屏，仅 >=768px 的桌面/平板放宽到 720px）
 * ========================================================================== */
@media (min-width: 768px) {
  #app { max-width: 720px; }
  .tabbar { max-width: 720px; }
  .card { margin: 16px 0; padding: 20px; }
  .page { padding-left: 16px; padding-right: 16px; }
  .navbar { padding: 16px 24px; }
  .upload-cell { width: 92px; height: 92px; }
  .card-title { font-size: 16px; }
}
