.cbq-workbench { min-height: 760px; height: calc(100vh - 260px); display: grid; grid-template-rows: auto minmax(0, 1fr) auto; gap: 8px; color: #18344f; }
.cbq-page-tabs { display: flex; gap: 6px; padding: 6px; border: 1px solid #cbd9e6; border-radius: 8px; background: #edf3f8; }
.cbq-page-tabs button, .cbq-footer button, .cbq-home-actions button, .cbq-compact-actions button, .cbq-file-button, .cbq-ai button { border: 1px solid #afc2d4; border-radius: 5px; padding: 8px 12px; color: #23445f; background: #fff; font-weight: 700; cursor: pointer; }
.cbq-page-tabs button.active, .cbq-home-actions .primary, .cbq-footer .primary { color: #fff; border-color: #1769aa; background: #1769aa; }
.cbq-page-tabs button:disabled, .cbq-footer button:disabled, .cbq-home-actions button:disabled { opacity: .45; cursor: not-allowed; }
.cbq-page { min-height: 0; overflow: hidden; }
.cbq-home { height: 100%; min-height: 720px; display: grid; grid-template-columns: 390px minmax(0, 1fr); gap: 10px; }
.cbq-header-form, .cbq-ledger, .cbq-pdf, .cbq-item-panel, .cbq-risk-list, .cbq-evidence { min-height: 0; box-sizing: border-box; border: 1px solid #cfdbea; border-radius: 8px; background: #fff; box-shadow: 0 4px 14px rgba(41, 72, 107, .06); }
.cbq-header-form { padding: 14px; overflow: auto; }
.cbq-workbench h3 { margin: 0 0 6px; color: #183b5b; font-size: 16px; }
.cbq-workbench p { margin: 0 0 10px; color: #6a7f92; font-size: 12px; line-height: 1.45; }
.cbq-header-form label, .cbq-ai label { display: grid; gap: 4px; margin-bottom: 8px; color: #526b83; font-size: 12px; font-weight: 650; }
.cbq-header-form input, .cbq-header-form select, .cbq-header-form textarea, .cbq-ai input, .cbq-ai select, .cbq-ai textarea { width: 100%; box-sizing: border-box; border: 1px solid #b9c9db; border-radius: 5px; padding: 7px 8px; font: inherit; color: #17324d; }
.cbq-header-form textarea, .cbq-ai textarea { min-height: 54px; resize: vertical; line-height: 1.5; }
.cbq-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.cbq-ai { margin: 0 0 10px; padding: 10px; border: 1px solid #bfdbfe; border-radius: 6px; background: #eff6ff; }
.cbq-ai strong { display: block; margin-bottom: 8px; color: #1d4ed8; }
.cbq-ai small { display: block; margin-top: 7px; color: #62768a; line-height: 1.45; }
.cbq-file-button { display: inline-flex !important; justify-content: center; margin-bottom: 9px; color: #1769aa !important; background: #edf6fd; }
.cbq-file-button input { display: none; }
.cbq-home-actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.cbq-home-actions .danger { color: #a52828; border-color: #f4a7ac; background: #fff1f2; }
.cbq-home-actions .success { color: #fff; border-color: #16a34a; background: #16a34a; }
.cbq-home-actions .success:not(:disabled):hover { background: #15803d; border-color: #15803d; }
.cbq-browse-scroll { max-height: 60vh; }
.cbq-overlay-footer .cbq-browse-actions { display: flex; gap: 8px; }
.cbq-note { margin-top: 10px; color: #687d90; font-size: 12px; line-height: 1.5; }
.cbq-ledger { display: grid; grid-template-rows: auto auto auto minmax(0, 1fr); padding: 14px; }
.cbq-table-scroll { min-height: 0; overflow: auto; border: 1px solid #d7e1eb; }
.cbq-workbench table { width: 100%; border-collapse: collapse; font-size: 12px; }
.cbq-ledger table { min-width: 1510px; }
.cbq-workbench th { position: sticky; top: 0; z-index: 2; padding: 8px 9px; text-align: left; white-space: nowrap; color: #38556f; background: #edf3f8; border-bottom: 1px solid #ccd9e6; }
.cbq-workbench td { padding: 8px 9px; border-bottom: 1px solid #e5ebf1; vertical-align: top; }
.cbq-workbench tbody tr { cursor: pointer; }
.cbq-workbench tbody tr:hover, .cbq-workbench tbody tr.selected { background: #eaf5ff; }
/* QS包3 中標來源色（同桌面 XAML RowStyle 一致）：藍=中標未綁主合同、紅=AI放置待人工確認 */
.cbq-ledger-legend { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.legend-chip { display: inline-flex; align-items: center; gap: 2px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; border: 1px solid; }
.legend-chip.is-award-unlinked { color: #1769aa; border-color: #1769aa; background: #eaf3fb; }
.legend-chip.is-ai-draft { color: #b03a2e; border-color: #c0392b; background: #fdecec; }
/* T-0831-19：公司下拉過濾（選擇公司 → BQ列表按 company_id 過濾） */
.cbq-company-filter { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; color: #17324d; }
.cbq-company-filter select { border: 1px solid #b9c9db; border-radius: 5px; padding: 5px 8px; font: inherit; color: #17324d; background: #fff; max-width: 220px; }
.cbq-deletion-badge { display: inline-block; font-size: 11px; padding: 1px 6px; border-radius: 999px; background: #b45309; color: #fff; margin-left: 4px; white-space: nowrap; }
.cbq-workbench tbody tr.is-award-unlinked td { background: #eaf3fb; color: #1769aa; }
.cbq-workbench tbody tr.is-award-unlinked td:first-child { border-left: 3px solid #1769aa; }
.cbq-workbench tbody tr.is-ai-draft td { background: #fdecec; color: #b03a2e; }
.cbq-workbench tbody tr.is-ai-draft td:first-child { border-left: 3px solid #c0392b; }
.cbq-workbench tbody tr.is-award-unlinked:hover td, .cbq-workbench tbody tr.is-award-unlinked.selected td, .cbq-workbench tbody tr.is-ai-draft:hover td, .cbq-workbench tbody tr.is-ai-draft.selected td { background: #eaf5ff; }
.cbq-empty { padding: 30px !important; text-align: center; color: #778a9d; }
.cbq-items, .cbq-risk { height: 100%; min-height: 720px; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; gap: 8px; }
.cbq-summary { display: grid; grid-template-columns: .8fr 1.5fr .9fr .9fr 1.1fr; gap: 8px; padding: 10px 12px; border: 1px solid #cfdbea; border-radius: 8px; background: #f7fafc; }
.cbq-summary div { display: grid; gap: 3px; }
.cbq-summary small { color: #6f8294; }
.cbq-summary strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cbq-pricing { min-height: 0; display: grid; grid-template-columns: minmax(420px, .9fr) minmax(560px, 1.1fr); gap: 10px; }
.cbq-pdf, .cbq-item-panel { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; padding: 12px; }
.cbq-panel-title { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.cbq-panel-title .cbq-file-button { margin: 0; white-space: nowrap; }
.cbq-pdf object { width: 100%; height: 100%; min-height: 590px; border: 1px solid #cbd5df; background: #e5e7eb; }
.cbq-pdf-empty { display: grid; min-height: 590px; place-items: center; padding: 30px; text-align: center; color: #667b8f; background: #e5e7eb; }
.cbq-pdf > small { margin-top: 6px; color: #6c8093; }
.cbq-compact-actions { display: flex; flex-wrap: wrap; gap: 5px; justify-content: flex-end; }
.cbq-item-table { min-width: 900px; }
.cbq-item-table input, .cbq-item-table textarea { width: 100%; min-width: 70px; box-sizing: border-box; border: 1px solid #c3d0dc; border-radius: 4px; padding: 6px; font: inherit; }
.cbq-item-table textarea { min-width: 260px; min-height: 54px; resize: vertical; }
.cbq-total { padding: 9px 0 0; text-align: right; font-weight: 750; color: #183b5b; }
.cbq-footer { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; padding: 9px; border: 1px solid #cfdbea; border-radius: 8px; background: #fff; }
.cbq-footer span { flex: 1 1 260px; color: #667c90; font-size: 12px; }
.cbq-risk-grid { min-height: 0; display: grid; grid-template-columns: minmax(430px, .85fr) minmax(560px, 1.15fr); gap: 10px; }
.cbq-risk > header { padding: 10px 12px; border: 1px solid #cfdbea; border-radius: 8px; background: #f7fafc; }
.cbq-risk-list, .cbq-evidence { display: grid; grid-template-rows: auto minmax(0, 1fr) minmax(180px, .45fr); padding: 12px; }
.cbq-risk-list textarea, .cbq-evidence textarea { width: 100%; height: 100%; min-height: 220px; box-sizing: border-box; margin-top: 8px; padding: 12px; border: 1px solid #c6d3df; border-radius: 5px; resize: none; line-height: 1.55; font-family: Consolas, "Microsoft YaHei UI", sans-serif; }
.cbq-evidence { grid-template-rows: auto minmax(0, 1fr) auto; }
.cbq-evidence textarea { min-height: 530px; margin: 0; }
.cbq-evidence-tabs { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 8px; color: #667b8f; font-size: 12px; }
.cbq-evidence details { max-height: 180px; overflow: auto; margin-top: 8px; border: 1px solid #d8e1eb; padding: 8px; }
.cbq-evidence pre { white-space: pre-wrap; font-size: 11px; }
.risk-high, .risk-medium, .risk-low { display: inline-block; min-width: 30px; padding: 3px 6px; border-radius: 4px; text-align: center; font-weight: 700; }
.risk-high { color: #991b1b; background: #fee2e2; }.risk-medium { color: #92400e; background: #fef3c7; }.risk-low { color: #166534; background: #dcfce7; }
.cbq-status, .cbq-error { padding: 9px 12px; border: 1px solid #c8d8e8; border-radius: 6px; background: #f4f8fb; font-size: 12px; }
.cbq-error { display: grid; gap: 3px; color: #9f2929; border-color: #f0b9b9; background: #fff4f4; }
@media (max-width: 1180px) { .cbq-workbench { height: auto; } .cbq-home, .cbq-pricing, .cbq-risk-grid { grid-template-columns: 1fr; } .cbq-ledger, .cbq-item-panel, .cbq-risk-list, .cbq-evidence { min-height: 620px; } }

/* ===== 桌面对齐扩展（模板管理 / 公司印 / PMB / 價格框）===== */
.cbq-desktop-parity-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 8px 0 4px; }
.cbq-desktop-parity-actions .secondary { border: 1px solid #fdba74; border-radius: 5px; padding: 7px 10px; color: #9a3412; background: #fff7ed; font-weight: 700; cursor: pointer; }
.cbq-desktop-parity-actions .secondary:disabled { opacity: .5; cursor: not-allowed; }
.cbq-parity-hint { color: #9a3412; font-size: 11px; }

.cbq-price-box-bar { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 8px 0; }
.cbq-price-box-bar small { color: #6c8093; font-size: 11px; }
.cbq-pricebox-table { min-width: 540px; }
.cbq-pricebox-table input[type="radio"] { cursor: pointer; }
.cbq-pricebox-empty { padding: 14px; text-align: center; color: #778a9d; font-size: 12px; }

.cbq-pmb-panel { display: grid; grid-template-rows: auto minmax(0, 1fr); padding: 12px; min-height: 0; box-sizing: border-box; border: 1px solid #cfdbea; border-radius: 8px; background: #fff; box-shadow: 0 4px 14px rgba(41, 72, 107, .06); }
.cbq-pmb-body { display: grid; gap: 8px; align-content: start; overflow: auto; }
.cbq-pmb-body label { display: grid; gap: 4px; color: #526b83; font-size: 12px; font-weight: 650; }
.cbq-pmb-body input, .cbq-pmb-body textarea { width: 100%; box-sizing: border-box; border: 1px solid #b9c9db; border-radius: 5px; padding: 7px 8px; font: inherit; color: #17324d; }
.cbq-pmb-body textarea { min-height: 120px; resize: vertical; line-height: 1.5; }
.cbq-pmb-body small { color: #9a3412; font-size: 11px; }

/* 三栏明细填价（PDF / 表格 / PMB）在窄屏退化为单列 */
@media (max-width: 1180px) { .cbq-pricing { grid-template-columns: 1fr; } .cbq-pmb-panel { min-height: 420px; } }

/* 模态覆盖层 */
.cbq-overlay { position: fixed; inset: 0; z-index: 1000; display: grid; place-items: center; background: rgba(15, 31, 50, .55); padding: 24px; }
.cbq-overlay-panel { width: min(1100px, 96vw); max-height: 90vh; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; background: #fff; border-radius: 10px; box-shadow: 0 24px 60px rgba(15, 31, 50, .3); overflow: hidden; }
.cbq-overlay-header { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid #dce6f0; background: #f4f8fb; }
.cbq-overlay-header h3 { margin: 0; color: #183b5b; font-size: 16px; }
.cbq-overlay-close { border: 1px solid #c3d0dc; border-radius: 5px; width: 30px; height: 30px; background: #fff; color: #526b83; cursor: pointer; font-size: 14px; }
.cbq-overlay-body { padding: 16px; overflow: auto; }
.cbq-overlay-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px; border-top: 1px solid #dce6f0; background: #f7fafc; }
.cbq-overlay-footer small { color: #9a3412; font-size: 11px; }
.cbq-overlay-footer button { border: 1px solid #afc2d4; border-radius: 5px; padding: 7px 14px; background: #fff; color: #23445f; font-weight: 700; cursor: pointer; }

/* 模板管理双栏 */
.cbq-tpl-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
.cbq-tpl-grid section { border: 1px solid #dce6f0; border-radius: 8px; padding: 12px; background: #fcfdfe; }
.cbq-tpl-grid h4 { margin: 0 0 8px; color: #183b5b; font-size: 14px; }
.cbq-tpl-actions { display: flex; flex-wrap: wrap; gap: 5px; margin: 0 0 10px; }
.cbq-tpl-actions button { border: 1px solid #afc2d4; border-radius: 5px; padding: 6px 10px; background: #fff; color: #23445f; font-weight: 700; cursor: pointer; font-size: 12px; }
.cbq-tpl-actions button.primary { color: #fff; border-color: #1769aa; background: #1769aa; }
.cbq-tpl-actions button.danger { color: #a52828; border-color: #f4a7ac; background: #fff1f2; }
.cbq-tpl-list { list-style: none; margin: 0 0 10px; padding: 0; max-height: 180px; overflow: auto; border: 1px solid #e0e8f0; border-radius: 6px; }
.cbq-tpl-list li { padding: 7px 10px; border-bottom: 1px solid #eef3f8; cursor: pointer; font-size: 12px; }
.cbq-tpl-list li:last-child { border-bottom: 0; }
.cbq-tpl-list li.selected { background: #eaf5ff; }
.cbq-tpl-list li.cbq-empty { cursor: default; color: #778a9d; text-align: center; }
.cbq-tpl-pmb-edit label, .cbq-tpl-engineering label { display: grid; gap: 4px; margin-bottom: 8px; color: #526b83; font-size: 12px; font-weight: 650; }
.cbq-tpl-pmb-edit input, .cbq-tpl-pmb-edit textarea, .cbq-tpl-engineering input, .cbq-tpl-engineering textarea { width: 100%; box-sizing: border-box; border: 1px solid #b9c9db; border-radius: 5px; padding: 7px 8px; font: inherit; color: #17324d; }
.cbq-tpl-pmb-edit textarea, .cbq-tpl-engineering textarea { min-height: 70px; resize: vertical; line-height: 1.5; }
.cbq-tpl-param-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 10px 0 6px; }
.cbq-tpl-param-bar strong { color: #183b5b; font-size: 13px; }
.cbq-param-table { min-width: 460px; }
.cbq-param-table input { width: 100%; box-sizing: border-box; border: 1px solid #c3d0dc; border-radius: 4px; padding: 5px; font: inherit; }

/* 公司印 / 報價單抬頭双栏 */
.cbq-chop-grid { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, .9fr); gap: 16px; }
.cbq-chop-grid section { border: 1px solid #dce6f0; border-radius: 8px; padding: 12px; background: #fcfdfe; }
.cbq-chop-grid h4 { margin: 0 0 6px; color: #183b5b; font-size: 14px; }
.cbq-chop-grid section > small { display: block; margin-bottom: 10px; color: #6a7f92; font-size: 11px; }
.cbq-chop-grid label { display: grid; gap: 4px; margin-bottom: 8px; color: #526b83; font-size: 12px; font-weight: 650; }
.cbq-chop-grid input, .cbq-chop-grid textarea { width: 100%; box-sizing: border-box; border: 1px solid #b9c9db; border-radius: 5px; padding: 7px 8px; font: inherit; color: #17324d; }
.cbq-chop-grid textarea { min-height: 60px; resize: vertical; line-height: 1.5; }
.cbq-chop-grid .cbq-check { display: flex; flex-direction: row; align-items: center; gap: 6px; font-weight: 600; }
.cbq-chop-grid .cbq-check input { width: auto; }
.cbq-chop-preview { margin: 0 0 10px; padding: 10px; border: 1px dashed #c3d0dc; border-radius: 6px; background: #f7fafc; min-height: 48px; display: grid; place-items: center; }
.cbq-chop-preview small { color: #6c8093; font-size: 11px; word-break: break-all; }
.cbq-chop-preview.cbq-empty { color: #778a9d; font-size: 12px; }

/* 從 PMB 模組選擇 */
.cbq-pmb-pick p { color: #6a7f92; font-size: 12px; margin: 0 0 10px; }

@media (max-width: 880px) { .cbq-tpl-grid, .cbq-chop-grid { grid-template-columns: 1fr; } }

/* ===== T-0908 BQ流水PDF：PDF欄圖標 + 上傳PDF掣（照mockup 2026-09-08）===== */
.pdf-chip { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; margin: 1px 2px; border-radius: 5px; font-size: 12px; font-weight: 700; cursor: pointer; border: 1px solid #c0392b; color: #c0392b; background: #fff; }
.pdf-chip:hover { background: #fdecec; }
.pdf-chip.none { border-color: #ccd6df; color: #9fb0bf; background: #f6f8fa; cursor: default; }
.btn-upload-pdf { border: 1px solid #1769aa; border-radius: 5px; padding: 8px 14px; color: #fff; background: #1769aa; font-weight: 700; cursor: pointer; font-size: 13px; }
.btn-upload-pdf.ghost { color: #1769aa; background: #edf6fd; }
header .btn-upload-pdf.ghost.cbq-file-button { margin: 0; white-space: nowrap; }
.cbq-upload-hint { margin-top: 10px; padding: 8px 10px; border: 1px solid #bfdbfe; border-radius: 6px; background: #eff6ff; color: #1d4ed8; font-size: 12px; line-height: 1.5; }
.cbq-upload-hint b { color: #17324d; }
/* T-0908收尾：版本tag（照mockup——最新實心藍tag、舊版灰tag）＋PDF欄cell排版＋底部統計列 */
.cbq-pdf-cell { display: inline-flex; align-items: center; gap: 5px; margin: 1px 2px; white-space: nowrap; }
.v-tag { display: inline-block; padding: 1px 7px; border-radius: 999px; font-size: 11px; font-weight: 700; background: #eaf3fb; color: #1769aa; border: 1px solid #b7d3ea; }
.v-tag.old { background: #f4f6f8; color: #7a8a98; border-color: #d7dfe6; }
.cbq-browse-stats { margin-top: 8px; padding: 7px 10px; border: 1px solid #d7e3ee; border-radius: 6px; background: #f7fafc; color: #38556f; font-size: 12px; font-weight: 700; }
