/* ==========================================================================
   排样测算（独立工具页）
   只放这一页自己的样式，通用类（.btn/.toolbar/.view/.hidden…）沿用 style.css。
   命名统一加 .nst- 前缀，避免和其它页撞车；整体仍吃 style.css 的 CSS 变量，
   所以换底色/品牌色不用改这里。
   ========================================================================== */

/* ---- 输入区 ---- */
.nst-grid{
  display:grid;grid-template-columns:minmax(340px,400px) minmax(0,1fr);
  gap:16px;align-items:start;
}
@media (max-width:1180px){ .nst-grid{grid-template-columns:1fr} }

.nst-panel{
  background:var(--panel);border:1px solid var(--line);border-radius:var(--radius);
  padding:13px 14px;box-shadow:var(--shadow);
}
.nst-panel + .nst-panel{margin-top:12px}
.nst-panel > h3{
  margin:0 0 10px;font-size:13.5px;font-weight:600;color:var(--ink);
  display:flex;align-items:center;gap:7px;
}
.nst-panel > h3 .nst-step{
  display:inline-grid;place-items:center;width:18px;height:18px;border-radius:50%;
  background:var(--brand-l);color:var(--brand-d);font-size:11px;font-weight:700;
  font-family:var(--mono);flex:none;
}

/* 一行两/三个数字 */
.nst-row{display:flex;gap:8px;flex-wrap:wrap;margin-bottom:9px}
.nst-f{display:flex;flex-direction:column;gap:3px;flex:1;min-width:0}
.nst-f > label{font-size:11.5px;color:var(--ink3);white-space:nowrap}
.nst-f > label b{color:var(--ink2);font-weight:600}
.nst-f input,.nst-f select{
  width:100%;padding:6px 8px;border:1px solid var(--line);border-radius:7px;
  background:var(--panel2);font-size:13px;color:var(--ink);outline:none;
  font-family:var(--mono);transition:.15s;
}
.nst-f input:focus,.nst-f select:focus{
  border-color:var(--brand);background:#fff;box-shadow:0 0 0 3px var(--brand-l);
}
.nst-f input.nst-err{border-color:var(--up);background:var(--up-bg)}
.nst-f .nst-unit{font-size:11px;color:var(--ink3)}

/* 快捷大板尺寸 */
.nst-quick{display:flex;gap:5px;flex-wrap:wrap;margin:-2px 0 10px}
.nst-quick button{
  border:1px solid var(--line);background:#fff;color:var(--ink2);cursor:pointer;
  padding:3px 8px;border-radius:6px;font-size:11.5px;font-family:var(--mono);transition:.15s;
}
.nst-quick button:hover{border-color:var(--brand);color:var(--brand);background:var(--brand-l)}

/* 开关 */
.nst-switch{display:flex;align-items:center;gap:7px;font-size:12.5px;color:var(--ink2);cursor:pointer;user-select:none}
.nst-switch input{width:15px;height:15px;accent-color:var(--brand);cursor:pointer}
.nst-switch .nst-warn{color:var(--warn);font-size:11.5px}

