* { box-sizing: border-box; }
body {
  font-family: "Microsoft JhengHei", "PingFang TC", Arial, sans-serif;
  background: #f4f6f8;
  margin: 0;
  color: #1f2d3d;
}
header {
  background: #1f4e78;
  color: #fff;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
header h1 { font-size: 18px; margin: 0; }
header .actions button {
  background: #ffffff22;
  border: 1px solid #ffffff55;
  color: #fff;
  padding: 6px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
}
header .actions span { font-size: 12px; opacity: .85; margin-right: 10px; }

nav.tabs {
  display: flex;
  background: #fff;
  border-bottom: 1px solid #dde3ea;
}
nav.tabs button {
  flex: none;
  padding: 12px 22px;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 14px;
  color: #55606e;
  border-bottom: 3px solid transparent;
}
nav.tabs button.active {
  color: #1f4e78;
  border-bottom-color: #1f4e78;
  font-weight: bold;
}

main { padding: 20px; max-width: 1180px; margin: 0 auto; }
.panel { display: none; }
.panel.active { display: block; }

.card {
  background: #fff;
  border-radius: 8px;
  padding: 18px 20px;
  margin-bottom: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
}
.card h2 { font-size: 15px; margin: 0 0 12px; color: #1f4e78; }

.search-row { display: flex; gap: 10px; margin-bottom: 10px; }
.search-row input[type=text] {
  flex: 1;
  padding: 9px 12px;
  border: 1px solid #cfd8e3;
  border-radius: 5px;
  font-size: 14px;
}
.search-row button {
  padding: 9px 16px;
  border: none;
  background: #1f4e78;
  color: #fff;
  border-radius: 5px;
  cursor: pointer;
}

table { width: 100%; border-collapse: collapse; font-size: 13px; }
table th, table td {
  text-align: left;
  padding: 7px 9px;
  border-bottom: 1px solid #edf0f4;
}
table th { color: #7a8898; font-weight: 600; background: #f9fafb; }
table tr.clickable { cursor: pointer; }
table tr.clickable:hover { background: #eef4fa; }
table tr.selected { background: #dcebfa; }

/* 2026-08-20 新增：欄位資料來源標註（工程用，方便核對 ERP 欄位對照），
   顯示在表頭下方的一小行灰字，例如「DAT・pod.dbf」。可以用旁邊的
   checkbox 開關，不影響一般使用時的畫面。 */
.eng-toggle {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; color: #7a8898; margin: 6px 0 2px;
  cursor: pointer;
}
.col-src {
  display: none;
  font-size: 10px; font-weight: normal; color: #a9b3bf;
  margin-top: 2px;
}
/* body 上有 .eng-mode 時（工程模式開啟）才顯示這些小灰字標註，
   兩個頁面（新增檢驗／產能查詢）共用同一個開關，見 eng_mode.js。 */
body.eng-mode .col-src { display: block; }
.field .col-src { margin-top: 1px; }
.kpi-tile .k-label .col-src { margin-top: 0; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}
.form-grid.wide { grid-template-columns: repeat(2, 1fr); }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 12px; color: #6b7684; }
.field input, .field select, .field textarea {
  padding: 8px 10px;
  border: 1px solid #cfd8e3;
  border-radius: 5px;
  font-size: 14px;
  font-family: inherit;
}
.field input[readonly] { background: #f4f7fa; color: #46525f; }
.field.span2 { grid-column: span 2; }
.field.span3 { grid-column: span 3; }

.save-bar {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}
.save-bar button {
  padding: 10px 22px;
  border-radius: 5px;
  border: none;
  font-size: 14px;
  cursor: pointer;
}
.btn-primary { background: #1f4e78; color: #fff; }
.btn-secondary { background: #eef1f5; color: #46525f; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11px; }
.badge.pass { background: #dff3e3; color: #237a3d; }
.badge.fail { background: #fbe2e2; color: #b3261e; }
.badge.pending { background: #fdf0d5; color: #9a6700; }
.qc-status-badge { cursor: pointer; }
.qc-status-badge:hover { filter: brightness(0.95); }

.hint { font-size: 12px; color: #8b96a4; margin-top: 4px; }
.section-title { font-size: 13px; color: #1f4e78; margin: 20px 0 10px; border-left: 3px solid #1f4e78; padding-left: 8px; }
.checkbox-row { display: flex; flex-wrap: wrap; gap: 12px; font-size: 13px; color: #46525f; }
.checkbox-row label { display: flex; align-items: center; gap: 4px; font-weight: normal; }
button.small { padding: 6px 12px; font-size: 12px; margin-top: 6px; }
#erpStatus.ok { color: #b6e2c2; }
#erpStatus.bad { color: #f3b3b3; }
table td input[type=text] { width: 100%; padding: 5px 6px; border: 1px solid #dde3ea; border-radius: 4px; font-size: 13px; }
.link-btn { background: none; border: none; color: #b3261e; cursor: pointer; font-size: 12px; }
.detail-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px 16px; font-size: 13px; }
.detail-grid .k { color: #8b96a4; }
.detail-grid .row { display: flex; justify-content: space-between; border-bottom: 1px dashed #edf0f4; padding: 4px 0; }
.toast {
  position: fixed; top: 16px; right: 16px;
  background: #1f4e78; color: #fff; padding: 10px 18px;
  border-radius: 6px; font-size: 13px; box-shadow: 0 2px 8px rgba(0,0,0,.15);
  opacity: 0; transform: translateY(-8px); transition: all .25s;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translateY(0); }
