/* 红外感应器开发平台 · 网页版
   配色与桌面版 QSS 保持一致：冷白底 + 蓝色点缀 */

:root {
  --bg: #F4F7FC;
  --panel: #FFFFFF;
  --line: #E4EAF3;
  --line-strong: #D2DAE8;
  --text: #1F2A3A;
  --muted: #7E8CA6;
  --muted2: #55637A;
  --accent: #2E6BE6;
  --accent-hi: #4A80EC;
  --accent-soft: #E8EEFB;
  --danger: #C24A3F;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei UI", "Segoe UI", "PingFang SC", sans-serif;
  font-size: 13px;
}

body { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }

/* ---------------------------------------------------------------- 通用 */
.app-name { font-size: 16px; font-weight: 700; color: #1B2432; }
.spacer { flex: 1; }

/* 编辑器页面复用工作台的「左侧栏 + 右侧内容」外壳（见文件末尾的 .wb / .side / .ws） */
.page { display: none; }
.page.active { display: flex; flex-direction: column; min-height: 100%; }

/* 整页重新加载时先把整个外壳（左栏 + 右侧）统一藏住。左栏的导航列表、工程名、用户名、
   工程数，右侧的标题、页头按钮，都得等接口回来才知道；先画出来就会露出「空导航 +
   未命名工程 + 正在加载…」外加一条没内容的页头——点「修改」和点「返回上一级」时闪的
   那一下就是它。整页一起藏住，揭幕时一次到位，就是最终样子 */
html.booting .side, html.booting .ws { visibility: hidden; }

/* ---------------------------------------------------------------- 卡片 */
.group {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 8px; padding: 10px 12px 12px; margin-bottom: 12px;
}
.group > .group-title {
  color: var(--muted); font-weight: 600; margin-bottom: 10px;
  border-left: 3px solid var(--accent); padding-left: 8px;
}
.hint { color: var(--muted); line-height: 1.7; margin-top: 8px; }
.calc {
  background: var(--accent-soft); color: #2456C4; border-radius: 6px;
  padding: 3px 8px; font-size: 12px; white-space: nowrap;
}

.row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; }
.row + .row { margin-top: 8px; }

/* 各模式动作说明：一个模式一行，行间留白；模式名加粗、靠右对齐，
   冒号排成一条竖线，眼睛能顺着模式名往下扫，不会糊成一整块 */
.mode-notes { display: flex; flex-direction: column; gap: 6px; margin-top: 7px; }
.mode-note { display: flex; }
.mode-note .mn-name {
  flex: none; width: 4em; text-align: right; white-space: nowrap;
  font-weight: 600; color: var(--text);
}
.mode-notes-title { color: var(--text); }
.mode-notes-foot {
  margin-top: 9px; padding-top: 8px; border-top: 1px dashed var(--line);
}

/* 扫描时间：秒数只读显示（固定两位小数），右边两个小箭头步进 0.2 秒 */
.stepper { display: inline-flex; align-items: center; gap: 4px; }
.stepper input { width: 78px; text-align: center; }
.step-btns { display: inline-flex; flex-direction: column; gap: 1px; }
.step-btns button {
  width: 24px; height: 12px; min-height: 12px; padding: 0;
  font-size: 8px; line-height: 12px; border-radius: 3px;
}
.field { display: flex; align-items: center; gap: 6px; }
.field > label { color: var(--text); }
/* 「默认值」页：每组「标题+编辑框」并排且靠拢，组与组之间留大间距 */
.grid2 { display: grid; grid-template-columns: 1fr; gap: 16px 0; }
.field.wide > label { width: 156px; display: inline-block; }
.field .unit { color: var(--muted); font-size: 12px; }

