/* ============================================================
 * theme.css · 电桩面板设计系统 v4
 * 方向：效率工具 —— 灰画布 + 白卡片分层 / 系统字体 + 表格数字 /
 *       绿色只给主操作，占用用中性灰蓝，红色只给「结束」
 * 依赖：无。三页共用，页面内 <style> 只写各自布局。
 * ============================================================ */

/* ---------------- tokens ---------------- */
:root{
  color-scheme: light;

  /* 面：灰画布 + 白卡片，靠明度差分层，不靠阴影堆叠 */
  --bg:#F4F5F6;
  --surface:#FFFFFF;
  --surface-2:#FAFBFC;     /* 停用 / 次级填充 */
  --surface-3:#F0F2F4;     /* 按下 */

  /* 线 */
  --line:#E6E9ED;
  --line-2:#D8DDE3;
  --line-dash:#DDE2E8;

  /* 字：正文级全部过 4.5:1 */
  --ink:#14171A;
  --ink-2:#4A5158;
  --gray:#666D78;
  --gray-2:#8A9099;        /* 3.4:1 —— 只用于装饰性文字，不承载信息 */

  /* 主色：绿色只出现在「可执行的主操作」上 */
  --g:#38A94F;             /* 强调 / 描边 / 勾：小面积 */
  --g-deep:#2A8340;
  --g-btn:#2C8742;         /* 按钮底：白字 4.5:1 */
  --g-btn-press:#237035;
  --g-press:#2F9445;
  --g-soft:#F1F9F3;
  --g-line:#C9E6D1;
  --g-glow:rgba(56,169,79,.14);

  /* 占用：中性灰蓝，不用红 —— 充电中是正常状态，不是警报 */
  --busy:#59677A;
  --busy-bg:#F5F7FA;
  --busy-line:#E1E6ED;

  /* 红：只给「结束充电」这类破坏性动作 + 真错误 */
  --red:#CE3F36;
  --red-press:#B8362E;
  --red-soft:#FDF3F2;
  --red-line:#F0CBC8;

  --amber:#8A5A00;
  --amber-soft:#FFF8EE;
  --amber-line:#F3E2C4;

  /* 阴影：只有浮起的东西才有 */
  --sh-bar:0 -1px 0 var(--line), 0 -8px 24px rgba(20,23,26,.05);
  --sh-pop:0 12px 32px rgba(20,23,26,.13);
  --sh-btn:0 3px 10px rgba(56,169,79,.22);

  --sans:-apple-system,BlinkMacSystemFont,"PingFang SC","Hiragino Sans GB","Microsoft YaHei",sans-serif;

  --r-1:8px; --r-2:12px; --r-3:14px; --r-4:16px; --r-pill:999px;
  --ease:cubic-bezier(.22,.68,.28,1);
  --ease-out:cubic-bezier(.16,1,.3,1);
  --pad:16px;

  /* 安全区：浏览器里 env() 给真值；App 里 WebView 恒为 0，
     那边由系统栏本身占位，所以这里的额外呼吸值才是主角 */
  --sat:env(safe-area-inset-top, 0px);
  --sab:env(safe-area-inset-bottom, 0px);
  /* 顶部/底部呼吸：装进 App 后系统栏紧贴页面，没有这层留白就会"顶头" */
  --head-y:18px;
  --foot-y:16px;
}

/* ---------------- 基础 ---------------- */
*{box-sizing:border-box;-webkit-tap-highlight-color:transparent}
html,body{margin:0;padding:0}
html{-webkit-text-size-adjust:100%;background:var(--bg)}
body{
  font-family:var(--sans);
  background:var(--bg);color:var(--ink);
  font-size:15px;line-height:1.45;
  -webkit-font-smoothing:antialiased;
  max-width:560px;margin:0 auto;
  overscroll-behavior-y:contain;
  /* App 里长按文字会弹系统菜单，工具页面用不上，只会误触 */
  -webkit-touch-callout:none;
  -webkit-user-select:none;user-select:none;
}
input,textarea,[data-selectable]{
  -webkit-touch-callout:default;
  -webkit-user-select:text;user-select:text;
}
button{
  font-family:inherit;font-size:inherit;line-height:inherit;
  border:0;background:none;padding:0;color:inherit;cursor:pointer;
  -webkit-appearance:none;appearance:none;
}
button:focus{outline:none}
button:focus-visible{outline:2px solid var(--g);outline-offset:2px}
input,select,textarea{font-family:inherit;font-size:inherit;color:inherit}
svg{display:block}
[hidden]{display:none!important}

/* 数字：系统字体 + 表格数字（不用等宽字体，中文混排更整） */
.num{font-variant-numeric:tabular-nums;font-feature-settings:"tnum" 1}

/* ---------------- 顶部栏 ----------------
 * 装进 App 后上方就是系统状态栏，这层留白是标题"不顶头"的唯一来源。
 */
