/* ============================================================================
 * base.css —— 公共底座（变量 + 复位 + 通用组件）
 * 规范依据：《工作台CSS设计说明》 8 条规则
 *   ① 颜色只用变量，禁止写死色值（除品牌渐变）
 *   ② 间距全是 4 的倍数
 *   ③ 输入框统一 .inp
 *   ④ 一页只有一个 .btn.pri
 *   ⑤ 卡片 = 1px 边框 + 14px 圆角 + var(--shadow)
 *
 * ★ 配色说明：前台沿用 v2 原有蓝色系（用户要求"尽量不改变原程序"）；
 *   后台按《工作台CSS设计说明》teal 主色。
 *   两套色板都收敛在本文件，改色只改这里。
 * ==========================================================================*/

/* ---------------- 前台色板（继承 v2） ---------------- */
:root {
  --primary:        #378ADD;
  --primary-dark:   #2a6db0;
  --primary-soft:   #eaf3fc;

  --bg:             #f4f7fb;
  --card:           #ffffff;
  --text:           #1f2d3d;
  --muted:          #8a94a6;

  --ok:             #21b573;
  --warn:           #e6a23c;
  --danger:         #f56c6c;

  --radius:         14px;
  --line:           #e6ebf3;

  --shadow:         0 1px 6px rgba(31, 45, 61, .06);
  --shadow-up:      0 8px 30px rgba(0, 0, 0, .15);

  /* 间距刻度（4 的倍数，禁止写 5px / 7px 这类值） */
  --s1: 4px;  --s2: 8px;  --s3: 12px;  --s4: 16px;  --s5: 20px;  --s6: 24px;
}

/* ---------------- 复位 ---------------- */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

svg { display: block; }
button { font-family: inherit; }

/* ---------------- 通用工具 ---------------- */
.hide { display: none !important; }

