:root{
  --bg:#f5f6f8; --card:#fff; --line:#e3e6ec; --fg:#1d2330; --muted:#6b7485;
  --accent:#c0392b; --accent-soft:#fdecea;
}
*{box-sizing:border-box}
body{
  margin:0; background:var(--bg); color:var(--fg);
  font-family:system-ui,-apple-system,"Segoe UI","Microsoft YaHei",sans-serif;
  font-size:15px; line-height:1.5;
}
.top{
  position:sticky; top:0; z-index:10;
  background:var(--card); border-bottom:1px solid var(--line);
  padding:14px 22px 0; display:flex; flex-wrap:wrap; gap:14px;
  align-items:center; justify-content:space-between;
}
.brand{display:flex; gap:12px; align-items:center}
.logo{
  width:40px;height:40px;border-radius:11px;background:var(--accent);color:#fff;
  display:grid;place-items:center;font-weight:700;font-size:19px;
}
h1{font-size:17px;margin:0;letter-spacing:.5px}
#status{margin:2px 0 0;font-size:12.5px;color:var(--muted)}
.tabs{display:flex;gap:6px}
.tab{
  border:1px solid transparent;background:transparent;color:var(--muted);
  padding:9px 16px;border-radius:9px 9px 0 0;font-size:14px;cursor:pointer;
}
.tab:hover{background:#f0f2f5}
.tab.active{background:var(--bg);border-color:var(--line);border-bottom-color:var(--bg);color:var(--fg);font-weight:600}
.hidden{display:none !important}

main{padding:18px 22px 60px;max-width:1240px;margin:0 auto}

/* 变更记录这一页单独放宽到 1800，其它页面保持 1300 */
#panel-changes{
  width:min(1800px, 96vw);
  position:relative;
  left:50%;
  transform:translateX(-50%);
}
.panel{display:none}
.panel.active{display:block}

.searchbar{
  display:flex;gap:10px;align-items:center;flex-wrap:wrap;
  background:var(--card);border:1px solid var(--line);border-radius:12px;
  padding:12px;margin-bottom:16px;
}
.searchbar label{display:flex;gap:6px;align-items:center;color:var(--muted);font-size:13px}
input{
  font:inherit;padding:9px 11px;border:1px solid var(--line);border-radius:9px;
  background:#fff;color:var(--fg);outline:none;
}
input:focus{border-color:var(--accent)}
#codeInput{flex:1;min-width:240px}
#sizeL,#sizeW{width:96px}
#sizeTol{width:68px}
button.primary{
  font:inherit;padding:9px 20px;border:0;border-radius:9px;background:var(--accent);
  color:#fff;cursor:pointer;
}
button.primary:hover{filter:brightness(1.07)}
button.ghost{
  font:inherit;padding:9px 16px;border:1px solid var(--line);border-radius:9px;
  background:#fff;color:var(--fg);cursor:pointer;
}
button.ghost:hover:not(:disabled){border-color:var(--accent);color:var(--accent)}
button.ghost:disabled{opacity:.45;cursor:not-allowed}
.info{font-size:13px;color:var(--muted);margin:-6px 0 14px;min-height:18px}
.info:empty{margin:0}