.top{
  position:sticky;top:0;z-index:20;
  display:flex;align-items:center;gap:8px;
  padding:calc(var(--head-y) + var(--sat)) var(--pad) 12px;
  background:var(--surface);
  border-bottom:1px solid var(--line);
}
.top-l{flex:1;min-width:0}
.top-t{
  margin:0;font-size:20px;line-height:1.22;font-weight:700;letter-spacing:-.015em;
  color:var(--ink);
  white-space:nowrap;overflow:hidden;text-overflow:ellipsis;
}
.top-s{
  margin-top:3px;display:flex;align-items:center;gap:4px;
  font-size:12.5px;color:var(--gray);min-width:0;
  white-space:nowrap;overflow:hidden;text-overflow:ellipsis;
}
.top-s .num{letter-spacing:.01em}

/* 图标按钮 */
.ib{
  flex:none;width:40px;height:40px;margin-left:-10px;
  display:flex;align-items:center;justify-content:center;
  color:var(--ink);border-radius:var(--r-1);
  transition:background .14s var(--ease);
}
.ib:active{background:var(--surface-3)}
.ib svg{width:20px;height:20px}
.ib.r{margin-left:0;margin-right:-10px;color:var(--gray)}
.ib.sm{width:24px;height:24px;margin:0;color:var(--gray)}
.ib.sm svg{width:14px;height:14px}

/* ---------------- 区块标题 ---------------- */
.sec-h{
  display:flex;align-items:center;justify-content:space-between;gap:10px;
  padding:0 2px 10px;
}
.k{
  font-size:12px;font-weight:600;letter-spacing:.08em;
  color:var(--gray);
}
.sec-h .r{
  display:flex;align-items:center;gap:8px;
  font-size:12px;color:var(--gray);
}
.rbtn{
  display:flex;align-items:center;gap:4px;
  font-size:12px;color:var(--gray);padding:4px 0;
  transition:color .14s var(--ease);
}
.rbtn:active{color:var(--g-deep)}
.rbtn svg{width:13px;height:13px}

/* ---------------- 卡片 ---------------- */
.card{
  background:var(--surface);
  border:1px solid var(--line);
  border-radius:var(--r-4);
  overflow:hidden;
}

/* 统计（关键数据给到最大） */
.stat{display:flex;align-items:baseline;gap:6px}
.stat b{
  font-size:26px;font-weight:700;line-height:1;letter-spacing:-.02em;
  font-variant-numeric:tabular-nums;color:var(--ink);
}
.stat span{font-size:12.5px;color:var(--gray)}
.stat-sep{width:1px;height:26px;background:var(--line);align-self:center;margin:0 18px}