/* 输入框（规范③：全站唯一输入框类名） */
.inp {
  width: 100%;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0 12px;
  font-size: 15px;
  background: #fafbfe;
  outline: none;
  color: var(--text);
  transition: border-color .15s, background .15s;
}
.inp:focus { border-color: var(--primary); background: #fff; }
.inp::placeholder { color: #b9c2d0; }
select.inp { padding: 0 8px; cursor: pointer; }

/* 按钮 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  height: 42px;
  border: none;
  border-radius: 10px;
  background: #eef1f6;
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity .15s, background .15s;
}
.btn:active { opacity: .85; }
.btn.pri   { background: var(--primary); color: #fff; }
.btn.pri:active { background: var(--primary-dark); }
.btn.ghost { background: #eef1f6; color: var(--muted); }
.btn.warn  { background: #fef5e7; color: var(--warn); }
.btn.danger{ background: #fdeeee; color: var(--danger); }
/* ★ 组合用法 .btn.ghost.danger（门店列表里的「移除」）
   为什么必须单列一条：.ghost 与 .danger 同为单类选择器、优先级相同，
   谁在后面谁生效 —— 写在一起会看代码顺序决定颜色，非常脆弱。
   用双类选择器把优先级提上去，颜色就锁死了。 */
.btn.ghost.danger { background: #fdeeee; color: var(--danger); }
.btn.ghost.danger:active { background: #f9dcdc; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn svg { width: 15px; height: 15px; flex: none; }

/* 卡片（规范⑤） */
.card-box {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
}

/* 遮罩 / 弹层 */
.mask {
  position: fixed;
  inset: 0;
  background: rgba(20, 30, 45, .45);
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  /* ★ 弹层打开时禁止背景滚动穿透（移动端真机上手指滑弹层会把底下页面一起带走） */
  overscroll-behavior: contain;

  /* ★★ 这里原来是 touch-action: none —— 那会**禁止遮罩层内所有触摸滚动**。
   *
   * 当时弹窗内容都短、不滚动，所以没暴露问题。但跟读弹窗正文可能很长，
   * 一旦把 .sheet 改成可滚动，真机上就完全滚不动（鼠标滚轮能滚，
   * 手指滑不动 —— 这种"桌面测不出来"的问题最坑）。
   *
   * 正确做法：遮罩层设 pan-y（允许纵向手势），把"不许滚"只加在
   * **遮罩本身**；要滚的内容由 .sheet 自己承担（见 .sheet 的 overflow-y）。
   * 背景穿透已由 overscroll-behavior + body.lock 双保险挡住。 */
  touch-action: pan-y;
}
html.lock, body.lock { overflow: hidden; height: 100%; }
.sheet {
  width: 100%;
  max-width: 360px;
  background: #fff;
  border-radius: 18px;
  padding: 20px;
  box-shadow: var(--shadow-up);
  /* ★ 弹窗高度上限：内容再长也不超出屏幕，超出部分内部滚动。
     为什么加在 .sheet 而不是每个弹窗各写一遍：
       身份弹窗、完成弹窗、跟读弹窗都可能变长，统一兜住，
       避免以后又出现"某个弹窗把按钮顶出屏幕"。 */
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.sheet h3 { font-size: 17px; margin-bottom: 4px; }
.sheet p  { font-size: 12px; color: var(--muted); margin-bottom: 14px; line-height: 1.6; }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px; }

/* Toast */
#toast {
  position: fixed;
  left: 50%;
  bottom: 90px;
  transform: translateX(-50%) translateY(20px);
  background: rgba(31, 45, 61, .92);
  color: #fff;
  padding: 9px 18px;
  border-radius: 20px;
  font-size: 13px;
  opacity: 0;
  transition: all .3s;
  z-index: 60;
  pointer-events: none;
  white-space: nowrap;
  max-width: 90vw;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* 骨架屏（规范「真」：加载中有明确反馈，杜绝白屏） */
.skeleton {
  background: linear-gradient(90deg, #eef1f6 25%, #f6f8fb 37%, #eef1f6 63%);
  background-size: 400% 100%;
  animation: sk 1.4s ease infinite;
  border-radius: 10px;
}
@keyframes sk { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* 空状态 */
.list-empty {
  background: #fff;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 22px 16px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}
.list-empty b { color: var(--text); }

/* 致命错误页（规范「真」：STORE_NOT_FOUND 等必须给出明确文案，禁止永久加载中） */
.fatal {
  margin: 60px 20px;
  background: #fff;
  border-radius: var(--radius);
  padding: 28px 20px;
  text-align: center;
  box-shadow: var(--shadow);
}
.fatal .f-ic { color: var(--warn); margin: 0 auto 12px; width: 40px; height: 40px; }
.fatal .f-ic svg { width: 40px; height: 40px; }
.fatal h3 { font-size: 16px; margin-bottom: 6px; }
.fatal p  { font-size: 13px; color: var(--muted); line-height: 1.7; }
.fatal code { background: var(--bg); border-radius: 4px; padding: 1px 6px; font-size: 12px; }

/* ===========================================================================
 * 启动骨架屏 —— SDK 加载期间必须**立刻有东西看**
 *
 * ★ 2026-09-18 新增。为什么必须这么做：
 *   cloudbase-js-sdk.js 是 775 KB 的单文件（gzip 后约 191 KB），弱网下实测要
 *   7~40 秒。而它加载期间浏览器**不触发 DOMContentLoaded**，原来的 start()
 *   挂在 DCL 上 → 这段时间页面是**纯白、零反馈**的。
 *   顾客看到的是"点进去一片白"，第一反应是"卡死了/坏了"，而不是"在加载"。
 *
 *   所以骨架屏必须用**纯 HTML + CSS 内联**写在 body 里，不依赖任何 JS
 *   （JS 还没加载呢），浏览器一解析到就立刻渲染出来。
 * =========================================================================*/
.boot {
  margin: 60px 20px;
  background: #fff;
  border-radius: var(--radius);
  padding: 28px 20px;
  text-align: center;
  box-shadow: var(--shadow);
}
.boot .boot-spin {
  width: 30px; height: 30px;
  margin: 0 auto 14px;
  border: 3px solid var(--bg);
  border-top-color: var(--warn);
  border-radius: 50%;
  animation: boot-spin .8s linear infinite;
}
@keyframes boot-spin { to { transform: rotate(360deg); } }
.boot h3 { font-size: 15px; margin-bottom: 6px; color: var(--text); }
.boot p  { font-size: 12.5px; color: var(--muted); line-height: 1.7; }
.boot .boot-slow { display: none; margin-top: 8px; font-size: 12px; color: var(--warn); }
.boot.is-slow .boot-slow { display: block; }
/* 重试按钮：SDK 彻底失败时才出现，给顾客一个**能点的出口**，
   而不是只丢一句"请刷新重试"让他自己想办法 */
.boot .boot-retry {
  display: none;
  margin: 14px auto 0;
  padding: 9px 26px;
  border: 0; border-radius: 999px;
  background: var(--warn); color: #fff;
  font-size: 14px; font-weight: 600;
  cursor: pointer;
}
.boot.is-failed .boot-retry { display: inline-block; }
.boot.is-failed .boot-spin { display: none; }