/* ---- 规格清单表 ---- */
.nst-specs{width:100%;border-collapse:collapse;margin-bottom:8px}
.nst-specs th{
  font-size:11px;color:var(--ink3);font-weight:500;text-align:left;
  padding:0 4px 5px;white-space:nowrap;
}
.nst-specs td{padding:2px 3px;vertical-align:middle}
.nst-specs td input{
  width:100%;padding:5px 7px;border:1px solid var(--line);border-radius:6px;
  background:var(--panel2);font-size:12.5px;font-family:var(--mono);color:var(--ink);outline:none;
}
.nst-specs td input:focus{border-color:var(--brand);background:#fff;box-shadow:0 0 0 2px var(--brand-l)}
.nst-specs td input.nst-err{border-color:var(--up);background:var(--up-bg)}
.nst-specs .nst-col-w{width:26%}
.nst-specs .nst-col-h{width:26%}
.nst-specs .nst-col-n{width:20%}
.nst-specs .nst-col-x{width:28px}
.nst-specs .nst-del{
  border:0;background:none;color:var(--ink3);cursor:pointer;font-size:15px;
  line-height:1;padding:2px 5px;border-radius:5px;
}
.nst-specs .nst-del:hover{color:var(--up);background:var(--up-bg)}
.nst-specs caption{caption-side:top;text-align:left}
.nst-add{
  border:1px dashed var(--line);background:var(--panel2);color:var(--ink2);
  width:100%;padding:6px;border-radius:7px;cursor:pointer;font-size:12px;transition:.15s;
}
.nst-add:hover{border-color:var(--brand);color:var(--brand);background:var(--brand-l)}

/* ---- 缺陷区 ---- */
/* .nst-panel 不做 overflow:hidden，但最后一行元素的 margin 会和 padding
   叠加出"看着被切掉"的错觉；这里显式给容器底部留出间距，并把最后一行
   的下外边距去掉，避免面板底边贴住内容。 */
.nst-defects{margin-top:2px}
.nst-defects:empty{display:none}
.nst-defect{
  display:flex;gap:6px;align-items:center;margin-bottom:5px;
  background:var(--panel2);border:1px solid var(--line);border-radius:7px;padding:5px 6px;
}
.nst-defect:last-child{margin-bottom:0}
.nst-defect label{font-size:10.5px;color:var(--ink3);flex:none}
.nst-defect input{
  width:100%;min-width:0;padding:4px 6px;border:1px solid var(--line);border-radius:5px;
  background:#fff;font-size:12px;font-family:var(--mono);color:var(--ink);outline:none;
}
.nst-defect .nst-del{
  border:0;background:none;color:var(--ink3);cursor:pointer;font-size:15px;padding:2px 4px;flex:none;
}
.nst-defect .nst-del:hover{color:var(--up)}
/* 缺陷区行与"增加"按钮之间留一口气 */
.nst-defects:not(:empty) + .nst-add{margin-top:7px}

/* ---- 操作按钮 ---- */
.nst-actions{display:flex;gap:8px;margin-top:12px}
.nst-actions .btn{flex:1;justify-content:center;text-align:center;padding:9px}

/* 面板内的"最后一块内容"统一不留下外边距，否则视觉上面板底边像被切掉 */
.nst-panel > *:last-child{margin-bottom:0}
.nst-panel > p.hint:last-child{margin-bottom:0}

/* ---- 结果区 ---- */
.nst-summary{
  display:grid;grid-template-columns:repeat(auto-fit,minmax(132px,1fr));gap:1px;
  background:var(--line);border:1px solid var(--line);border-radius:var(--radius);
  overflow:hidden;margin-bottom:12px;
}
.nst-kpi{background:var(--panel);padding:11px 13px}
.nst-kpi .k{font-size:11.5px;color:var(--ink3);margin-bottom:4px}
.nst-kpi .v{
  font-size:22px;font-weight:600;color:var(--ink);font-family:var(--mono);
  line-height:1.15;white-space:nowrap;
}
.nst-kpi .v small{font-size:12px;color:var(--ink3);font-weight:500;font-family:inherit;margin-left:2px}
.nst-kpi .s{font-size:11px;color:var(--ink3);margin-top:3px}
.nst-kpi.hl .v{color:var(--brand)}
.nst-kpi.good .v{color:var(--down)}
.nst-kpi.warn .v{color:var(--warn)}

/* ---- 排样图 ---- */
.nst-canvas-wrap{
  background:var(--panel);border:1px solid var(--line);border-radius:var(--radius);
  padding:12px;box-shadow:var(--shadow);
}
.nst-canvas-head{
  display:flex;align-items:center;gap:10px;margin-bottom:9px;flex-wrap:wrap;
}
.nst-canvas-head h3{margin:0;font-size:13.5px;font-weight:600;color:var(--ink)}
.nst-legend{display:flex;gap:11px;flex-wrap:wrap;font-size:11.5px;color:var(--ink2);margin-left:auto}
.nst-legend span{display:flex;align-items:center;gap:4px}
.nst-legend i{width:11px;height:11px;border-radius:3px;display:block;border:1px solid rgba(0,0,0,.12)}
.nst-svg-box{position:relative;width:100%;overflow:hidden;border-radius:8px;background:var(--panel2)}
.nst-svg-box svg{display:block;width:100%;height:auto}
.nst-svg-box .nst-empty{
  padding:56px 20px;text-align:center;color:var(--ink3);font-size:13px;
}
/* SVG 内部元素 */
.nst-slab{fill:#fbfcfd;stroke:#c8d0d8;stroke-width:1.2}
.nst-usable{fill:none;stroke:var(--brand);stroke-width:1;stroke-dasharray:5 4;opacity:.4}
.nst-piece{fill:var(--brand-l);stroke:var(--brand);stroke-width:1.1;rx:2}
.nst-piece.f0{fill:#e8eff6;stroke:#14568A}
.nst-piece.f1{fill:#e8f6f0;stroke:#0f8a5f}
.nst-piece.f2{fill:#fdf4e3;stroke:#b26a00}
.nst-piece.f3{fill:#f9f3e8;stroke:#B0813C}
.nst-piece.f4{fill:#f3eef8;stroke:#7a5aa8}
.nst-piece.f5{fill:#fdecea;stroke:#cf3a2e}
.nst-piece-label{
  font-size:9px;fill:#2b3138;font-family:"JetBrains Mono",Consolas,monospace;
  text-anchor:middle;dominant-baseline:middle;pointer-events:none;
}
.nst-defect-rect{fill:rgba(207,58,46,.20);stroke:#cf3a2e;stroke-width:1;stroke-dasharray:3 3}
.nst-defect-label{
  font-size:8.5px;fill:#a02a20;text-anchor:middle;dominant-baseline:middle;pointer-events:none;
}
.nst-dim{font-size:11px;fill:var(--ink3);font-family:var(--mono)}
.nst-kerf{stroke:#cf3a2e;stroke-width:.6;opacity:.35}

/* ---- 提示条 ---- */
.nst-note{
  border-radius:8px;padding:9px 12px;font-size:12.5px;line-height:1.6;
  margin-bottom:11px;border:1px solid var(--line);background:var(--panel2);color:var(--ink2);
}
.nst-note.warn{background:var(--warn-bg);border-color:#f0dcc0;color:var(--warn)}
.nst-note.bad{background:var(--up-bg);border-color:#f0cdc9;color:var(--up)}
.nst-note.good{background:var(--down-bg);border-color:#c6e6da;color:var(--down)}
.nst-note b{font-weight:600}
.nst-note code{
  font-family:var(--mono);background:rgba(0,0,0,.05);padding:1px 4px;border-radius:4px;font-size:12px;
}

/* ---- 出材明细表 ---- */
.nst-detail{margin-top:13px}
.nst-detail h4{margin:0 0 8px;font-size:13px;font-weight:600;color:var(--ink)}
.nst-detail table{width:100%;border-collapse:collapse;font-size:12.5px}
.nst-detail th{
  text-align:left;font-size:11.5px;color:var(--ink3);font-weight:500;
  padding:6px 9px;border-bottom:1px solid var(--line);white-space:nowrap;
}
.nst-detail td{padding:6px 9px;border-bottom:1px solid var(--line2);font-family:var(--mono)}
.nst-detail th:first-child,.nst-detail td:first-child{font-family:inherit}
.nst-detail tr:last-child td{border-bottom:0}
.nst-detail td.num{text-align:right}
.nst-detail .miss{color:var(--up);font-weight:600}

/* ---- 成本联动 ---- */
.nst-cost{
  margin-top:13px;background:var(--panel);border:1px solid var(--line);
  border-radius:var(--radius);padding:12px 14px;box-shadow:var(--shadow);
}
.nst-cost h4{margin:0 0 9px;font-size:13px;font-weight:600;color:var(--ink)}
.nst-cost-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(150px,1fr));gap:11px}
.nst-cost-item .k{font-size:11.5px;color:var(--ink3);margin-bottom:2px}
.nst-cost-item .v{font-size:16px;font-weight:600;font-family:var(--mono);color:var(--ink)}
.nst-cost-item .v.hl{color:var(--brand)}
.nst-cost-item .s{font-size:11px;color:var(--ink3);margin-top:2px}

/* ---- 打印/导出用：隐藏控件 ---- */
@media print{
  .nst-panel:first-child,.nst-actions,.nav,.topbar{display:none !important}
  .nst-grid{grid-template-columns:1fr}
}
