#appView .lab-upload{border-style:dashed}
#appView #labChoose{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:8px;width:100%;min-height:160px;padding:20px;background:transparent;border:0;color:var(--bronze-deep);white-space:normal}
.lab-plus{font-size:40px;font-weight:300;line-height:1}.lab-message{padding:14px}
#appView [data-lab-value]{width:110px;min-width:90px}

.lab-file-name{overflow-wrap:anywhere;min-width:0;flex:1 1 200px}.lab-latest{color:#24e879;font-size:18px;white-space:nowrap}.lab-file .panel-head{flex-wrap:wrap}.lab-file [hidden]{display:none!important}

.lab-file tr.abn-low td.num b{color:#fff}.lab-file tr.abn-high td.num b{color:#ff4040}

/* Consistent column alignment across all blood-test files. */
#appView .lab-file table th,
#appView .lab-file table td { text-align:center; vertical-align:middle; }
#appView .lab-file .lab-results { table-layout:fixed; min-width:1000px; width:100%; }
#appView .lab-results th { white-space:normal; }
#appView .lab-results th:nth-child(1) { width:20%; }
#appView .lab-results th:nth-child(2) { width:8%; }
#appView .lab-results th:nth-child(3) { width:8%; }
#appView .lab-results th:nth-child(4) { width:14%; }
#appView .lab-results th:nth-child(5) { width:19%; }
#appView .lab-results th:nth-child(6) { width:12%; }
#appView .lab-results th:nth-child(7) { width:8%; }
#appView .lab-results th:nth-child(8) { width:11%; }
#appView .lab-results td { overflow-wrap:anywhere; }
#appView .lab-results td[colspan] { text-align:left; }
#appView .lab-results .rr { display:grid; grid-template-columns:96px 48px; gap:6px; align-items:center; justify-content:center; }
#appView .lab-results .rr .delta { text-align:left; }
#appView .lab-results td .tag { white-space:normal; justify-content:center; }

/* Thẻ xét nghiệm / phiếu y tế: một dòng. Trái: tên · ngày · nhãn (liền nhau). Phải: nhãn cảnh báo + các nút sát nhau.
   Xuống dòng theo bề rộng của chính thẻ (cột danh sách hồ sơ chiếm chỗ), không theo màn hình. */
#appView .lab-file, #appView .ttyt-saved { container: labcard / inline-size; }
#appView :is(.lab-file-head, .ttyt-head) { display:flex; flex-wrap:nowrap; align-items:center; gap:12px; padding:12px 18px; min-height:58px; }
#appView .ttyt-head { cursor:pointer; }
#appView .ttyt-head:hover { background:var(--bronze-wash); }
#appView .ttyt-saved.is-open > .ttyt-head { border-bottom:1px solid var(--hair-soft); }
.lab-file-label { flex:1 1 auto; display:flex; align-items:center; gap:10px; min-width:0; }
.lab-file-label > svg { flex-shrink:0; color:var(--bronze); }
.lab-file-label .lab-file-name { flex:0 1 auto; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; font-weight:600; }
.lab-file-label .lab-latest { flex-shrink:0; font-size:16px; line-height:1; margin-left:-4px; }
.lab-file-date { flex-shrink:0; white-space:nowrap; font-variant-numeric:tabular-nums; font-weight:600; }
.lab-file-lab { flex:0 1 auto; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; font-size:12px; color:var(--muted); }
.lab-file-label .tag, .lab-file-badges .tag { flex-shrink:0; display:inline-flex; align-items:center; gap:4px; height:26px; padding:0 9px; white-space:nowrap; }
.lab-file-badges { flex-shrink:0; display:flex; align-items:center; gap:6px; }
.lab-file-badges:empty { display:none; }
.lab-file-actions { flex-shrink:0; display:flex; align-items:center; gap:8px; }
#appView .lab-file-actions button { min-width:96px; height:34px; min-height:34px; padding:0 14px; font-size:13px; white-space:nowrap; justify-content:center; }
/* Nút đang mở (Xem chi tiết / So sánh lần trước / Xem phiếu / Xem bảng tư vấn): nền vàng nâu để biết đang dùng mục nào */
#appView :is(.lab-file-actions, .care-file-head) button[aria-expanded="true"], #appView :is(.lab-file-actions, .care-file-head) button[aria-expanded="true"]:hover { background:#a9783a; border-color:#a9783a; color:#fff; box-shadow:0 2px 8px rgba(169,120,58,.28); }
@container labcard (max-width:1080px) {
  #appView .lab-file-head { flex-wrap:wrap; row-gap:10px; }
  .lab-file-head .lab-file-label { flex-basis:100%; flex-wrap:wrap; row-gap:6px; }
  .lab-file-head .lab-file-badges { margin-right:auto; }
  .lab-file-head .lab-file-actions { margin-left:auto; }
}
/* Phiếu y tế ngắn hơn: giữ một dòng tới khi thẻ còn 760px */
@container labcard (max-width:760px) {
  #appView .ttyt-head { flex-wrap:wrap; row-gap:10px; }
  .ttyt-head .lab-file-label { flex-basis:100%; flex-wrap:wrap; row-gap:6px; }
  .ttyt-head .lab-file-actions { margin-left:auto; }
}
@container labcard (max-width:480px) {
  #appView :is(.lab-file-head, .ttyt-head) { padding:12px 14px; }
  .lab-file-actions { flex-basis:100%; display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); }
  #appView .lab-file-actions button { min-width:0; }
}

/* Doc tu anh chup / PDF scan */
.lab-ocr-note { color:var(--bronze-deep); font-weight:600; }
.lab-ocr-pages { display:flex; flex-wrap:wrap; gap:8px; margin:8px 0 12px; }
.lab-ocr-pages a { display:flex; align-items:center; justify-content:center; width:72px; height:96px; border:1px solid var(--hair-soft, rgba(255,255,255,.16)); border-radius:6px; overflow:hidden; color:var(--bronze-deep); font-weight:700; text-decoration:none; }
.lab-ocr-pages img { width:100%; height:100%; object-fit:cover; }
#appView .lab-ocr-table { min-width:820px; width:100%; table-layout:fixed; }
#appView .lab-ocr-table th:nth-child(1) { width:32%; }
#appView .lab-ocr-table th:nth-child(2) { width:13%; }
#appView .lab-ocr-table th:nth-child(3) { width:12%; }
#appView .lab-ocr-table th:nth-child(4) { width:18%; }
#appView .lab-ocr-table th:nth-child(5) { width:17%; }
#appView .lab-ocr-table th:nth-child(6) { width:52px; }
#appView .lab-ocr-table input { width:100%; min-width:70px; }
#appView .lab-ocr-table td:last-child { text-align:center; }
#appView .lab-ocr-table tr.lab-ocr-uncertain td { background:color-mix(in srgb, var(--bronze) 16%, transparent); }
#appView .lab-ocr-table tr.lab-ocr-uncertain td:first-child { box-shadow:inset 3px 0 0 var(--bronze); }
#labOcrAdd { margin:8px 0 4px; }
/* So sánh lần trước: chỉ số khác đơn vị ghi kèm đơn vị cũ */
.lab-old-unit{color:var(--muted);font-style:italic}.lab-unit-diff td:last-child{color:#a2560b}
.lab-missing td{color:var(--muted)}

/* ===== MOBILE 11/2026 (≤ 760px) — docs/MOBILE-UI-SPEC.md =====
   So sánh lần trước + duyệt kết quả đọc từ file: bảng nhiều cột → mỗi chỉ số một dòng thẻ. */
@media screen and (max-width: 760px) {
  /* So sánh: tên · lần này + đơn vị / các lần trước · thay đổi.
     Cột: 2 lần = tên · lần trước · lần này · đơn vị · thay đổi; 3 lần (.lab-compare3) thêm cột lần trước nữa sau tên. */
  body.sales-shell #appView #medicalWorkspace .tbl-wrap:has(> .lab-compare) { overflow: visible; margin: 0 -14px; border: 0; border-radius: 0; }
  body.sales-shell #appView #medicalWorkspace .lab-compare { display: block; width: 100%; min-width: 0; table-layout: auto; }
  body.sales-shell #appView #medicalWorkspace .lab-compare thead { display: none; }
  body.sales-shell #appView #medicalWorkspace .lab-compare tbody { display: block; }
  body.sales-shell #appView #medicalWorkspace .lab-compare tr { display: grid; grid-template-columns: auto auto minmax(0, 1fr) auto auto; align-items: baseline; column-gap: 10px; row-gap: 4px; padding: 10px 14px; border-top: 1px solid var(--m-line-soft); }
  body.sales-shell #appView #medicalWorkspace .lab-compare td { display: block; min-width: 0; padding: 0; border: 0; background: none; text-align: left; font-size: 13px; }
  body.sales-shell #appView #medicalWorkspace .lab-compare td:nth-child(1) { grid-column: 1 / 4; grid-row: 1; font-size: 14px; font-weight: 600; }
  body.sales-shell #appView #medicalWorkspace .lab-compare td:nth-last-child(3) { grid-column: 4; grid-row: 1; justify-self: end; font-size: 16px; font-weight: 800; }
  body.sales-shell #appView #medicalWorkspace .lab-compare td:nth-last-child(2) { grid-column: 5; grid-row: 1; color: var(--m-sub); font-size: 12px; }
  body.sales-shell #appView #medicalWorkspace .lab-compare td:nth-last-child(1) { grid-column: 4 / 6; grid-row: 2; justify-self: end; font-size: 12.5px; font-weight: 700; text-align: right; }
  body.sales-shell #appView #medicalWorkspace .lab-compare td:nth-child(n+2):nth-last-child(n+4) { grid-row: 2; color: var(--m-sub); font-size: 12px; }
  body.sales-shell #appView #medicalWorkspace .lab-compare td:nth-last-child(4)::before { content: "Lần trước "; color: var(--m-faint); }
  body.sales-shell #appView #medicalWorkspace .lab-compare3 td:nth-last-child(5)::before { content: "Lần trước nữa "; color: var(--m-faint); }
  body.sales-shell #appView #medicalWorkspace .lab-compare td .lab-old-unit { display: block; font-size: 11.5px; }
  body.sales-shell #appView #medicalWorkspace .lab-compare tr.lab-unit-diff td:nth-last-child(1) { color: var(--m-warn); }

  /* Duyệt kết quả trước khi lưu */
  body.sales-shell #appView #medicalWorkspace .lab-upload:has(#labImportReview > .panel-body) { border-style: solid; border-color: var(--m-line); background: #fff; }
  body.sales-shell #appView #labImportReview .panel-body { padding: 12px 14px 14px; }
  body.sales-shell #appView #labImportReview .grid-2 { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  body.sales-shell #appView #labImportReview .tbl-wrap { overflow: visible; margin: 8px 0; border: 0; border-radius: 0; }
  body.sales-shell #appView #labImportReview table { display: block; width: 100%; min-width: 0; table-layout: auto; }
  body.sales-shell #appView #labImportReview thead { display: none; }
  body.sales-shell #appView #labImportReview tbody { display: grid; gap: 8px; }
  body.sales-shell #appView #labImportReview tr { display: grid; grid-template-columns: minmax(0, 1fr) 96px; gap: 8px; padding: 12px; border: 1px solid var(--m-line); border-radius: 14px; background: #fff; }
  body.sales-shell #appView #labImportReview td { display: block; min-width: 0; padding: 0; border: 0; background: none; text-align: left; font-size: 13px; }
  body.sales-shell #appView #labImportReview td input { width: 100%; min-width: 0; min-height: 44px; border-color: var(--m-line); border-radius: 10px; font-size: 16px; }
  /* Đọc từ ảnh: tên cả hàng · kết quả + đơn vị · tham chiếu · ghi chú; nút × góc phải */
  body.sales-shell #appView #labImportReview .lab-ocr-table tr { position: relative; padding-top: 10px; }
  body.sales-shell #appView #labImportReview .lab-ocr-table td[data-label]::before { content: attr(data-label); display: block; margin-bottom: 3px; color: var(--m-sub); font-size: 12px; font-weight: 600; }
  body.sales-shell #appView #labImportReview .lab-ocr-table td:has(> [data-ocr="name"]) { grid-column: 1 / -1; padding-right: 44px; }
  body.sales-shell #appView #labImportReview .lab-ocr-table td:has(> [data-ocr="reference"]), body.sales-shell #appView #labImportReview .lab-ocr-table td:has(> [data-ocr="flag"]) { grid-column: 1 / -1; }
  body.sales-shell #appView #labImportReview .lab-ocr-table td:last-child { position: absolute; top: 6px; right: 6px; }
  body.sales-shell #appView #labImportReview .lab-ocr-table [data-ocr-remove] { width: 40px; min-width: 40px; height: 40px; min-height: 40px; padding: 0; border: 0; border-radius: 12px; background: var(--m-wash); font-size: 20px; }
  body.sales-shell #appView #labImportReview .lab-ocr-table tr.lab-ocr-uncertain { border-color: #E3C79E; background: var(--m-accent-wash); box-shadow: inset 3px 0 0 var(--m-accent); }
  body.sales-shell #appView #labImportReview .lab-ocr-table tr.lab-ocr-uncertain td { background: none; box-shadow: none; }
  /* Đọc từ PDF: tên · ô kết quả, đơn vị trong ô bên phải; tham chiếu / ghi chú dòng dưới */
  body.sales-shell #appView #labImportReview .li-name { grid-column: 1 / -1; font-size: 14px; font-weight: 600; }
  body.sales-shell #appView #labImportReview .li-val { grid-column: 1; }
  body.sales-shell #appView #labImportReview .li-unit { grid-column: 2; align-self: center; color: var(--m-sub); }
  body.sales-shell #appView #labImportReview .li-ref { grid-column: 1 / -1; color: var(--m-sub); font-size: 12px; }
  body.sales-shell #appView #labImportReview .li-ref:not(:empty)::before { content: "Tham chiếu "; }
  body.sales-shell #appView #labImportReview .li-note { grid-column: 1 / -1; color: var(--m-sub); font-size: 12px; }
  body.sales-shell #appView #labImportReview :is(.li-ref, .li-note):empty { display: none; }
  body.sales-shell #appView #labImportReview #labOcrAdd { width: 100%; min-height: 44px; border-style: dashed; border-radius: 12px; }
  body.sales-shell #appView #labImportReview .check { align-items: flex-start; gap: 10px; margin: 12px 0 4px; padding: 12px; border-radius: 12px; background: var(--m-wash); font-size: 14px; }
  body.sales-shell #appView #labImportReview .check span { white-space: normal; }
  body.sales-shell #appView #labImportReview .lab-import-save { margin-top: 10px; }
  body.sales-shell #appView #labImportReview .lab-import-save button { flex: 1 1 auto; width: 100%; }
  body.sales-shell #appView #labImportReview .lab-ocr-pages a { width: 64px; height: 84px; border-radius: 10px; }
}

/* ===== MOBILE 11/2026 — Đợt 2: mật độ (dòng so sánh ~48px, nhập kết quả gọn) ===== */
@media screen and (max-width: 760px) {
  body.sales-shell #appView #medicalWorkspace .tbl-wrap:has(> .lab-compare) { margin: 0 -12px; }
  body.sales-shell #appView #medicalWorkspace .lab-compare tr { row-gap: 2px; column-gap: 8px; padding: 6px 12px; }
  body.sales-shell #appView #medicalWorkspace .lab-compare td:nth-child(1) { overflow: hidden; font-size: 14px; font-weight: 500; line-height: 1.35; white-space: nowrap; text-overflow: ellipsis; }
  body.sales-shell #appView #medicalWorkspace .lab-compare td:nth-last-child(3) { font-size: 14px; line-height: 1.35; }
  body.sales-shell #appView #medicalWorkspace .lab-compare td:nth-child(n+2):nth-last-child(n+4), body.sales-shell #appView #medicalWorkspace .lab-compare td:nth-last-child(1) { font-size: 12px; line-height: 16px; }
  body.sales-shell #appView #medicalWorkspace .lab-compare td:nth-last-child(1) { white-space: nowrap; }
  body.sales-shell #appView #medicalWorkspace .lab-compare td .lab-old-unit { display: inline; font-size: 11.5px; }
  body.sales-shell #appView #medicalWorkspace .lab-compare + p, body.sales-shell #appView #medicalWorkspace [id^="labCompare_"] > .panel-body > p:first-child { margin: 0 0 4px; font-size: 13px; }
  body.sales-shell #appView #labImportReview .panel-body { padding: 10px 12px 12px; }
  body.sales-shell #appView #labImportReview .panel-body > p { margin: 0 0 4px; font-size: 13px; }
  body.sales-shell #appView #labImportReview tbody { gap: 6px; }
  body.sales-shell #appView #labImportReview tr { gap: 6px 8px; padding: 10px 12px; }
  body.sales-shell #appView #labImportReview .lab-ocr-table td[data-label]::before { margin-bottom: 2px; font-size: 12px; }
}
