/* ============================================================================
   KC — Báo giá NCC · lịch sử giá linh kiện (web/bao-gia-ncc.js). Dùng biến màu của app.css, tiền tố bgn-.
   ========================================================================== */
/* danh sách: ô tra mã + chọn NCC */
.o-tim.bgn-tra { min-width: 240px; }
.bgn-chon-nho { height: 30px; border: 1px solid var(--vien-2); border-radius: var(--bo-nho); background: var(--mat); padding: 0 8px; font: inherit; font-size: 12.5px; color: var(--chu); }

/* nhập nhanh: vùng kéo thả */
.bgn-tha { border: 2px dashed #c6d3e6; border-radius: 12px; padding: 18px; display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; color: var(--chu-2); background: #f8fafc; outline: 0; }
.bgn-tha .ic.lon { width: 30px; height: 30px; color: var(--chinh); }
.bgn-tha .hang-nut { justify-content: center; flex-wrap: wrap; }
.bgn-tha.keo, #bgn-the-dong.keo { border-color: var(--chinh); background: var(--chinh-nhat); }
#bgn-the-dong.keo { box-shadow: 0 0 0 2px var(--chinh); }

/* bảng dòng báo giá */
.bgn-bang td { vertical-align: top; }
/* tên hàng không bắt buộc ở báo giá NCC: bỏ nền vàng "thiếu NAME" của app.css */
.bang.bgn-bang td input[data-k=ten]:placeholder-shown { background: var(--mat); border-color: var(--vien-2); }
.bang.mb-luoi td input.bgn-phu { margin-top: 3px; height: 22px; font-size: 12px; color: var(--chu-2); background: var(--mat-2); }
.bang.mb-luoi td input.bgn-ph:not(:placeholder-shown) { background: var(--tim-nhat); border-color: #d9c9f6; font-weight: 600; }
.bgn-ph-lech { font-size: 11.5px; margin-top: 2px; white-space: nowrap; }
.bgn-khop { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin-top: 3px; }
.bgn-khop:empty { display: none; }
.bgn-khop .nhan { font-size: 11px; padding: 1px 7px; }
.bgn-khop .nhan .ic { width: 12px; height: 12px; }
.bgn-goi-y { height: 22px; max-width: 220px; border: 1px solid #f0c36d; border-radius: 6px; background: var(--vang-nhat); font: inherit; font-size: 11.5px; padding: 0 4px; }
.bgn-khop-tom { margin: 8px 12px 0; padding: 7px 12px; border-radius: 10px; background: #f8fafc; border: 1px solid var(--vien); font-size: 12.5px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.bgn-khop-tom > .ic { color: var(--nhat); }
.bgn-khop-tom b.xanh { color: var(--xanh); } .bgn-khop-tom b.lam { color: var(--lam); } .bgn-khop-tom b.vang { color: var(--vang); }

/* cột tham chiếu: tối đa 3 dòng nhỏ (nhãn · giá · lệch) */
.bgn-tc-cot { min-width: 190px; }
.bgn-tc-dong { display: flex; align-items: baseline; gap: 6px; font-size: 12px; line-height: 1.5; white-space: nowrap; }
.bgn-tc-dong > span:first-child { color: var(--nhat); font-size: 11px; min-width: 76px; overflow: hidden; text-overflow: ellipsis; max-width: 120px; }
.bgn-tc-dong b { font-variant-numeric: tabular-nums; }
.bgn-tc-them { margin-top: 2px; border: 0; background: none; padding: 0; color: var(--chinh); font: inherit; font-size: 11.5px; cursor: pointer; }
.bgn-tc-them:hover { text-decoration: underline; }

/* khối đề xuất chi tiết đúng / gần giống */
details.bgn-dx { border: 1px solid var(--vien); border-radius: 10px; margin-bottom: 8px; background: var(--mat); }
details.bgn-dx > summary { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 7px 12px; cursor: pointer; list-style: none; }
details.bgn-dx > summary::-webkit-details-marker { display: none; }
details.bgn-dx > summary::before { content: ""; width: 7px; height: 7px; border-right: 2px solid var(--nhat); border-bottom: 2px solid var(--nhat); transform: rotate(-45deg); margin-right: 2px; transition: transform .15s; }
details.bgn-dx[open] > summary::before { transform: rotate(45deg); }
details.bgn-dx[open] > summary { border-bottom: 1px solid var(--vien); background: #f8fafc; border-radius: 10px 10px 0 0; }
.bgn-dx-tom { margin-left: auto; font-size: 12.5px; white-space: nowrap; }
.bgn-dx-noi:empty { display: none; }
.bgn-dx-noi { padding: 10px 12px; }
.bgn-dx-than { display: flex; flex-direction: column; gap: 12px; }
.bgn-tc { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 8px; }
.bgn-tc-o { border: 1px solid var(--vien); border-radius: 9px; padding: 6px 10px; display: flex; flex-direction: column; gap: 2px; background: var(--mat); min-width: 0; }
.bgn-tc-o > span { font-size: 11.5px; color: var(--nhat); font-weight: 500; }
.bgn-tc-o > b { font-size: 14.5px; font-variant-numeric: tabular-nums; }
.bgn-tc-o > small { font-size: 11.5px; color: var(--nhat); }
.bgn-tc-o > a { font-size: 11.5px; }
.bgn-tc-o > .nut { align-self: flex-start; margin-top: 3px; }
.bgn-tc-o.trong { background: var(--mat-2); }
.bgn-dx-nhom h4 { margin: 0 0 6px; font-size: 13px; display: flex; align-items: center; gap: 6px; color: var(--chu); }
.bgn-dx-nhom h4 .ic { color: var(--nhat); }
.bgn-dx-nhom h4 .dem { font-size: 11px; font-weight: 600; padding: 0 7px; border-radius: 999px; background: #eef2f7; color: var(--chu-2); }
.bgn-dx-nhom h4 .nut.trong { height: 22px; padding: 0 5px; }
.bgn-lt { margin-bottom: 4px; }
details.bgn-dx-ma { border: 1px solid #edf1f6; border-radius: 8px; padding: 5px 8px; margin-bottom: 5px; background: #fbfcfe; }
details.bgn-dx-ma > summary { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; cursor: pointer; font-size: 12.5px; }
details.bgn-dx-ma .bv-gia { overflow-x: auto; display: block; }
.bgn-dx-gon { font-size: 12px; color: var(--chu-2); }
.bgn-dx-nut { margin-left: auto; display: inline-flex; gap: 4px; flex-wrap: wrap; }
.bgn-dx-nut .nut { height: 24px; }
.bgn-dx-bv-ten { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
/* KC 0.9.1: vật liệu · bề mặt của mã gợi ý */
.nhan.bgn-dx-vl { font-size: 11px; padding: 0 7px; background: var(--lam-nhat); color: var(--lam); font-weight: 500; max-width: 260px; overflow: hidden; text-overflow: ellipsis; }
.bgn-dx-bv-ten .nhan.bgn-dx-vl { align-self: flex-start; }

/* màn linh kiện */
.bgn-h1-ma { font-size: 19px; }
.bgn-anh-luoi { display: flex; flex-wrap: wrap; gap: 10px; }
.bgn-anh-o { display: flex; gap: 10px; align-items: flex-start; text-align: left; border: 1px solid var(--vien); border-radius: 10px; padding: 8px; background: var(--mat); cursor: pointer; font: inherit; color: var(--chu); max-width: 340px; }
.bgn-anh-o:hover { border-color: var(--chinh); }
.bgn-anh-o .mo-ta { word-break: break-all; }

/* hộp dán bảng */
textarea.bgn-dan { width: 100%; font-family: "JetBrains Mono", Consolas, monospace; font-size: 12px; resize: vertical; }

@media (max-width: 860px) {
  .o-tim.bgn-tra { min-width: 0; width: 100%; }
  .bgn-dx-tom { margin-left: 0; white-space: normal; }
  .bgn-dx-nut { margin-left: 0; }
}

/* ======================= 0.9.8 MẪU NHẬP · TẢI NHIỀU BÁO GIÁ NCC (tiền tố bgn-mau- / bgn-tn-) ======================= */
/* thả tệp vào trang danh sách */
.bgn-ds-trang.keo { outline: 2px dashed var(--chinh); outline-offset: 6px; border-radius: 12px; }
/* hộp tải mẫu */
.bgn-mau-luoi { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.bgn-mau-o { display: flex; flex-direction: column; gap: 6px; padding: 12px; border: 1px solid var(--vien); border-radius: var(--bo); background: var(--mat-2); min-width: 0; }
.bgn-mau-o > .ic { color: var(--chinh); }
.bgn-mau-o > b { color: var(--chu); }
.bgn-mau-o > span { font-size: 12.5px; color: var(--nhat); flex: 1; }
.bgn-mau-o .nut { align-self: flex-start; }
.bgn-mau-o select { width: 100%; }
.bgn-mau-buoc { margin: 14px 0 0; padding-left: 20px; font-size: 12.5px; color: var(--chu-2); display: flex; flex-direction: column; gap: 4px; }
.bgn-mau-chon { display: flex; flex-direction: column; gap: 6px; }
.bgn-mau-chon .nut { justify-content: flex-start; height: auto; min-height: 30px; padding: 4px 10px; text-align: left; white-space: normal; }

/* hộp tải nhiều: cao cố định như hộp nhập Excel (.hop.rong), thân cuộn */
.hop.rong.bgn-tn-hop .hop-dau h2 { flex: 1; }
.bgn-tn-than { gap: 10px; }
.bgn-tn-tha { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border: 1.5px dashed var(--vien-2); border-radius: var(--bo); background: var(--mat-2); flex-wrap: wrap; }
.bgn-tn-tha > div:nth-child(2) { flex: 1 1 260px; min-width: 0; }
.bgn-tn-tha b { color: var(--chu); }
.bgn-tn-tha .nx-bieu { margin: 0; }
.bgn-tn-tha.gon { padding: 8px 12px; }
.bgn-tn-tha.gon .nx-bieu { width: 34px; height: 34px; }
.nx-keo .bgn-tn-tha { border-color: var(--chinh); background: var(--chinh-nhat); }
.bgn-tn-ds { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.bgn-tn-ds-luu { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 6px; }
.bgn-tn-ds-luu a { font-weight: 600; }
.bgn-tn-tep { border: 1px solid var(--vien); border-radius: var(--bo); background: var(--mat); padding: 8px 10px; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.bgn-tn-tep > .canh-bao { margin: 0; }
.bgn-tn-tdau { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; }
.bgn-tn-tdau > .ic { color: var(--chinh); }
.bgn-tn-tdau > b { min-width: 0; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bgn-tn-tdau > .nut:first-of-type { margin-left: auto; }
.bgn-tn-tdau .xoay { width: 13px; height: 13px; display: inline-block; vertical-align: -2px; }
.bgn-tn-trang { display: flex; flex-wrap: wrap; gap: 4px; }
.bgn-tn-trang .nhan { font-weight: 500; white-space: normal; }
/* một phiếu nháp */
.bgn-tn-phieu { border: 1px solid var(--vien); border-radius: 10px; padding: 8px 10px; display: flex; flex-direction: column; gap: 8px; background: var(--mat-2); min-width: 0; }
.bgn-tn-phieu.chon { border-color: #b9cdf5; background: #f7faff; }
.bgn-tn-phieu.co-loi { border-color: #f5c2bf; }
.bgn-tn-phieu.co-trung:not(.chon) { border-color: #dccff5; }
.bgn-tn-phieu.da-luu { border-color: #b7e2c4; background: var(--xanh-nhat); }
.bgn-tn-phieu.da-luu > .bgn-tn-pdau > .ic { color: var(--xanh); }
.bgn-tn-phieu.nhay { animation: bgn-nhay 1.2s ease 2; }
@keyframes bgn-nhay { 50% { box-shadow: 0 0 0 3px rgba(198, 40, 40, .35); } }
.bgn-tn-pdau { display: flex; align-items: flex-start; gap: 8px; min-width: 0; }
.bgn-tn-hop-chon { padding-top: 2px; }
.bgn-tn-hop-chon input { width: 16px; height: 16px; margin: 0; accent-color: var(--chinh); cursor: pointer; }
.bgn-tn-hop-chon input:disabled { cursor: not-allowed; }
.bgn-tn-pten { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.bgn-tn-pten > b { color: var(--chu); word-break: break-word; }
.bgn-tn-pten .mo-ta .nhan { font-size: 11px; padding: 0 7px; }
.bgn-tn-nhan { display: flex; flex-wrap: wrap; gap: 4px; }
.bgn-tn-nhan .nhan { font-size: 11px; padding: 0 7px; }
.bgn-tn-nhan:empty { display: none; }
.bgn-tn-pnut { display: flex; gap: 4px; flex: none; }
/* sửa nhanh: lưới ô nhỏ */
.bgn-tn-sua { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px 10px; }
.bgn-tn-o { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.bgn-tn-o > span { font-size: 11.5px; font-weight: 500; color: var(--nhat); }
.bgn-tn-o input, .bgn-tn-o select { width: 100%; min-width: 0; height: 28px; padding: 2px 7px; border: 1px solid var(--vien-2); border-radius: var(--bo-nho); background: var(--mat); font: inherit; font-size: 12.5px; color: var(--chu); }
.bgn-tn-o input.so { text-align: right; }
.bgn-tn-o input:focus, .bgn-tn-o select:focus { outline: none; border-color: var(--chinh); box-shadow: 0 0 0 3px rgba(37,99,235,.15); }
.bgn-tn-o > small { font-size: 11px; color: var(--mo); line-height: 1.3; }
.bgn-tn-o:first-child { grid-column: span 2; }
.bgn-tn-ncc { display: flex; gap: 4px; min-width: 0; }
.bgn-tn-ncc select { flex: 1; }
.bgn-tn-ncc .nut { flex: none; height: 28px; width: 28px; }
.bgn-tn-bao { display: flex; flex-direction: column; gap: 6px; }
.bgn-tn-bao:empty { display: none; }
.bgn-tn-bao .canh-bao { margin: 0; padding: 6px 10px; font-size: 12.5px; }
.bgn-tn-goi { font-size: 12.5px; color: var(--chu-2); display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; }
.bgn-tn-trung { border-color: #dccff5; background: var(--tim-nhat); color: #4c1d95; }
.bgn-tn-van, .bgn-tn-rong { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; cursor: pointer; }
.bgn-tn-van { margin-left: 4px; }
.bgn-tn-rong { font-size: 12.5px; color: var(--chu); padding: 4px 0; }
.bgn-tn-van input, .bgn-tn-rong input { width: 15px; height: 15px; margin: 0; }
/* dòng của phiếu */
.bgn-tn-cuon { border: 1px solid var(--vien); border-radius: var(--bo-nho); background: var(--mat); max-height: 420px; }
.bgn-tn-bang th, .bgn-tn-bang td { padding: 4px 8px; font-size: 12.5px; vertical-align: top; }
.bgn-tn-bang td.nx-r { color: var(--nhat); white-space: nowrap; font-variant-numeric: tabular-nums; }
.bgn-tn-bang tr.bgn-tn-loi td { background: var(--do-nhat); color: #8f1d1d; }
.bgn-tn-bang tr.bgn-tn-loi .nhan { font-size: 11px; padding: 0 7px; }
.bgn-tn-soat { min-width: 160px; }
.bgn-tn-cb { display: flex; gap: 4px; align-items: flex-start; font-size: 11.5px; color: var(--vang); line-height: 1.35; }
.bgn-tn-cb .ic { width: 12px; height: 12px; margin-top: 2px; }

@media (max-width: 560px) {
  .bgn-tn-tha { padding: 10px; }
  .bgn-tn-tha > div:nth-child(2) .nho { display: none; }
  .bgn-tn-sua { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bgn-tn-o:first-child { grid-column: span 2; }
  .bgn-tn-pdau { flex-wrap: wrap; }
  .bgn-tn-pnut { width: 100%; justify-content: flex-end; }
  .bgn-tn-tdau > b { flex: 1 1 60%; }
}