/* ---------------------------------------------------------------- 控件 */
input[type="text"], input[type="password"], input[type="number"], select, textarea {
  background: var(--panel); border: 1px solid var(--line-strong);
  border-radius: 6px; padding: 4px 8px; color: var(--text);
  min-height: 26px; font-size: 13px; outline: none;
}
input[type="text"]:hover, input[type="password"]:hover, input[type="number"]:hover, select:hover, textarea:hover { border-color: #B9C4D8; }
input[type="text"]:focus, input[type="password"]:focus, input[type="number"]:focus, select:focus, textarea:focus { border-color: var(--accent); }
input[type="number"] { width: 76px; }
input[type="text"].hex { width: 96px; }
input:disabled { background: #F0F3F8; color: #9AA5B8; border-color: var(--line); }
/* 电池门限：自动算出来的 ADC 值只读，压暗底色表示不能改 */
input.adc-out, input.adc-out:hover, input.adc-out:focus {
  width: 76px; background: #F3F6FB; border-color: var(--line);
  color: var(--muted2); cursor: default;
}
/* 电池门限页：单位文字长短不一（K / V（一位小数） / ADC 值（自动计算）），
   不固定宽度的话第一列宽度会随单位变化，把右边那列推得左右错位。
   这里给单位统一宽度，左右两列才能上下对齐 */
#page-power .field .unit { width: 118px; white-space: nowrap; }
/* 这页的标签最长 6 个字（「解除报警电压」），通用样式给的 156px 太宽，
   文字和输入框之间会空出一大截；按 6 个字（6em）+ 一点余量收窄 */
#page-power .field.wide > label { width: 7em; }

button {
  background: var(--panel); border: 1px solid var(--line-strong);
  border-radius: 6px; padding: 5px 16px; color: var(--text);
  font-size: 13px; cursor: pointer; font-family: inherit;
}
button:hover { background: #EEF2FA; border-color: #B9C4D8; }
button:active { background: #E2E9F7; }
button:disabled { color: #A9B4C7; border-color: var(--line); background: var(--bg); cursor: not-allowed; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.primary:hover { background: var(--accent-hi); border-color: var(--accent-hi); }
/* 浅蓝次要按钮：和实心蓝的主按钮并排时能一眼分开（如「上传源码」旁的「下载源码」） */
button.blue { background: #E8EEFB; border-color: #B9CDF0; color: #2456C4; font-weight: 600; }
button.blue:hover { background: #DCE6FA; border-color: #8FB0EA; }
button.danger { color: var(--danger); }
button.danger:hover { background: #FBEAE7; border-color: #E8B7B0; }

label.check { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
input[type="checkbox"] { width: 15px; height: 15px; accent-color: var(--accent); cursor: pointer; }

.mode-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.mode-chip {
  display: flex; align-items: center; gap: 8px; padding: 5px 12px;
  background: var(--panel); border: 1px solid var(--line-strong);
  border-radius: 6px; cursor: pointer;
}
.mode-chip:hover { background: var(--bg); border-color: #B9C4D8; }
.mode-chip.on { background: var(--accent-soft); border-color: var(--accent); color: #2456C4; }

/* ---------------------------------------------------------------- 表格 */
table.led { border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
table.led th, table.led td { border: 1px solid #E8EDF6; padding: 5px 8px; text-align: center; }
table.led th { background: #EEF3FC; color: var(--muted); font-weight: 600; }
table.led td.scene { text-align: left; color: var(--text); white-space: nowrap; }
table.led input[type="number"] { width: 72px; }

/* ---------------------------------------------------------------- 预览 / 日志 */
pre.mono {
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  padding: 10px; margin: 0; color: #2A3445;
  font-family: Consolas, "Courier New", monospace; font-size: 12px;
  line-height: 1.55; overflow: auto; white-space: pre;
}
/* 生成配置的预览框、编译工程的「结果」框：高度最大化，把剩余空间都吃掉 */
#page-output > .group, #page-build > .group:last-child {
  flex: 1; display: flex; flex-direction: column; min-height: 0;
}
#preview, #buildLog { flex: 1; height: auto; min-height: 240px; }

.path-line { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.path-line label { width: 84px; flex: 0 0 auto; color: var(--text); }
.path-line input[type="text"], .path-line input[type="password"], .path-line select {
  flex: 1; min-width: 0; font-family: Consolas, monospace; font-size: 12px;
}

.result-label { margin: 10px 0 8px; color: var(--muted); }
.result-label.ok { color: #2E7D32; }
.result-label.err { color: var(--danger); }

.progress-wrap { margin-top: 10px; height: 22px; background: #E4EAF5; border-radius: 6px; overflow: hidden; position: relative; }
.progress-bar { height: 100%; width: 0; background: var(--accent); border-radius: 6px; transition: width .25s ease; }
.progress-text {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 12px; color: var(--text); font-weight: 600;
}

/* ---------------------------------------------------------------- 模板同步进度（和页面一致的蓝色配色） */
#templateSyncModal {
  position: fixed; inset: 0; z-index: 80;
  display: flex; align-items: center; justify-content: center;
  background: rgba(24, 36, 58, .35);
}
.tsync-box {
  width: 384px; max-width: 92vw;
  padding: 18px 22px 20px;
  border-radius: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: 0 12px 40px rgba(24, 36, 58, .25);
  color: var(--text); font-family: inherit;
}
.tsync-head {
  display: flex; align-items: center; gap: 9px;
  font-size: 15px; font-weight: 700; color: #1B2432;
}
.tsync-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 8px rgba(46, 107, 230, .55);
  animation: tsyncPulse 1.1s ease-in-out infinite;
}
@keyframes tsyncPulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: .4; transform: scale(.72); } }
.tsync-steps { margin: 16px 0 14px; display: flex; flex-direction: column; gap: 10px; }
.tsync-step { display: flex; align-items: center; gap: 11px; color: var(--muted); font-size: 13px; transition: color .22s; }
.tsync-step i {
  width: 15px; height: 15px; border-radius: 50%; flex: none;
  border: 2px solid var(--line-strong); position: relative;
  transition: border-color .22s, background .22s, box-shadow .22s;
}
.tsync-step.on { color: var(--text); }
.tsync-step.on i { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 8px rgba(46, 107, 230, .4); }
.tsync-step.on i::after {
  content: ""; position: absolute; inset: 3px; border-radius: 50%; background: var(--accent);
}
.tsync-bar {
  position: relative; height: 8px; border-radius: 999px;
  background: #E4EAF5; overflow: hidden;
}
.tsync-fill {
  height: 100%; width: 0; border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent-hi));
  transition: width .12s linear;
}
.tsync-scan {
  position: absolute; top: 0; bottom: 0; width: 60px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .6), transparent);
  animation: tsyncScan 1.4s linear infinite;
}
@keyframes tsyncScan { 0% { left: -70px; } 100% { left: 100%; } }
.tsync-pct {
  margin-top: 10px; text-align: right; font-size: 12px;
  color: var(--accent); font-family: Consolas, "Courier New", monospace;
  font-variant-numeric: tabular-nums;
}

/* ---------------------------------------------------------------- 弹窗 / 提示 */
#modal, #alertModal, #confirmModal, #scanModal, #bindRefreshModal {
  position: fixed; inset: 0; background: rgba(24, 36, 58, .35);
  display: flex; align-items: center; justify-content: center; z-index: 50;
}
#alertModal, #confirmModal { z-index: 60; }
/* 工作台（uiDialog）和工具页（alertModal）是两套弹窗，文字呈现要一致：
   都保留换行符，长句按容器宽度自然折行 */
#alertText, .confirm-text { color: var(--text); line-height: 1.8; white-space: pre-wrap; }
.modal-box {
  width: 460px; max-width: 92vw; background: var(--panel);
  border: 1px solid var(--line); border-radius: 10px; padding: 16px;
  box-shadow: 0 12px 40px rgba(24, 36, 58, .25);
}
.modal-title { font-weight: 700; color: #1B2432; margin-bottom: 12px; }
.modal-row { display: flex; gap: 8px; margin-bottom: 12px; }
.modal-row input { flex: 1; }
.proj-list { max-height: 280px; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; }
.proj-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-bottom: 1px solid #E8EDF6; }
.proj-item:last-child { border-bottom: none; }
.proj-item .nm { flex: 1; }
.proj-item .meta { color: var(--muted); font-size: 12px; }
.proj-empty { padding: 16px; text-align: center; color: var(--muted); }
.modal-foot { margin-top: 12px; text-align: right; }

/* 「权限管理」小窗口：两列排布，宽窄对齐（原来挤在表格「操作」列的那排按钮） */
.perm-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.perm-actions button { padding: 6px 10px; }

#toast {
  position: fixed; left: 50%; bottom: 60px; transform: translateX(-50%);
  background: #1F2A3A; color: #fff; padding: 9px 16px; border-radius: 8px;
  font-size: 13px; max-width: 70vw; white-space: pre-wrap; z-index: 80;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .2);
}
#toast.err { background: var(--danger); }

.hidden { display: none !important; }

/* ---------------------------------------------------------------- 登录 / 注册 */
body.auth-body { align-items: center; justify-content: center; }
.auth-card {
  width: 360px; max-width: 92vw; background: var(--panel);
  border: 1px solid var(--line); border-radius: 10px; padding: 24px 24px 12px;
  box-shadow: 0 14px 44px rgba(24, 36, 58, .12);
}
.auth-brand { text-align: center; margin-bottom: 18px; }
.auth-brand .app-name { font-size: 18px; }
.auth-tabs {
  display: flex; gap: 4px; background: var(--bg);
  border-radius: 8px; padding: 4px; margin-bottom: 16px;
}
.auth-tab {
  flex: 1; text-align: center; padding: 7px 0; border-radius: 6px;
  color: var(--muted2); cursor: pointer; user-select: none;
}
.auth-tab.active { background: var(--panel); color: #2456C4; font-weight: 600; }
/* 最上面那一档：前台 / 后台 —— 决定这次登录进哪个门（不只是切表单） */
.auth-scope {
  display: flex; gap: 4px; margin-bottom: 12px; padding: 4px;
  background: var(--accent-soft); border: 1px solid var(--line-strong); border-radius: 8px;
}
.auth-scope-btn {
  flex: 1; padding: 8px 0; border: 0; border-radius: 6px; background: transparent;
  color: var(--muted2); font: inherit; font-size: 13px; cursor: pointer; user-select: none;
}
.auth-scope-btn:hover { background: #DCE6FA; }
.auth-scope-btn.active { background: var(--accent); color: #fff; font-weight: 600; }
.auth-form { display: flex; flex-direction: column; gap: 12px; }
.auth-form label { display: flex; flex-direction: column; gap: 5px; color: var(--muted2); font-size: 12px; }
.auth-form input { width: 100%; min-height: 34px; }
.auth-form button { margin-top: 4px; min-height: 36px; }

/* 两张表单（密码登录 / 短信登录）叠在同一个格子里：卡片高度永远按高的那张算，
   切换页签时大小纹丝不动，不会看着晃眼。
   .hidden 自带 display:none !important，这里得盖回来并换成 visibility:hidden，
   让隐藏的表单继续占位——看不见、点不着，但撑住高度。 */
.auth-forms { display: grid; }
.auth-forms > .auth-form { grid-area: 1 / 1; }
.auth-forms > .auth-form.hidden { display: flex !important; visibility: hidden; }

/* 「记住我」那一行：勾选框和说明文字横着排，别被上面 input 的整行宽度带偏 */
.auth-form .remember-row { flex-direction: row; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.auth-form .remember-row input { width: auto; min-height: 0; height: 15px; margin: 0; accent-color: var(--accent); }

/* 短信登录表单里的同款空位：结构与「记住我」那一行一模一样，只是看不见（撑高度用），
   这样两个页签来回切，「登录」按钮位置不会上下跳 */
.auth-form .remember-ph { visibility: hidden; pointer-events: none; }

/* 登录按钮下面那一排文字链接：刷新页面靠左、注册账号靠右，并排一行。
   它不在表单里了（两条表单共用），间距自己带上 */
.auth-links { display: flex; align-items: center; justify-content: space-between; margin-top: 12px; }
.auth-links a { padding: 3px 0; color: var(--muted2); font-size: 12px; cursor: pointer; user-select: none; }
.auth-links a:hover { color: var(--accent); text-decoration: underline; }
/* 提示条：不管有没有内容都占住一行，这样点「登录」出错时外壳高度不会变长；
   底部留白改由卡片自己的内边距收窄来控，看起来不空 */
.auth-msg { margin-top: 8px; min-height: 16px; text-align: center; font-size: 12px; color: var(--danger); }
.auth-msg.ok { color: #2E7D32; }

/* 图形验证码 / 短信验证码那一行：输入框 + 图片 / 获取按钮 并排 */
.cap-row, .code-row { display: flex; gap: 8px; align-items: stretch; }
.cap-row input, .code-row input { flex: 1 1 auto; min-width: 0; }
.cap-img {
  flex: none; display: block; width: 132px; height: 34px;
  border: 1px solid var(--line); border-radius: 6px;
  background: var(--panel); cursor: pointer;
}
.code-row .send-code {
  flex: none; margin-top: 0; min-height: 34px; padding: 0 12px; white-space: nowrap;
}

/* ---------------------------------------------------------------- 注册页（整页铺满）
   登录页那张 360px 的小卡片放不下 11 项资料，所以注册单独一页：顶栏吸顶，
   下面按「账号信息 / 个人资料 / 开票信息 / 收货地址」分四块，一行排三格。 */
body.reg-body { display: block; height: auto; min-height: 100vh; overflow-y: auto; }
.reg-top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 10px;
  padding: 12px 22px; background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.reg-sub { color: var(--accent); font-size: 12px; }
.reg-tip { color: var(--muted); font-size: 12px; }
.reg-form { max-width: 1120px; margin: 0 auto; padding: 16px 22px 32px; }
.reg-grid {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px 18px;
}
.reg-grid > label {
  display: flex; flex-direction: column; gap: 5px;
  color: var(--muted2); font-size: 12px;
}
.reg-grid > label > input, .reg-grid > label > select { width: 100%; min-height: 32px; }
.reg-actions { display: flex; align-items: center; gap: 12px; margin-top: 14px; }
.reg-actions #btnReg, .reg-actions #btnBackLogin2 { min-width: 132px; min-height: 36px; }
.reg-actions .auth-msg { margin-top: 0; text-align: left; }
@media (max-width: 900px) { .reg-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 620px) { .reg-grid { grid-template-columns: minmax(0, 1fr); } }

/* 调试模式：登录页的测试账号快捷按钮 */
.debug-note { color: var(--muted); font-size: 12px; margin-bottom: 6px; }
.debug-chips { display: flex; gap: 6px; margin-bottom: 14px; }
.debug-chip {
  flex: 1; display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  padding: 7px 10px; font-size: 12px; line-height: 1.35; text-align: left;
}
.debug-chip span { color: var(--muted); font-family: Consolas, monospace; font-size: 11px; }
.debug-chip.active { border-color: var(--accent); background: var(--accent-soft); color: #2456C4; }
.debug-chip.active span { color: #2456C4; }



/* ---------------------------------------------------------------- 后台管理 */
/* auto-fit：卡片把整行铺满（auto-fill 会留出空轨道，右边会空一截） */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(148px, 1fr)); gap: 10px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; }
.stat .k { color: var(--muted); font-size: 12px; }
.stat .v { font-size: 22px; font-weight: 700; color: #1B2432; margin-top: 4px; }

table.grid {
  width: 100%; border-collapse: collapse; background: var(--panel);
  border: 1px solid var(--line); border-radius: 8px; overflow: hidden;
}
table.grid th, table.grid td {
  border-bottom: 1px solid #E8EDF6; padding: 7px 10px;
  /* 表头与内容统一居中 */
  text-align: center; vertical-align: middle;
}
table.grid th { background: #EEF3FC; color: var(--muted); font-weight: 600; white-space: nowrap; }
table.grid tr:last-child td { border-bottom: none; }
table.grid tbody tr:hover td { background: #F1F5FE; }
table.grid td.actions { white-space: nowrap; }
/* 操作列居中：按钮左右留一样的边距，整体才居中 */
table.grid td.actions button { padding: 3px 10px; font-size: 12px; margin: 2px 3px; }
/* 「修改」「进入（N）」等宽：短的那个补到一样宽，并排看整齐 */
table.grid td.actions button.act-eq { min-width: 90px; }
table.grid td.num, table.grid th.num { text-align: center; }
/* 可排序表头：点一下按该列升降序，hover 变主色提示可点 */
table.grid th.sortable { cursor: pointer; user-select: none; }
table.grid th.sortable:hover { color: var(--accent); }

/* 用户管理：管理员 / 普通用户是上下两张表，用同一套固定列宽，上下表头才对得齐。
   列宽写死在 admin.js 的 USER_COLS 里；这里把左右内边距收窄一点，
   固定列宽下「调试模式」「手机号码」这类四字表头才不会顶出格子 */
table.grid.user-grid { table-layout: fixed; }
table.grid.user-grid th, table.grid.user-grid td { padding: 7px 6px; }

/* 后台首页：增长曲线的区间切换按钮 + 手绘 SVG */
.range-btn { padding: 3px 12px; font-size: 12px; }
.range-btn.active {
  background: var(--accent-soft); border-color: var(--accent);
  color: #2456C4; font-weight: 600;
}
.chart-svg { width: 100%; height: auto; display: block; }

/* 增长曲线容器：先按图形宽高比把高度占住，加载中/切换区间时页面不会抖动 */
#growthChart { aspect-ratio: 940 / 328; }
#growthChart.loading { opacity: .45; transition: opacity .15s; }


/* 客户页：三个品种的卡片 */
.type-cards {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px; margin: 12px 0;
}
.type-card {
  border: 1px solid var(--line); border-radius: 8px; padding: 13px 15px;
  background: var(--bg); cursor: pointer; user-select: none;
}
.type-card:hover { border-color: var(--accent); background: #F7FAFF; }
.type-card.active { border-color: var(--accent); background: var(--accent-soft); }
.type-card .k { font-size: 12px; color: var(--muted); }
.type-card .v { font-size: 24px; font-weight: 700; color: #1B2432; margin-top: 5px; }
.crumb { color: var(--muted); font-size: 13px; }
.crumb b { color: var(--text); }

.tag { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 12px; white-space: nowrap; }
.tag.on { background: #E4F3E5; color: #2E7D32; }
.tag.off { background: #F0F3F8; color: #A39E95; }
.tag.admin { background: var(--accent-soft); color: #2456C4; }
.tag.user { background: #EEF1F6; color: #5A6B85; }
.tag.type { background: #EEF4EC; color: #4A7C59; }
.tag.warn { background: #FBF0DC; color: #B8791B; }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 7px 8px; align-items: baseline; }
.kv .k { color: var(--muted); font-size: 12px; text-align: right; white-space: nowrap; }
.kv .k::after { content: "："; }
.kv .v { color: var(--text); font-family: Consolas, monospace; font-size: 12px; word-break: break-all; }
.kv .name { font-family: "Microsoft YaHei UI", "Segoe UI", sans-serif; font-weight: 700; }

.form-grid { display: grid; grid-template-columns: max-content 1fr; gap: 10px 12px; align-items: center; }
.form-grid label { color: var(--muted2); }
.form-grid input, .form-grid select, .form-grid textarea { width: 100%; }
/* 备注这类多行输入：给足高度、可纵向拉伸；标签顶对齐才对得齐第一行 */
.form-grid textarea { min-height: 150px; line-height: 1.6; resize: vertical; }
/* 没有标签的多行框（工程备注）：整行铺满，不空着左边那一列 */
.form-grid textarea.full { grid-column: 1 / -1; }
/* 带标签的整行多行框（商品购买链接）：标签也占满一行，框在它下面整行铺满 */
.form-grid label.full-row { grid-column: 1 / -1; }
.form-grid:has(textarea) { align-items: start; }
.form-grid:has(textarea) label { padding-top: 5px; }
.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.empty { padding: 20px; text-align: center; color: var(--muted); }

/* 后台：每种工程类型一块设置 */
.type-block {
  border: 1px solid var(--line); border-radius: 8px;
  padding: 10px 12px; margin-bottom: 10px; background: var(--bg);
}
.type-block .path-line { margin-bottom: 6px; }
.type-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.type-head b { color: var(--text); }
/* 分类卡片右上角的操作按钮组：上移 / 下移 / 删除分类，整体靠右 */
.type-ops { margin-left: auto; display: inline-flex; gap: 6px; }
.mono-cell { font-family: Consolas, monospace; font-size: 12px; word-break: break-all; }

/* ---------------------------------------------------------------- 客户工作台（左侧栏目布局） */
.wb { flex: 1; display: flex; min-height: 0; }

.side {
  width: 214px; flex: 0 0 auto; display: flex; flex-direction: column;
  background: var(--panel); border-right: 1px solid var(--line);
}
/* 左侧品牌块与右侧页头高度对齐（都是 68px，底部分隔线连成一条） */
.side-brand {
  min-height: 68px; padding: 12px 18px; border-bottom: 1px solid var(--line);
  display: flex; flex-direction: column; justify-content: center;
}
.side-brand .t { font-size: 15px; font-weight: 700; color: #1B2432; }
.side-brand .s {
  font-size: 11px; color: var(--muted); margin-top: 3px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.side-nav { flex: 1; padding: 10px; overflow-y: auto; }
.side-item {
  display: flex; align-items: center; gap: 10px; height: 38px; padding: 0 12px;
  margin-bottom: 3px; border-radius: 7px; color: var(--muted2);
  cursor: pointer; user-select: none; font-size: 13px;
}
.side-item:hover { background: var(--bg); color: var(--text); }
.side-item.active { background: var(--accent-soft); color: #2456C4; font-weight: 600; }
.side-item .ic { width: 16px; flex: 0 0 auto; }
.side-item .ic svg { width: 15px; height: 15px; display: block; }
.side-item .ic svg * { stroke: currentColor; fill: none; stroke-width: 1.5;
                       stroke-linecap: round; stroke-linejoin: round; }
.side-item .badge { margin-left: auto; font-size: 11px; color: var(--muted); }

/* 编辑器左侧栏底部：校验配置 / 恢复默认 + 状态提示（原本在页面底栏） */
.side-foot { flex: 0 0 auto; border-top: 1px solid var(--line); padding: 22px 10px 3px; }
.side-foot .btns { display: flex; gap: 6px; }
.side-foot .btns button { flex: 1; padding: 3px 8px; }
.side-foot .tpl-ver { margin-top: 14px; font-size: 12px; color: var(--muted); text-align: center; }
/* 状态提示固定两行高度（12px × 1.5 = 18px/行）：刷新时文案在 1~2 行之间变化，
   底部这块钱高度不变，「校验配置 / 恢复默认」就不会被顶得上下跳。
   更长的提示（如导出报错）在框内滚动，不再把底部撑高 */
.side-foot #statusMsg {
  margin-top: 8px; color: var(--muted); font-size: 12px; line-height: 1.5;
  height: 36px; overflow-y: auto; white-space: pre-wrap;
}

.ws { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.ws-head {
  flex: 0 0 auto; display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  min-height: 68px; padding: 12px 20px;
  border-bottom: 1px solid var(--line); background: var(--panel);
}
.ws-head .tt { font-size: 15px; font-weight: 700; color: #1B2432; }
.ws-head .st { font-size: 12px; color: var(--muted); }
.ws-head .acts { display: flex; gap: 8px; flex-wrap: wrap; }
/* 页头靠左的「后退 / 前进 / 刷新」：浏览器同款位置，只放图标不要文字 */
.head-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.head-nav { display: flex; align-items: center; gap: 2px; flex: none; }
.head-nav button {
  width: 30px; height: 30px; min-height: 30px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--muted2); background: transparent; border-color: transparent;
}
.head-nav button:hover { background: #EEF2FA; border-color: var(--line-strong); color: var(--text); }
.head-nav button:active { background: #E2E9F7; }
/* 到头了（没有可后退 / 可前进的记录）就压暗，样子和浏览器一致 */
.head-nav button:disabled { color: #CFC3B2; background: transparent; border-color: transparent; cursor: default; }
.head-nav button svg {
  width: 17px; height: 17px; fill: none; stroke: currentColor;
  stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}
.head-right { margin-left: auto; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
/* 页头这一排按钮字数不一样（「新建客户」4 字、「返回上一级」5 字、「退出登录」4 字……），
   自然宽度参差不齐；统一成一样的宽度，整排才齐。
   宽度按最长的那个定（「返回上一级」5 字，13px 字号约 65px），所以把原来的左右内边距
   16px 收到 11px，三个才能一起收到 92px；再窄文字就换行了 */
.head-right button { width: 92px; padding: 5px 11px; }
.head-user { display: flex; align-items: baseline; gap: 6px; font-size: 13px; }
.head-user b { color: var(--text); font-weight: 600; }
/* scrollbar-gutter：滚动条的位置一直留着，内容高度变化时不会因为滚动条
   出现/消失而左右晃一下（刷新时的抖动感主要来自这里） */
.ws-body { flex: 1; min-height: 0; overflow-y: auto; padding: 16px 20px 40px;
           scrollbar-gutter: stable; }

/* ---------------------------------------------------------------- 商品（图片 + 淘宝链接） */
/* 商品列表：列宽改由 colgroup 固定（见 admin.js 的 PROD_COLS）。
   自动列宽会把「状态」「更新时间」撑得虚宽、左边几列挤在一起，看着不平均；
   固定后左边几列宽度接近，「更新时间」「操作」按内容需要稍宽一点 */
table.grid.prod-table { table-layout: fixed; }
/* 固定列宽后格子变窄，左右内边距和操作按钮都收一点，三个按钮才排得下 */
table.grid.prod-table th, table.grid.prod-table td { padding: 7px 6px; }
table.grid.prod-table td.actions button { padding: 3px 6px; margin: 2px 2px; }
table.grid td.prod-thumb img {
  width: 72px; height: 72px; object-fit: cover; display: block; margin: 0 auto;
  border-radius: 6px; border: 1px solid var(--line);
}
/* 「查看链接」小窗口：整条链接放进只读框里，不再铺在表格上 */
.link-view-box {
  width: 100%; min-height: 140px; resize: vertical;
  font-size: 12px; line-height: 1.6; word-break: break-all;
}
.link-view-foot { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.link-open {
  display: inline-block; padding: 4px 12px; border: 1px solid var(--line-strong);
  border-radius: 6px; color: var(--accent); text-decoration: none; font-size: 13px;
}
.link-open:hover { background: var(--accent-soft); border-color: var(--accent); }

/* 后台发布商品弹窗里的图片预览 */
.form-grid input[type="file"] { font-size: 12px; }
.file-preview { margin-top: 6px; }
.file-preview img {
  width: 120px; height: 120px; object-fit: cover; display: block;
  border-radius: 8px; border: 1px solid var(--line);
}

/* 客户端「芯片采购」的商品卡片 */
.prod-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px;
}
.prod-card {
  display: flex; flex-direction: column; gap: 8px; padding: 10px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
}
.prod-card:hover { border-color: var(--accent); box-shadow: 0 6px 18px rgba(24, 36, 58, .08); }
.prod-img {
  display: flex; align-items: center; justify-content: center;
  height: 160px; background: var(--bg); border-radius: 6px; overflow: hidden;
}
.prod-img img { width: 100%; height: 100%; object-fit: contain; display: block; }
.prod-noimg { color: var(--muted); font-size: 12px; }
.prod-name {
  font-size: 13px; font-weight: 600; color: var(--text); line-height: 1.4;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.prod-buy {
  display: block; text-align: center; text-decoration: none; font-size: 13px;
  padding: 6px 0; border-radius: 6px; font-weight: 600;
  background: var(--accent); border: 1px solid var(--accent); color: #fff;
}
.prod-buy:hover { background: var(--accent-hi); border-color: var(--accent-hi); }
/* 「复制购买地址」：次要按钮，白底描边，跟上面的主按钮区分开 */
.prod-copy {
  display: block; width: 100%; padding: 6px 0; font-size: 13px; font-weight: 600;
  color: var(--accent);
}
.prod-copy:hover { background: var(--accent-soft); border-color: var(--accent); }

/* 资料下载 / 视频教程 */
table.grid.res-table { table-layout: fixed; }
table.grid.res-table td.pname { white-space: normal; word-break: break-word; }
table.grid.res-table td.res-desc { white-space: normal; word-break: break-word; color: var(--muted); }
.dl-link {
  display: inline-block; padding: 3px 12px; font-size: 12px; border-radius: 6px;
  border: 1px solid var(--accent); color: var(--accent); text-decoration: none;
  background: var(--panel); cursor: pointer; font-family: inherit;
}
.dl-link:hover { background: var(--accent-soft); }
.video-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.video-card {
  display: flex; flex-direction: column; gap: 8px; padding: 10px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
}
.video-card video {
  width: 100%; aspect-ratio: 16 / 9; background: #000;
  border-radius: 6px; display: block;
}
.video-name {
  font-size: 13px; font-weight: 600; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.video-desc { font-size: 12px; color: var(--muted); line-height: 1.5; }

/* 图表 */
.charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); gap: 12px; }
.chart-box {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 8px; padding: 12px 14px 10px;
}
.chart-box h4 { margin: 0 0 10px; font-size: 13px; color: var(--muted); font-weight: 600; }
.chart-box svg { display: block; width: 100%; height: auto; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 10px;
          font-size: 12px; color: var(--muted2); }
.legend span { display: inline-flex; align-items: center; }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 6px; }
.pname { font-weight: 600; }
.pname .tag { margin-left: 7px; }
/* 工程名 / 客户名不换行：名字长的时候整格横着撑开，不会折成两行（工作台与后台统一）。
   商品表是固定列宽（.prod-table），允许换行，否则长名称会撑破列宽 */
table.grid td.pname { white-space: nowrap; }
table.grid.prod-table td.pname { white-space: normal; }
.muted { color: var(--muted); font-size: 12px; }
/* 搜索框：宽度够放下完整提示文字（用户名 / 公司 / 手机号 / 地区 / 备注…），
   窄屏时由 .toolbar 的 flex-wrap 自动折行 */
.search { width: 360px; min-width: 360px; }

/* 列表分页条：表格超过一页（100 条）时才出现，居中贴在表格下方 */
.pager { display: flex; align-items: center; justify-content: center; gap: 12px;
         margin-top: 10px; font-size: 12px; color: var(--muted2); }
.pager button { padding: 3px 12px; font-size: 12px; }
.pager button[disabled] { opacity: .45; cursor: default; }
.pager b { color: var(--text); }

/* 用户管理里的备注列：太长就截断，悬停看完整内容（title） */
.remark-cell { display: inline-block; max-width: 200px; overflow: hidden;
               text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }

/* 侧栏栏目按权限隐藏：没有权限的栏目整个不显示 */
#nav .side-item.hidden { display: none; }

/* 权限管理页：每个管理员一张卡片，里面是栏目勾选 */
.role-card { background: var(--panel); border: 1px solid var(--line);
             border-radius: 8px; padding: 12px 14px; margin-bottom: 10px; }
.role-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.role-head b { font-size: 14px; color: var(--text); }
.perm-cbs { display: flex; flex-wrap: nowrap; overflow-x: auto; gap: 8px 16px; padding: 8px 0; }
.perm-cb { display: inline-flex; flex: 0 0 auto; align-items: center; gap: 5px;
           font-size: 13px; color: var(--text); cursor: pointer; }
.perm-cb input { width: 15px; height: 15px; accent-color: var(--accent); cursor: pointer; }
.role-foot { display: flex; align-items: center; gap: 12px;
             margin-top: 4px; padding-top: 10px; border-top: 1px dashed var(--line); }