/* ---------------- 按钮 ---------------- */
.btn{
  display:flex;align-items:center;justify-content:center;gap:8px;
  height:54px;width:100%;border-radius:var(--r-2);
  font-size:17px;font-weight:600;letter-spacing:.01em;
  transition:background .14s var(--ease),transform .1s var(--ease),color .14s var(--ease);
}
.btn svg{width:19px;height:19px}
.btn-1{background:var(--g-btn);color:#fff;box-shadow:var(--sh-btn)}
.btn-1:active{background:var(--g-btn-press);transform:scale(.99);box-shadow:none}
.btn-1:disabled{background:var(--surface-3);color:var(--gray-2);box-shadow:none;transform:none;transition:none}
.btn-2{
  background:var(--surface);color:var(--ink-2);
  border:1px solid var(--line-2);
}
.btn-2:active{background:var(--surface-3);color:var(--ink)}
.btn-danger{background:var(--red);color:#fff;box-shadow:0 3px 10px rgba(206,63,54,.22)}
.btn-danger:active{background:var(--red-press);box-shadow:none}
.btn-danger:disabled{background:var(--surface-3);color:var(--gray-2);box-shadow:none;transition:none}

/* 次级入口：一行文字链 */
.linkbtn{
  display:inline-flex;align-items:center;gap:6px;
  min-height:44px;padding:0 10px;
  font-size:14px;color:var(--ink-2);
  transition:color .14s var(--ease);
}
.linkbtn:active{color:var(--g-deep)}
.linkbtn svg{width:16px;height:16px;color:var(--gray)}

/* ---------------- 列表行 ---------------- */
.list{list-style:none;margin:0;padding:0}
.row{
  display:flex;align-items:center;gap:12px;
  min-height:60px;padding:10px 14px;
  border-top:1px solid var(--line);
  background:transparent;width:100%;text-align:left;
  transition:background .12s var(--ease);
}
.row:first-child{border-top:0}
.row:active{background:var(--surface-3)}
.row-t{flex:1;min-width:0}
.row-1{
  font-size:15px;font-weight:600;line-height:1.3;color:var(--ink);
  white-space:nowrap;overflow:hidden;text-overflow:ellipsis;
}
.row-2{
  margin-top:2px;font-size:12.5px;line-height:1.3;color:var(--gray);
  font-variant-numeric:tabular-nums;
  white-space:nowrap;overflow:hidden;text-overflow:ellipsis;
}
.row-c{flex:none;color:var(--gray-2)}
.row-c svg{width:16px;height:16px}
.row .hit{color:var(--g-deep);font-weight:700}

/* 行首缩略：浅灰底 + 深灰图标，不抢主色 */
.thumb{
  flex:none;width:36px;height:36px;border-radius:10px;
  display:flex;align-items:center;justify-content:center;
  background:var(--surface-3);color:var(--ink-2);
}
.thumb svg{width:17px;height:17px}

/* ---------------- 输入框 ---------------- */
.field{
  position:relative;display:flex;align-items:center;
  height:54px;border:1.5px solid var(--line-2);border-radius:var(--r-2);
  background:var(--surface);
  transition:border-color .15s var(--ease),box-shadow .15s var(--ease);
}
.field:focus-within{border-color:var(--g);box-shadow:0 0 0 3px var(--g-glow)}
.field input{
  flex:1;min-width:0;height:100%;border:0;background:transparent;
  padding:0 14px;outline:none;-webkit-appearance:none;
  font-size:16px;
}
.field input::placeholder{color:var(--gray);font-size:14px}
.field .fx{flex:none;width:44px;height:100%;display:flex;align-items:center;justify-content:center;color:var(--gray)}
.field .fx:active{color:var(--ink)}
.field .fx svg{width:16px;height:16px}
.field.bad{border-color:var(--red);box-shadow:0 0 0 3px var(--red-soft)}

/* ---------------- 底部操作栏 ---------------- */
.acts{
  position:fixed;left:0;right:0;bottom:var(--kb,0px);z-index:30;
  background:var(--surface);
  border-top:1px solid var(--line);
  padding:10px var(--pad) calc(var(--foot-y) + var(--sab));
  box-shadow:var(--sh-bar);
  transition:bottom .18s var(--ease);
}
.acts-in{max-width:528px;margin:0 auto}

/* ---------------- toast ---------------- */
.toast{
  position:fixed;left:50%;bottom:calc(112px + var(--sab));
  transform:translate(-50%,8px);
  background:#1F242A;color:#fff;
  font-size:13.5px;line-height:1.45;padding:10px 16px;border-radius:var(--r-pill);
  z-index:200;max-width:82vw;text-align:center;
  box-shadow:var(--sh-pop);
  opacity:0;pointer-events:none;
  transition:opacity .18s var(--ease),transform .18s var(--ease-out);
}
.toast.on{opacity:1;transform:translate(-50%,0)}
.toast.err{background:var(--red)}

/* ---------------- 提示条 ---------------- */
.note{
  display:flex;gap:9px;align-items:flex-start;
  padding:11px 13px;border-radius:var(--r-2);
  font-size:12.5px;line-height:1.6;
  background:var(--amber-soft);color:var(--amber);
  border:1px solid var(--amber-line);
}
.note b{font-weight:600}
.note svg{flex:none;width:15px;height:15px;margin-top:1px}

/* 中性提示（信息类，不报警） */
.note.info{
  background:var(--surface-2);color:var(--ink-2);
  border-color:var(--line);
}

/* ---------------- 空态 ---------------- */
.empty{
  display:flex;flex-direction:column;align-items:center;justify-content:center;
  padding:48px 28px;text-align:center;
}
.empty .ei{
  width:52px;height:52px;border-radius:var(--r-3);
  display:flex;align-items:center;justify-content:center;
  background:var(--surface-3);color:var(--gray);
  margin-bottom:14px;
}
.empty .ei svg{width:23px;height:23px}
.empty .et{font-size:14.5px;color:var(--ink-2);font-weight:600}
.empty .es{margin-top:5px;font-size:13px;color:var(--gray);line-height:1.6}

/* ---------------- 全屏面板（输入页 / 贴桩码 / 摄像头） ----------------
 * 从右侧推入：这是"进入下一层"，不是"新开一个 App"。
 */
.page{
  position:fixed;inset:0;z-index:90;
  background:var(--bg);
  display:flex;flex-direction:column;
  transform:translateX(100%);
  /* 阴影只在「已推入」时存在：否则它会从屏幕右缘漏出来，变成一条灰边 */
  box-shadow:-14px 0 36px rgba(20,23,26,0);
  transition:transform .28s var(--ease-out),box-shadow .28s var(--ease);
  will-change:transform;
}
.page.on{transform:none;box-shadow:-14px 0 36px rgba(20,23,26,.14)}
.page-body{flex:1;min-height:0;overflow-y:auto;-webkit-overflow-scrolling:touch}

/* 滚动条：桌面浏览器/部分 WebView 会占掉 8px，把左右边距挤成不一样 */
main::-webkit-scrollbar,.page-body::-webkit-scrollbar{width:0;height:0}

/* 整页跳转（扫码页 → 控制页）没有转场可言，用一点淡入把白闪压掉 */
@keyframes pageIn{from{opacity:.45}to{opacity:1}}
body{animation:pageIn .18s var(--ease) both}
body.leaving{animation:none;opacity:.45;transition:opacity .16s var(--ease)}