.results{display:flex;flex-direction:column;gap:10px}
.item{
  display:grid;
  grid-template-columns:88px minmax(200px,260px) 190px minmax(240px,1fr);
  gap:16px;align-items:start;
  background:var(--card);border:1px solid var(--line);
  border-radius:12px;padding:12px 14px;
}
.item:hover{border-color:#cfd6e2}
.thumb{
  width:88px;height:88px;object-fit:cover;border-radius:9px;background:#eef0f4;
  cursor:zoom-in;
}
.thumb.empty{display:grid;place-items:center;color:#a9b1bf;font-size:12px;cursor:default}
.col{min-width:0}
.col-id .head{display:flex;gap:8px;align-items:baseline;margin-bottom:6px}
.col-id strong{font-size:15.5px;letter-spacing:.4px}
.count{font-size:11.5px;color:#fff;background:#9aa4b5;border-radius:20px;padding:1px 8px}
.chips{display:flex;flex-wrap:wrap;gap:5px}
.chip{
  display:inline-flex;gap:5px;align-items:center;font-size:12.2px;
  background:#f1f3f7;border-radius:7px;padding:2px 7px;color:#3a4252;
  max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;
}
.chip i{font-style:normal;color:#8b93a3;font-size:10.5px}
/* 查询命中：把命中的那个代码标红 */
.chip.chip-hit{background:#b5302a;color:#fff}
.chip.chip-hit i{color:#ffd9d3}
.label{display:block;font-size:11.5px;color:var(--muted);margin-bottom:3px;letter-spacing:.5px}
.col-size .val{display:block;font-size:15px;font-weight:600;letter-spacing:.3px}
.size-line{display:flex;gap:6px;align-items:baseline;margin-bottom:3px}
.size-tag{
  font-style:normal;font-size:11px;color:#fff;background:var(--accent);
  border-radius:4px;padding:1px 5px;line-height:1.3;
}
.foot{display:flex;gap:8px;align-items:center;margin-top:8px;flex-wrap:wrap}
.more{
  border:1px solid var(--line);background:#fff;border-radius:7px;
  padding:3px 10px;font-size:12px;color:var(--fg);cursor:pointer;font-family:inherit;
}
.more:hover{border-color:var(--accent);color:var(--accent)}
.extra{margin-top:8px;border-top:1px dashed var(--line);padding-top:6px;max-height:230px;overflow:auto}
.extra-row{display:grid;grid-template-columns:130px 1fr;gap:8px;font-size:12.5px;padding:2px 0}
.extra-row .k{color:var(--muted)}
.extra-row .v{word-break:break-all;white-space:pre-wrap}
.bom{margin-bottom:8px}
.block-title{font-size:12px;color:var(--muted);margin:8px 0 4px;padding-top:6px;border-top:1px dashed var(--line)}
.kv-block:first-of-type .block-title{border-top:0;padding-top:0}
.kv-block .extra-row{grid-template-columns:130px 1fr}
.bom-title{font-size:12px;color:var(--muted);margin-bottom:4px}
table.bomtable{border-collapse:collapse;width:100%;font-size:12.5px;margin-bottom:6px}
table.bomtable th,table.bomtable td{border-bottom:1px solid var(--line);padding:3px 6px;text-align:left}
table.bomtable th{color:var(--muted);font-weight:500}
table.bomtable td.mono{font-family:ui-monospace,Consolas,monospace;white-space:nowrap}
table.bomtable td.num{text-align:right;white-space:nowrap}
.inline{color:var(--muted);font-size:13px;display:flex;gap:6px;align-items:center}
select{font:inherit;padding:8px 10px;border:1px solid var(--line);border-radius:9px;background:#fff;color:var(--fg);max-width:220px}
.table-wrap{max-height:520px;overflow:auto;margin-top:10px;border:1px solid var(--line);border-radius:10px}
table.grid{border-collapse:collapse;width:100%;font-size:13px}
table.grid th,table.grid td{border-bottom:1px solid var(--line);padding:7px 10px;text-align:left;vertical-align:top}
table.grid th{position:sticky;top:0;background:#f7f8fa;font-weight:600;z-index:1}
table.grid tr.miss td{color:#b4453b;background:#fdf5f4}
td.clip{max-width:320px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.col-size .sub{display:block;font-size:12px;color:var(--muted);margin-top:4px}
.model-text{
  font-size:12.8px;color:#39414f;line-height:1.55;white-space:pre-wrap;
  overflow:hidden;
}
.model-text.clamped{
  display:-webkit-box;-webkit-line-clamp:3;-webkit-box-orient:vertical;
  cursor:pointer;
}
.model-text.clamped:hover{color:var(--accent)}
.note{margin-top:6px;font-size:12px;color:#8a5a2b;background:#fdf6ec;border-radius:6px;padding:4px 8px}
.badge{
  display:inline-block;margin-top:7px;font-size:11.5px;letter-spacing:.3px;
  border-radius:20px;padding:2px 10px;
}
.badge.yes{background:#e8f5ec;color:#1e7d43}
.badge.warn{background:#fdf3e2;color:#9a6a1c}
.badge.no{background:#f1f3f7;color:#8b93a3}
.empty-tip{color:var(--muted);font-size:14px;padding:20px 4px}

.card{background:var(--card);border:1px solid var(--line);border-radius:12px;padding:18px;margin-bottom:16px}
.card h2{font-size:15px;margin:0 0 6px}
.hint{color:var(--muted);font-size:13px;margin:0 0 12px}
.row{display:flex;gap:10px;flex-wrap:wrap;align-items:center}
.msg{margin-top:10px;font-size:13px;color:var(--muted);min-height:18px}
.msg.ok{color:#1e7d43}
.msg.err{color:#c0392b}
.report{margin:8px 0 0;padding-left:18px;font-size:12.5px;color:#8a5a2b}
.report li{margin:2px 0}
code{background:#f1f3f7;border-radius:4px;padding:1px 5px;font-size:12px}

.lightbox{
  position:fixed;inset:0;background:rgba(15,18,24,.86);display:grid;place-items:center;z-index:80;
}
.lightbox.hidden{display:none}
.lightbox img{max-width:92vw;max-height:88vh;border-radius:10px}
.lightbox .close{
  position:absolute;top:18px;right:24px;background:transparent;border:0;color:#fff;
  font-size:34px;cursor:pointer;line-height:1;
}

.modal{position:fixed;inset:0;background:rgba(15,18,24,.55);display:grid;place-items:center;z-index:60}
.modal.hidden{display:none}
.modal-box{
  background:#fff;border-radius:14px;width:min(880px,92vw);max-height:88vh;
  display:flex;flex-direction:column;box-shadow:0 20px 60px rgba(0,0,0,.25);
}
.modal-head{display:flex;justify-content:space-between;align-items:center;padding:13px 18px;border-bottom:1px solid var(--line)}
.modal-head .close{background:transparent;border:0;font-size:24px;cursor:pointer;color:var(--muted);line-height:1}
.modal-body{padding:14px 18px;overflow:auto}
.modal-foot{padding:12px 18px;border-top:1px solid var(--line);display:flex;justify-content:flex-end;gap:10px}
.edit-fields{display:grid;grid-template-columns:1fr 1fr;gap:10px 18px}
.edit-row{display:flex;flex-direction:column;gap:3px}
.edit-key{font-size:12px;color:var(--muted)}
.edit-row input,.edit-row textarea{
  width:100%;font:inherit;padding:6px 9px;border:1px solid var(--line);
  border-radius:8px;outline:none;resize:vertical;
}
.edit-row input:focus,.edit-row textarea:focus{border-color:var(--accent)}
.edit-foot{display:flex;gap:14px;margin-top:16px;align-items:flex-end;flex-wrap:wrap}
.edit-foot .grow{flex:1;min-width:240px}
.edit-foot input{flex:1;min-width:160px}
.req{color:var(--accent)}
@media (max-width:720px){.edit-fields{grid-template-columns:1fr}}

@media (max-width:900px){
  .item{grid-template-columns:76px 1fr;grid-template-areas:"img id" "img size" "model model"}
  .item > .thumb{grid-area:img;width:76px;height:76px}
  .col-id{grid-area:id}
  .col-size{grid-area:size}
  .col-model{grid-area:model}
}
@media (max-width:640px){
  main{padding:14px}
  .top{padding:12px 14px 0}
}

/* 打印记录分页 */
.pager {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
}
.pager-info {
  font-size: 13px;
  color: #666;
}
.pager button[disabled] {
  opacity: .45;
  cursor: not-allowed;
}
.grow-input {
  flex: 1 1 auto;
  min-width: 200px;
}
.muted {
  font-size: 13px;
  color: #888;
}

/* 打印按钮下拉、打印记录入口、预览小按钮 */
.menu-wrap { position: relative; display: inline-block; }
.menu {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  background: #fff;
  border: 1px solid #e3e6ea;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,.12);
  padding: 6px;
  min-width: 220px;
  z-index: 50;
}
.menu button {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: 0;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  color: #333;
}
.menu button:hover { background: #f4f6f8; }
.menu-printer { padding: 6px 10px 2px; border-top: 1px solid #f0f2f4; margin-top: 4px; }
.menu-printer select { width: 100%; }
.link {
  background: none;
  border: 0;
  padding: 0;
  color: #b5302a;
  font-size: 14px;
  cursor: pointer;
}
.link:hover { text-decoration: underline; }
.log-link-row { margin-top: 12px; }
button.mini {
  padding: 3px 10px;
  font-size: 12px;
  border: 1px solid #d8dce1;
  background: #fff;
  border-radius: 6px;
  cursor: pointer;
  color: #444;
}
button.mini:hover { border-color: #b5302a; color: #b5302a; }
td.op { white-space: nowrap; }

/* 工艺单预览里的图位 */
.img-slots {
  display: flex;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.img-slot {
  flex: 1 1 260px;
  border: 1px solid #e3e6ea;
  border-radius: 8px;
  padding: 10px;
  background: #fbfcfd;
}
.slot-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  color: #555;
  margin-bottom: 8px;
}
.slot-up {
  font-size: 12px;
  color: #b5302a;
  cursor: pointer;
  border: 1px solid #e6c9c7;
  padding: 2px 8px;
  border-radius: 6px;
  background: #fff;
}
.slot-up input { display: none; }
.slot-body {
  position: relative;
  height: 150px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  border-radius: 6px;
  overflow: hidden;
}
.slot-body img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}
.slot-body .slot-empty {
  position: absolute;
  color: #aaa;
  font-size: 13px;
}
.slot-body:not(.empty) .slot-empty { display: none; }
.slot-body.empty img { display: none; }

/* 老单文件夹确认 */
.confirm {
  border: 1px solid #e8c4c0;
  background: #fff7f6;
  border-radius: 10px;
  padding: 14px 16px;
  margin: 10px 0;
}
.confirm-title {
  font-size: 15px;
  color: #b5302a;
  font-weight: 600;
  margin-bottom: 6px;
}
.confirm-hint {
  font-size: 13px;
  color: #7a5b58;
  margin-bottom: 10px;
}

/* BOM 清单 */
.bom-wrap { max-height: 70vh; overflow: auto; }
.bomtable th, .bomtable td { white-space: nowrap; }
.bomtable th.idx, .bomtable td.idx { width: 46px; color: #999; text-align: right; }
.col-picker { margin: 10px 0; }
.col-picker summary { cursor: pointer; font-size: 14px; color: #b5302a; }
.col-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 4px 12px;
  max-height: 220px;
  overflow: auto;
  padding: 10px;
  border: 1px solid #eef0f2;
  border-radius: 8px;
  margin-top: 8px;
  background: #fbfcfd;
}
.col-item { font-size: 13px; color: #444; cursor: pointer; }

/* 嵌进公司网站：?embed=1 只留「查询」，隐藏页签和账号 */
body.embed .tabs, body.embed .user-chip { display: none; }

/* 免登录嵌入页：主色改蓝（R:45 G:163 B:221），logo 改白底蓝字 RZ（只影响 /embed） */
body.embed { --accent: #2DA3DD; --accent-soft: #e9f6fc; }
body.embed .logo {
  background: #fff; color: #2DA3DD; border: 2px solid #2DA3DD;
  font-size: 15px; letter-spacing: .5px;
}
body.embed button.primary { background: #2DA3DD; }
body.embed .chip.chip-hit { background: #2DA3DD; }
body.embed .chip.chip-hit i { color: #e5f6ff; }

/* 编辑/新增里的图片上传 */
.edit-images {
  margin: 14px 0 4px;
  padding: 12px;
  border: 1px dashed #dde1e6;
  border-radius: 8px;
  background: #fbfcfd;
}
.edit-images .hint { font-size: 12px; color: #999; margin-top: 4px; }

/* 右上角用户 */
.user-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: 16px;
  padding: 4px 10px 4px 4px;
  border: 1px solid #eceff2;
  border-radius: 999px;
  background: #fff;
  cursor: pointer;
  font-size: 13px;
  color: #444;
  max-width: 180px;
}
.user-chip:hover { border-color: #b5302a; }
.avatar-wrap {
  width: 28px; height: 28px; border-radius: 50%;
  background: #b5302a; color: #fff;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; flex: none; font-size: 13px;
}
.avatar-wrap img { width: 100%; height: 100%; object-fit: cover; }
#userNick { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 我的账户弹窗 */
.modal-box.narrow { max-width: 420px; }
.profile-top { display: flex; gap: 16px; align-items: center; margin-bottom: 16px; }
.profile-avatar {
  width: 64px; height: 64px; border-radius: 50%;
  background: #b5302a; color: #fff; font-size: 24px;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; flex: none;
}
.profile-avatar img { width: 100%; height: 100%; object-fit: cover; }

/* 缺项提示、整单补录表格 */
.miss-cell { background: #fff6d8 !important; }
.fill-table input, .fill-table textarea {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid transparent;
  background: transparent;
  font-size: 13px;
  padding: 2px 4px;
  font-family: inherit;
}
.fill-table input:focus, .fill-table textarea:focus {
  border-color: #b5302a;
  background: #fff;
  outline: none;
}
.modal-box.wide { max-width: 96vw; width: 1500px; }
.fill-row td { background: #f4faf4; }

/* 整单补录：表格放宽，看不全就横向滚动 */
#fillTable table.grid { min-width: 2600px; }
#fillTable th { white-space: nowrap; font-size: 12px; }
#fillTable td { padding: 3px 5px; }
#fillTable input, #fillTable textarea { min-width: 110px; font-size: 12.5px; }
#fillTable thead th:first-child { position: sticky; left: 0; background: #f7f8fa; z-index: 2; }
#fillTable tbody td:first-child { position: sticky; left: 0; background: #fff; z-index: 1; }
a.mini-link {
  font-size: 12px;
  color: #b5302a;
  text-decoration: none;
  border: 1px solid #e6c9c7;
  padding: 2px 8px;
  border-radius: 6px;
}
a.mini-link:hover { background: #fff3f2; }

/* 编辑弹窗里的产品图片 */
.img-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.img-list .muted { font-size: 12px; color: var(--muted); }
.img-thumb { position: relative; width: 76px; height: 76px; border: 1px solid var(--line);
  border-radius: 8px; overflow: hidden; background: #f7f8fa; }
.img-thumb img { width: 100%; height: 100%; object-fit: cover; cursor: zoom-in; display: block; }
.img-del { position: absolute; top: 2px; right: 2px; width: 20px; height: 20px; line-height: 1;
  border: 0; border-radius: 50%; background: rgba(0,0,0,.55); color: #fff; font-size: 13px;
  cursor: pointer; padding: 0; }
.img-del:hover { background: #b5302a; }
.sep { border: 0; border-top: 1px solid var(--line); margin: 14px 0; }
button.ghost.danger { color: #b5302a; border-color: #e7c3c0; }
button.ghost.danger:hover:not(:disabled) { border-color: #b5302a; color: #8d211c; }

/* 批量匹配：模糊命中标黄 */
table.grid tr.fuzzy td { background: #fff8e1; }
table.grid tr.fuzzy td:first-child { box-shadow: inset 3px 0 0 #e0a800; }

/* 变更记录：表头筛选（像 Excel） */
table.chgtable th.chgth { white-space: nowrap; padding-right: 4px; }
.chgfilter-btn { border: 0; background: transparent; color: #b5302a; cursor: pointer;
  font-size: 12px; padding: 0 3px; line-height: 1; }
.chgfilter-btn.on { background: #fdecea; border-radius: 4px; }
.chgsort { color: #b5302a; font-size: 11px; margin-left: 2px; }
.cfilter { position: absolute; z-index: 70; width: 250px; padding: 10px; font-size: 13px;
  background: #fff; border: 1px solid #d8dde5; border-radius: 10px;
  box-shadow: 0 8px 24px rgba(15,18,24,.16); }
.cfilter-tip { font-size: 12px; color: #8b93a3; margin-bottom: 6px; }
.cfilter-q { width: 100%; box-sizing: border-box; font: inherit; padding: 4px 6px;
  border: 1px solid #dfe3ea; border-radius: 6px; margin-bottom: 6px; }
.cfilter-acts { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 6px; }
.cfilter-list { max-height: 220px; overflow: auto; border-top: 1px solid #eef0f4; padding-top: 6px; }
.cfilter-item { display: flex; gap: 6px; align-items: flex-start; padding: 2px 0; line-height: 1.35; word-break: break-all; }
td.nowrap { white-space: nowrap; }

/* 变更记录：整张表格开，不横向拖动，长文本自动换行 */
#chgResult table.grid { min-width: 0; width: 100%; font-size: 12.5px; }
#chgResult th { white-space: nowrap; }
#chgResult td { white-space: normal; word-break: break-all; }
#chgResult td.clip { max-width: none; overflow: visible; text-overflow: clip; }
#chgResult td:nth-child(1) { white-space: nowrap; }
#chgResult td:nth-child(2) { white-space: nowrap; }

/* 颜色说明 */
.legend { display: flex; flex-wrap: wrap; gap: 16px; margin: 8px 0 10px; font-size: 13px; color: #555; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 14px; height: 14px; border-radius: 3px; display: inline-block; border: 1px solid #ddd; }
.legend .c-ok { background: #fff; }
.legend .c-fuzzy { background: #fff8e1; border-color: #e0a800; }
.legend .c-miss { background: #fdf5f4; border-color: #b4453b; }

/* 危险操作按钮（删除） */
button.mini.danger { color: #b5302a; border-color: #e6c9c7; }
button.mini.danger:hover { background: #fdf1f0; }
