/* ==========================================================================
   EVER Sales — trang Hồ sơ sức khỏe (thiết kế lại 11/10/2026).
   Chỉ trang Sales tải file này, nạp sau shell.css. Mọi selector nằm trong
   #appView #medicalWorkspace để không ảnh hưởng trang khác.
   ========================================================================== */
@media screen {
  #appView #medicalWorkspace {
    --m-line: #e4dccf; --m-soft: #f6f2ea; --m-warm: #fbf8f3; --m-ink: #0a0a0a; --m-sub: #5b524a;
    --m-bronze: #a9783a; --m-bronze-deep: #8a5f2a; --m-shadow: 0 1px 2px rgba(20,16,10,.05), 0 6px 18px rgba(80,60,30,.06);
    grid-template-columns: minmax(300px, 340px) minmax(0, 1fr);
    align-items: start;
  }
  /* Thẻ xét nghiệm / phiếu y tế / bảng CSYT giữ nguyên CSS production (lab-import.css, shell.css). */
  #appView #medicalWorkspace .panel:not(.lab-file):not(.care-file):not(.ttyt-saved):not(.intake-add):not(.lab-upload) { border: 1px solid var(--m-line); border-radius: 16px; background: #fff; box-shadow: var(--m-shadow); }

  /* ---------- Cột trái: danh sách hồ sơ ---------- */
  #appView #medicalWorkspace > aside { display: flex; flex-direction: column; max-height: calc(100svh - 96px); padding: 0; }
  #appView #medicalWorkspace > aside > .panel-head { display: flex; flex-wrap: nowrap; align-items: center; gap: 8px; padding: 14px 14px 12px; }
  #appView #medicalWorkspace > aside.panel > .panel-head { padding: 14px 12px 12px; }
  #appView #medicalWorkspace > aside > .panel-head > .spacer { display: none; }
  #appView #medicalWorkspace > aside > .panel-head > #newFromCrmBtn { margin-left: auto; }
  #appView #medicalWorkspace > aside > .panel-head::before { display: none; }
  #appView #medicalWorkspace > aside .panel-head { border-bottom: 1px solid var(--m-line); background: linear-gradient(105deg, var(--m-warm), #fff); border-radius: 16px 16px 0 0; }
  #appView #medicalWorkspace > aside > .panel-head > span:first-of-type { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14.5px; font-weight: 800; color: var(--m-ink); }
  #appView #medicalWorkspace #listCount { flex: none; min-width: 26px; padding: 2px 8px; border-radius: 99px; background: #f0ebe2; color: var(--m-sub); font-weight: 800; text-align: center; }
  #appView #medicalWorkspace #newFromCrmBtn { flex: none; display: inline-flex; align-items: center; gap: 4px; min-height: 32px; white-space: nowrap; padding: 5px 10px; font-size: 12.5px; border: 1px solid var(--m-bronze); border-radius: 10px; color: var(--m-bronze-deep); font-weight: 700; background: #fff; }
  #appView #medicalWorkspace #newFromCrmBtn:hover { background: #f6efe5; }
  #appView #medicalWorkspace .rail-filters { padding: 12px 14px; gap: 8px; border-bottom: 1px solid #f0ebe2; }
  #appView #medicalWorkspace .rail-filters input, #appView #medicalWorkspace .rail-filters select { min-height: 40px; border-radius: 10px; }
  #appView #medicalWorkspace .plist { flex: 1; max-height: none; min-height: 120px; overflow: auto; padding: 8px; }
  #appView #medicalWorkspace .pitem { display: grid; grid-template-columns: 38px minmax(0, 1fr); align-items: center; gap: 10px; width: 100%; padding: 10px; margin: 0 0 4px; border: 1px solid transparent; border-radius: 12px; text-align: left; }
  #appView #medicalWorkspace .pitem:hover { background: #faf6ef; }
  #appView #medicalWorkspace .pitem[aria-selected="true"] { background: #f6efe5; border-color: #e3cfb4; box-shadow: inset 3px 0 var(--m-bronze); }
  #appView #medicalWorkspace .pbody { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
  #appView #medicalWorkspace .pitem .row1 { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
  #appView #medicalWorkspace .pitem .nm { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; font-weight: 700; color: var(--m-ink); }
  #appView #medicalWorkspace .pitem .row2 { display: flex; gap: 10px; margin: 0; color: var(--m-sub); font-size: 12px; }
  #appView #medicalWorkspace .pitem .tag { flex: none; font-size: 11px; }
  /* Ảnh đại diện chữ cái, màu theo trạng thái chăm sóc */
  #appView #medicalWorkspace .pav, #appView #medicalWorkspace .pb-avatar { display: inline-grid; place-items: center; border-radius: 50%; font-weight: 800; letter-spacing: .02em; color: #fff; background: linear-gradient(135deg, #c4955a, #8a5f2a); }
  #appView #medicalWorkspace .pav { width: 38px; height: 38px; font-size: 13px; }
  #appView #medicalWorkspace .pav.st-moi { background: linear-gradient(135deg, #a1a1aa, #71717a); }
  #appView #medicalWorkspace .pav.st-cho_xet_nghiem, #appView #medicalWorkspace .pav.st-theo_doi { background: linear-gradient(135deg, #5b8def, #1a4fc4); }
  #appView #medicalWorkspace .pav.st-cho_tu_van { background: linear-gradient(135deg, #e7a84a, #a2560b); }
  #appView #medicalWorkspace .pav.st-ket_thuc { background: linear-gradient(135deg, #4cb57a, #15713f); }

  /* Nút thu gọn / mở danh sách */
  #appView #medicalWorkspace .med-toggle { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; min-height: 0; padding: 0; border: 1px solid var(--m-line); border-radius: 9px; background: #fff; color: var(--m-bronze-deep); line-height: 0; }
  #appView #medicalWorkspace .med-toggle svg { display: block; }
  #appView #medicalWorkspace .med-toggle:hover { border-color: var(--m-bronze); background: #f6efe5; }
  #appView #medicalWorkspace .med-toggle[hidden] { display: none; }

  /* ---------- Cột phải: trống ---------- */
  #appView #medicalWorkspace #detailEmpty { border-style: dashed; box-shadow: none; background: var(--m-warm); }

  /* ---------- Thanh thông tin khách ---------- */
  #appView #medicalWorkspace .patient-banner { border: 1px solid var(--m-line); border-radius: 16px; background: linear-gradient(105deg, var(--m-warm) 0%, #fff 70%); box-shadow: var(--m-shadow); overflow: hidden; }
  #appView #medicalWorkspace .pb-main { display: flex; align-items: center; gap: 14px; padding: 16px 18px 12px; }
  #appView #medicalWorkspace .pb-avatar { flex: none; width: 54px; height: 54px; font-size: 19px; box-shadow: 0 0 0 3px #fff, 0 0 0 4px #e4d3b8; }
  #appView #medicalWorkspace .pb-id { flex: 1; min-width: 0; }
  #appView #medicalWorkspace .pb-name { font-size: 22px; font-weight: 800; color: var(--m-ink); letter-spacing: -.01em; }
  #appView #medicalWorkspace .pb-facts { display: flex; flex-wrap: wrap; gap: 4px 0; margin-top: 4px; color: var(--m-sub); font-size: 13px; }
  #appView #medicalWorkspace .pb-facts > span { padding: 0 10px; border: 0; border-left: 1px solid #ddd2c2; }
  #appView #medicalWorkspace .pb-facts > span:first-child { padding-left: 0; border-left: 0; }
  #appView #medicalWorkspace .pb-facts .mrn { font-family: 'IBM Plex Mono', monospace; font-weight: 600; color: var(--m-bronze-deep); }
  #appView #medicalWorkspace .pb-actions #printBtn { padding: 8px 14px; border-radius: 10px; font-weight: 700; }
  /* Hành trình chăm sóc */
  #appView #medicalWorkspace .pb-journey { padding: 4px 18px 14px; overflow-x: auto; scrollbar-width: none; }
  #appView #medicalWorkspace .journey { display: flex; margin: 0; padding: 0; list-style: none; min-width: 560px; }
  #appView #medicalWorkspace .journey li { position: relative; flex: 1; }
  #appView #medicalWorkspace .journey li + li::before { content: ""; position: absolute; top: 14px; right: 50%; width: 100%; height: 3px; background: #ebe4d8; z-index: 0; }
  #appView #medicalWorkspace .journey li.is-done + li::before, #appView #medicalWorkspace .journey li.is-done + li.is-now::before { background: var(--m-bronze); }
  #appView #medicalWorkspace .journey button { position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center; gap: 5px; width: 100%; min-height: auto; padding: 0; border: 0; background: transparent; box-shadow: none; color: var(--m-sub); font-weight: 600; cursor: pointer; }
  #appView #medicalWorkspace .journey button:disabled { cursor: default; opacity: 1; }
  #appView #medicalWorkspace .jdot { display: inline-grid; place-items: center; width: 30px; height: 30px; border: 2px solid #ddd2c2; border-radius: 50%; background: #fff; font-size: 12px; font-weight: 800; color: #8a8078; transition: transform .15s; }
  #appView #medicalWorkspace .journey button:not(:disabled):hover .jdot { transform: scale(1.08); border-color: var(--m-bronze); color: var(--m-bronze-deep); }
  #appView #medicalWorkspace .jlabel { font-size: 12px; white-space: nowrap; }
  #appView #medicalWorkspace .journey li.is-done .jdot { border-color: var(--m-bronze); background: var(--m-bronze); color: #fff; }
  #appView #medicalWorkspace .journey li.is-now .jdot { border-color: var(--m-bronze); background: #fff; color: var(--m-bronze-deep); box-shadow: 0 0 0 4px #f3e6d2; }
  #appView #medicalWorkspace .journey li.is-now .jlabel { color: var(--m-bronze-deep); font-weight: 800; }
  /* Cảnh báo dị ứng / nguy kịch */
  #appView #medicalWorkspace .pb-alerts:empty { display: none; }
  #appView #medicalWorkspace .pb-alerts { display: grid; gap: 6px; padding: 0 18px 14px; }
  #appView #medicalWorkspace .alert-strip { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border: 1px solid #f5c2bd; border-radius: 10px; background: #fdf0ee; color: #7a1a14; font-size: 13px; }
  #appView #medicalWorkspace .alert-strip .k { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 99px; background: #b3261e; color: #fff; font-size: 11px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; }
  #appView #medicalWorkspace .alert-strip .k::before { content: "⚠"; font-size: 12px; }
  #appView #medicalWorkspace .alert-strip .v { font-weight: 600; }

  /* ---------- Tab: gạch chân ---------- */
  #appView #medicalWorkspace .tabs { display: flex; gap: 2px; margin-top: 14px; padding: 0; border: 0; border-radius: 0; background: transparent; box-shadow: inset 0 -1px var(--m-line); overflow-x: auto; scrollbar-width: none; }
  #appView #medicalWorkspace .tabs + div { height: 16px !important; }
  #appView #medicalWorkspace .tab { flex: none; display: inline-flex; align-items: center; gap: 7px; min-height: 44px; padding: 0 14px; border: 0; border-bottom: 3px solid transparent; border-radius: 0; background: transparent; box-shadow: none; color: var(--m-sub); font-weight: 700; }
  #appView #medicalWorkspace .tab:hover { color: var(--m-ink); background: transparent; }
  #appView #medicalWorkspace .tab[aria-selected="true"] { color: var(--m-bronze-deep); border-bottom-color: var(--m-bronze); background: transparent; box-shadow: none; }
  #appView #medicalWorkspace .tab .count { min-width: 20px; padding: 1px 6px; border-radius: 99px; background: #f0ebe2; color: var(--m-sub); font-size: 11px; font-weight: 800; text-align: center; }
  #appView #medicalWorkspace .tab[aria-selected="true"] .count { background: var(--m-bronze); color: #fff; }

  /* ---------- Tổng quan ---------- */
  #appView #medicalWorkspace .ov-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
  #appView #medicalWorkspace .ov-stat { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 12px; min-height: auto; padding: 14px 16px; border: 1px solid var(--m-line); border-radius: 14px; background: #fff; box-shadow: var(--m-shadow); color: inherit; font-weight: 400; text-align: left; cursor: pointer; transition: border-color .15s, transform .15s; }
  #appView #medicalWorkspace .ov-stat:hover { border-color: #d9c6a5; transform: translateY(-1px); }
  #appView #medicalWorkspace .ov-ic { display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 11px; background: #f6efe5; color: var(--m-bronze-deep); }
  #appView #medicalWorkspace .ov-txt { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
  #appView #medicalWorkspace .ov-txt span { font-size: 13px; font-weight: 700; color: var(--m-ink); }
  #appView #medicalWorkspace .ov-txt small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--m-sub); font-size: 12px; }
  #appView #medicalWorkspace .ov-txt em { font-style: normal; font-weight: 700; color: #a2560b; }
  #appView #medicalWorkspace .ov-stat b { font-size: 28px; font-weight: 800; line-height: 1; color: var(--m-ink); font-variant-numeric: tabular-nums; }
  #appView #medicalWorkspace .ov-stat.is-warn { border-color: #f0cfa6; background: linear-gradient(135deg, #fff 50%, #fff6ea); }
  #appView #medicalWorkspace .ov-stat.is-warn .ov-ic { background: #fff0d9; color: #a2560b; }
  #appView #medicalWorkspace .panel:not(.lab-file):not(.care-file):not(.ttyt-saved) > .panel-body { padding: 16px 18px; }
  #appView #medicalWorkspace .panel:not(.lab-file):not(.care-file):not(.ttyt-saved) > .panel-head { padding: 12px 18px; border-bottom: 1px solid #f0ebe2; font-weight: 700; }
  #appView #medicalWorkspace .section-title { display: flex; align-items: center; gap: 8px; margin: 0 0 12px; font-size: 12px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--m-bronze-deep); }
  #appView #medicalWorkspace .section-title::before { content: ""; width: 4px; height: 14px; border-radius: 2px; background: var(--m-bronze); }
  #appView #medicalWorkspace .kv { grid-template-columns: minmax(120px, 38%) 1fr; gap: 0; }
  #appView #medicalWorkspace .kv dt, #appView #medicalWorkspace .kv dd { padding: 8px 0; border-bottom: 1px dashed #efe7da; }
  #appView #medicalWorkspace .kv dt:last-of-type, #appView #medicalWorkspace .kv dd:last-of-type { border-bottom: 0; }
  #appView #medicalWorkspace .kv dt { margin-top: 0; color: var(--m-sub); font-weight: 600; }
  #appView #medicalWorkspace .kv { grid-template-columns: minmax(110px, 38%) 1fr !important; }
  #appView #medicalWorkspace .kv dd { font-weight: 600; }
  #appView #medicalWorkspace .clinical-summary { gap: 0; }
  #appView #medicalWorkspace .clinical-summary > div { padding: 11px 0; border: 0; border-bottom: 1px dashed #efe7da; border-radius: 0; background: transparent; }
  #appView #medicalWorkspace .clinical-summary > div:last-child { border-bottom: 0; }
  #appView #medicalWorkspace .clinical-summary dt { color: var(--m-sub); }
  #appView #medicalWorkspace .clinical-summary dd { border-left: 0; padding-left: 0; }
  #appView #medicalWorkspace .panel .empty { padding: 26px 16px; }

  /* ---------- Thẻ thêm mới (phiếu y tế, xét nghiệm, bảng CSYT, tư vấn) ---------- */
  #appView #medicalWorkspace :is(.intake-add, .lab-upload) { border: 1.5px dashed #d9c6a5; background: var(--m-warm); box-shadow: none; }
  #appView #medicalWorkspace :is(.intake-add, .lab-upload) > button { display: flex; align-items: center; justify-content: center; gap: 12px; width: 100%; min-height: 64px; padding: 14px 18px; border: 0; border-radius: 16px; background: transparent; box-shadow: none; color: var(--m-bronze-deep); font-size: 14px; font-weight: 700; }
  #appView #medicalWorkspace :is(.intake-add, .lab-upload) > button:hover { background: #f6efe5; }
  /* Dấu + vẽ bằng CSS để luôn nằm chính giữa hình tròn (ký tự "+" lệch theo font) */
  #appView #medicalWorkspace :is(.intake-add, .lab-upload) .lab-plus { --pl: 14px; --pw: 2.5px; flex: none; display: inline-block; width: 34px; height: 34px; border-radius: 50%; font-size: 0 !important; color: transparent; background: linear-gradient(#fff, #fff) center / var(--pl) var(--pw) no-repeat, linear-gradient(#fff, #fff) center / var(--pw) var(--pl) no-repeat, var(--m-bronze); }
  /* Tab chưa có dữ liệu: thẻ thêm mới là nội dung chính → to, căn giữa */
  #appView #medicalWorkspace .stack > :is(.intake-add, .lab-upload):first-child > button { flex-direction: column; gap: 14px; min-height: 220px; font-size: 15px; }
  #appView #medicalWorkspace .stack > :is(.intake-add, .lab-upload):first-child .lab-plus { --pl: 24px; --pw: 3px; width: 60px; height: 60px; box-shadow: 0 0 0 8px #f3e6d2; }

  /* Ô tìm kiếm: biểu tượng kính lúp căn giữa theo chiều dọc */
  #appView #medicalWorkspace .search { position: relative; display: flex; align-items: center; }
  #appView #medicalWorkspace .search svg { top: 50%; transform: translateY(-50%); }

  /* Xét nghiệm: nhãn "x bất thường" cùng hàng với tên phiếu khi thẻ còn đủ rộng (CSS production cho xuống dòng từ 1080px) */
  @container labcard (min-width: 700px) and (max-width: 1080px) {
    #appView #medicalWorkspace .lab-file-head { flex-wrap: nowrap; }
    #appView #medicalWorkspace .lab-file-head .lab-file-label { flex: 1 1 auto; flex-basis: auto; flex-wrap: nowrap; }
    #appView #medicalWorkspace .lab-file-head .lab-file-badges { margin-right: 0; }
  }

  /* Cảnh báo cạnh tên khách: dị ứng, bệnh mạn tính, chỉ số nguy kịch */
  #appView #medicalWorkspace .pb-name { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px; }
  #appView #medicalWorkspace .pb-flag { display: inline-flex; align-items: center; gap: 5px; max-width: 100%; padding: 3px 10px; border: 1px solid; border-radius: 999px; font-size: 12.5px; font-weight: 700; letter-spacing: 0; line-height: 1.35; }
  #appView #medicalWorkspace .pb-flag b { font-weight: 800; }
  #appView #medicalWorkspace .pb-flag em { margin-left: 2px; padding: 0 6px; border-radius: 99px; background: #b3261e; color: #fff; font-size: 11px; font-style: normal; font-weight: 800; }
  #appView #medicalWorkspace .pb-flag.is-allergy, #appView #medicalWorkspace .pb-flag.is-crit { border-color: #f5c2bd; background: #fdecea; color: #b3261e; }
  #appView #medicalWorkspace .pb-flag.is-chronic { border-color: #f0cfa6; background: #fff4e0; color: #a2560b; }
  /* Nút "N cảnh báo nguy hiểm gắn cờ đỏ" — bấm mở hộp thoại xem trước. */
  #appView #medicalWorkspace .pb-flag-btn { min-height: 0; cursor: pointer; font-family: inherit; box-shadow: none; transition: background .15s, box-shadow .15s; }
  #appView #medicalWorkspace .pb-flag-btn:hover { background: #fbdcd8; box-shadow: 0 2px 8px rgba(179, 38, 30, .18); }
  #appView #medicalWorkspace .pb-flag-btn:focus-visible { outline: 2px solid #b3261e; outline-offset: 2px; }

  /* ---------- Xem phiếu thông tin y tế: gọn, đủ thông tin (chỉ màn hình; bản in giữ nguyên) ---------- */
  #appView #medicalWorkspace .ttyt-saved .ttyt-summary { --q-line: #efe7da; line-height: 1.45; }
  #appView #medicalWorkspace .ttyt-saved .panel-body { padding: 14px 18px 16px; }
  #appView #medicalWorkspace .ttyt-saved .ttyt-read-section { margin-top: 14px; }
  #appView #medicalWorkspace .ttyt-saved .ttyt-read-section:first-child { margin-top: 0; }
  #appView #medicalWorkspace .ttyt-saved .ttyt-read-section > h3 { display: flex; align-items: center; gap: 8px; margin: 0 0 8px; font-size: 12px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--m-bronze-deep); }
  #appView #medicalWorkspace .ttyt-saved .ttyt-read-section > h3::before { content: ""; width: 4px; height: 13px; border-radius: 2px; background: var(--m-bronze); }
  #appView #medicalWorkspace .ttyt-saved .ttyt-card-grid { gap: 8px; }
  #appView #medicalWorkspace .ttyt-saved .ttyt-card { padding: 8px 12px; border: 1px solid var(--m-line); border-radius: 10px; background: #fff; }
  #appView #medicalWorkspace .ttyt-saved .ttyt-card h4 { margin: 2px 0 4px; font-size: 13px; font-weight: 800; color: var(--m-ink); }
  /* Thông tin chung: 3 thẻ cạnh nhau, mỗi câu một hàng "nhãn | giá trị" */
  #appView #medicalWorkspace .ttyt-saved .ttyt-general { grid-template-columns: 1.15fr 1fr .9fr; }
  #appView #medicalWorkspace .ttyt-saved .ttyt-general > .ttyt-card:first-child { grid-column: auto; }
  #appView #medicalWorkspace .ttyt-saved .ttyt-answer-grid { grid-template-columns: minmax(0, 1fr); gap: 0; }
  #appView #medicalWorkspace .ttyt-saved .ttyt-answer { display: grid; grid-template-columns: minmax(96px, 42%) minmax(0, 1fr); align-items: baseline; gap: 10px; padding: 5px 0; border-bottom: 1px dashed var(--q-line); }
  #appView #medicalWorkspace .ttyt-saved .ttyt-answer:last-child { border-bottom: 0; }
  #appView #medicalWorkspace .ttyt-saved .ttyt-summary dt { margin: 0; font-size: 12.5px; font-weight: 500; line-height: 1.4; color: var(--m-sub); }
  #appView #medicalWorkspace .ttyt-saved .ttyt-summary dd { margin: 0; font-size: 13px; font-weight: 700; line-height: 1.4; color: var(--m-ink); }
  #appView #medicalWorkspace .ttyt-saved .ttyt-summary .is-empty dd { font-size: 12px; font-weight: 400; color: #a39a90; }
  #appView #medicalWorkspace .ttyt-saved .ttyt-signature { max-height: 44px; width: auto; }
  /* Nghề nghiệp, di chuyển, giấc ngủ: 2 cột, câu hỏi ở trên, trả lời ngay dưới */
  #appView #medicalWorkspace .ttyt-saved .ttyt-read-section:has(.ttyt-work-card) .ttyt-card-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  #appView #medicalWorkspace .ttyt-saved .ttyt-work-card .ttyt-answer { display: block; padding: 0; border: 0; }
  #appView #medicalWorkspace .ttyt-saved .ttyt-work-card dt { font-size: 12.5px; }
  #appView #medicalWorkspace .ttyt-saved .ttyt-work-card dd { margin-top: 3px; }
  /* Tiền sử bệnh: lưới 3 cột hàng gọn; bệnh trả lời "Có" nổi màu, trải hết chiều ngang để đọc chi tiết */
  #appView #medicalWorkspace .ttyt-saved .ttyt-read-section:last-child .ttyt-card-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
  #appView #medicalWorkspace .ttyt-saved .ttyt-condition { padding: 6px 10px; }
  #appView #medicalWorkspace .ttyt-saved .ttyt-condition header { align-items: center; gap: 8px; }
  #appView #medicalWorkspace .ttyt-saved .ttyt-condition header h4 { margin: 0; font-size: 12.5px; font-weight: 600; line-height: 1.35; }
  #appView #medicalWorkspace .ttyt-saved .ttyt-status { padding: 2px 8px; border-radius: 99px; font-size: 11px; font-weight: 800; }
  #appView #medicalWorkspace .ttyt-saved .ttyt-status.is-no { background: #eef8f1; color: #15713f; }
  #appView #medicalWorkspace .ttyt-saved .ttyt-status.is-yes { background: #b3261e; color: #fff; }
  #appView #medicalWorkspace .ttyt-saved .ttyt-status.is-unanswered { background: #f0f0f2; color: #71717a; }
  #appView #medicalWorkspace .ttyt-saved .ttyt-condition.has-condition { grid-column: 1 / -1; border-color: #f5c2bd; background: #fff8f7; }
  #appView #medicalWorkspace .ttyt-saved .ttyt-condition.has-condition header h4 { font-weight: 800; color: #7a1a14; }
  #appView #medicalWorkspace .ttyt-saved .ttyt-condition dl { margin-top: 6px; padding-top: 4px; border-top: 1px dashed #f5c2bd; }
  #appView #medicalWorkspace .ttyt-saved .ttyt-condition .ttyt-answer-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 18px; }
  @media (max-width: 1200px) {
    #appView #medicalWorkspace .ttyt-saved .ttyt-general { grid-template-columns: 1fr 1fr; }
    #appView #medicalWorkspace .ttyt-saved .ttyt-general > .ttyt-card:first-child { grid-column: 1 / -1; }
    #appView #medicalWorkspace .ttyt-saved .ttyt-general > .ttyt-card:first-child .ttyt-answer-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 18px; }
    #appView #medicalWorkspace .ttyt-saved .ttyt-read-section:last-child .ttyt-card-grid,
    #appView #medicalWorkspace .ttyt-saved .ttyt-read-section:has(.ttyt-work-card) .ttyt-card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  }
  @media (max-width: 700px) {
    #appView #medicalWorkspace .ttyt-saved .ttyt-general, #appView #medicalWorkspace .ttyt-saved .ttyt-card-grid,
    #appView #medicalWorkspace .ttyt-saved .ttyt-read-section:last-child .ttyt-card-grid,
    #appView #medicalWorkspace .ttyt-saved .ttyt-read-section:has(.ttyt-work-card) .ttyt-card-grid,
    #appView #medicalWorkspace .ttyt-saved .ttyt-general > .ttyt-card:first-child .ttyt-answer-grid,
    #appView #medicalWorkspace .ttyt-saved .ttyt-condition .ttyt-answer-grid { grid-template-columns: minmax(0, 1fr); }
  }

  /* ---------- Hộp thoại "Bảng thu thập thông tin y tế" (trang Hồ sơ sức khỏe + trang Khách hàng) ---------- */
  #appView :is(#intakeDialog, #hubIntakeDialog) { --q-bronze: #a9783a; --q-deep: #8a5f2a; --q-line: #e4dccf; width: min(1060px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); border: 0; border-radius: 18px; background: #faf7f2; color: #0a0a0a; box-shadow: 0 30px 90px rgba(20, 16, 10, .35); }
  #appView :is(#intakeDialog, #hubIntakeDialog)::backdrop { background: rgba(28, 22, 15, .55); backdrop-filter: blur(2px); }
  #appView :is(#intakeDialog, #hubIntakeDialog) .intake-dialog-head { box-sizing: border-box; height: 56px; padding: 0 22px; border-bottom: 1px solid var(--q-line); background: linear-gradient(105deg, #f8efe1, #fff 70%); }
  #appView :is(#intakeDialog, #hubIntakeDialog) .intake-dialog-head h2 { display: flex; align-items: center; gap: 10px; font-size: 15px; font-weight: 800; letter-spacing: .03em; color: var(--q-deep); }
  #appView :is(#intakeDialog, #hubIntakeDialog) .intake-dialog-head h2::before { content: ""; width: 4px; height: 18px; border-radius: 2px; background: var(--q-bronze); }
  #appView :is(#intakeDialog, #hubIntakeDialog) .intake-dialog-head button { min-height: 34px; padding: 0 14px; border-radius: 10px; font-weight: 700; }
  #appView :is(#intakeDialog, #hubIntakeDialog) .ttyt-form { background: transparent; box-shadow: none; }
  #appView :is(#intakeDialog, #hubIntakeDialog) .ttyt-form > .panel-body { padding: 0 22px; }
  /* Đọc từ ảnh phiếu giấy */
  #appView :is(#intakeDialog, #hubIntakeDialog) .ttyt-ocr-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 14px 0 0; }
  #appView :is(#intakeDialog, #hubIntakeDialog) #ttyt_ocr { display: inline-flex; align-items: center; gap: 8px; min-height: 36px; padding: 0 14px; border: 1px dashed var(--q-bronze); border-radius: 10px; background: #fff; color: var(--q-deep); font-weight: 700; }
  #appView :is(#intakeDialog, #hubIntakeDialog) #ttyt_ocr::before { content: ""; width: 16px; height: 16px; background: currentColor; -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='1.6' stroke-linejoin='round'%3E%3Cpath d='M2.5 5.5h2l1.2-2h4.6l1.2 2h2v7.5h-11z'/%3E%3Ccircle cx='8' cy='9' r='2.4'/%3E%3C/svg%3E") center / contain no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='1.6' stroke-linejoin='round'%3E%3Cpath d='M2.5 5.5h2l1.2-2h4.6l1.2 2h2v7.5h-11z'/%3E%3Ccircle cx='8' cy='9' r='2.4'/%3E%3C/svg%3E") center / contain no-repeat; }
  #appView :is(#intakeDialog, #hubIntakeDialog) #ttyt_ocr:hover { background: #f6efe5; }
  /* Thanh bước dính dưới tiêu đề */
  #appView :is(#intakeDialog, #hubIntakeDialog) .ttyt-nav { position: sticky; top: 55px; z-index: 2; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0; margin: 12px -22px 14px; padding: 10px 22px; border-bottom: 1px solid var(--q-line); background: rgba(250, 247, 242, .96); backdrop-filter: blur(4px); }
  #appView :is(#intakeDialog, #hubIntakeDialog) .ttyt-nav button { position: relative; display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 0 8px; border: 0; border-radius: 10px; background: transparent; box-shadow: none; color: #5b524a; font-weight: 700; white-space: nowrap; }
  #appView :is(#intakeDialog, #hubIntakeDialog) .ttyt-nav button + button::before { content: ""; position: absolute; left: -12%; top: 50%; width: 24%; height: 2px; background: #e4d8c6; }
  #appView :is(#intakeDialog, #hubIntakeDialog) .ttyt-nav button:hover { background: #f3ece1; color: #0a0a0a; }
  #appView :is(#intakeDialog, #hubIntakeDialog) .ttyt-step-no { display: inline-grid; place-items: center; flex: none; width: 26px; height: 26px; border: 2px solid #dccdb6; border-radius: 50%; background: #fff; font-size: 12px; font-weight: 800; }
  #appView :is(#intakeDialog, #hubIntakeDialog) .ttyt-step-label { overflow: hidden; text-overflow: ellipsis; font-size: 13px; }
  #appView :is(#intakeDialog, #hubIntakeDialog) .ttyt-nav button[aria-pressed="true"] { background: #fff; color: var(--q-deep); box-shadow: 0 1px 3px rgba(20, 16, 10, .1); }
  #appView :is(#intakeDialog, #hubIntakeDialog) .ttyt-nav button[aria-pressed="true"] .ttyt-step-no { border-color: var(--q-bronze); background: var(--q-bronze); color: #fff; }
  #appView :is(#intakeDialog, #hubIntakeDialog) .ttyt-ocr-count { margin-left: 2px; padding: 0 6px; border-radius: 99px; background: #b3261e; color: #fff; font-size: 11px; }
  /* Lời dẫn mỗi trang + thẻ từng mục */
  #appView :is(#intakeDialog, #hubIntakeDialog) .ttyt-intro { margin: 0 0 12px; padding: 10px 14px; border-left: 3px solid var(--q-bronze); border-radius: 0 10px 10px 0; background: #f4ede2; color: #3f3a33; font-size: 13px; line-height: 1.55; }
  #appView :is(#intakeDialog, #hubIntakeDialog) [data-ttyt-panel] > h3 { margin: 4px 0 10px; font-size: 14px; font-weight: 800; color: var(--q-deep); }
  #appView :is(#intakeDialog, #hubIntakeDialog) .ttyt-section { margin: 0 0 12px; padding: 14px 16px; border: 1px solid var(--q-line); border-radius: 14px; background: #fff; box-shadow: 0 1px 2px rgba(20, 16, 10, .04); }
  #appView :is(#intakeDialog, #hubIntakeDialog) .ttyt-section > h3 { margin: 0 0 12px; padding-bottom: 8px; border-bottom: 1px solid #f0e8dc; font-size: 14px; font-weight: 800; line-height: 1.45; color: #0a0a0a; }
  #appView :is(#intakeDialog, #hubIntakeDialog) .ttyt-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px 16px; }
  #appView :is(#intakeDialog, #hubIntakeDialog) .ttyt-grid .field { margin: 0; }
  #appView :is(#intakeDialog, #hubIntakeDialog) .ttyt-grid label { display: block; margin-bottom: 4px; font-size: 12.5px; font-weight: 600; line-height: 1.4; color: #5b524a; }
  #appView :is(#intakeDialog, #hubIntakeDialog) .ttyt-grid :is(input:not([type=radio]):not([type=checkbox]), select, textarea) { width: 100%; min-height: 40px; border: 1px solid #d9cdbb; border-radius: 10px; background: #fff; font-size: 14px; }
  #appView :is(#intakeDialog, #hubIntakeDialog) .ttyt-grid textarea { min-height: 64px; resize: vertical; }
  #appView :is(#intakeDialog, #hubIntakeDialog) .ttyt-grid :is(input:not([type=radio]):not([type=checkbox]), select, textarea):focus { border-color: var(--q-bronze); outline: 0; box-shadow: 0 0 0 3px rgba(169, 120, 58, .18); }
  /* Trang nghề nghiệp, giấc ngủ: mỗi câu một hàng — câu hỏi bên trái, ô trả lời bên phải, các ô thẳng hàng */
  #appView :is(#intakeDialog, #hubIntakeDialog) [data-ttyt-panel="1"] .ttyt-grid { grid-template-columns: minmax(0, 1fr); gap: 0; }
  #appView :is(#intakeDialog, #hubIntakeDialog) [data-ttyt-panel="1"] .ttyt-grid > .field { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); align-items: center; gap: 16px; padding: 10px 0; border-bottom: 1px dashed #efe7da; }
  #appView :is(#intakeDialog, #hubIntakeDialog) [data-ttyt-panel="1"] .ttyt-grid > .field:last-child { border-bottom: 0; }
  #appView :is(#intakeDialog, #hubIntakeDialog) [data-ttyt-panel="1"] .ttyt-grid > .field > label { margin: 0; font-size: 13.5px; color: #2a2520; }
  #appView :is(#intakeDialog, #hubIntakeDialog) [data-ttyt-panel="1"] .ttyt-grid textarea { min-height: 52px; }
  /* Trang tiền sử bệnh: mỗi bệnh một hàng (câu hỏi | Có / Không), chọn "Có" thì nổi đỏ và mở chi tiết bên dưới */
  #appView :is(#intakeDialog, #hubIntakeDialog) :is([data-ttyt-panel="2"], [data-ttyt-panel="3"]) .ttyt-section { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: center; gap: 10px 16px; margin-bottom: 8px; padding: 10px 14px; }
  #appView :is(#intakeDialog, #hubIntakeDialog) :is([data-ttyt-panel="2"], [data-ttyt-panel="3"]) .ttyt-section > h3 { grid-column: 1 / 3; grid-row: 1; margin: 0; padding: 0; border: 0; font-size: 13.5px; font-weight: 700; }
  #appView :is(#intakeDialog, #hubIntakeDialog) :is([data-ttyt-panel="2"], [data-ttyt-panel="3"]) .ttyt-section > .ttyt-grid { display: contents; }
  #appView :is(#intakeDialog, #hubIntakeDialog) :is([data-ttyt-panel="2"], [data-ttyt-panel="3"]) .ttyt-grid > .field:first-child { grid-column: 3; grid-row: 1; justify-self: end; width: min(220px, 100%); }
  #appView :is(#intakeDialog, #hubIntakeDialog) :is([data-ttyt-panel="2"], [data-ttyt-panel="3"]) .ttyt-grid > .field:not(:first-child) { grid-column: auto; }
  #appView :is(#intakeDialog, #hubIntakeDialog) :is([data-ttyt-panel="2"], [data-ttyt-panel="3"]) .ttyt-section:has(option[value="yes"]:checked) { border-color: #f5c2bd; background: #fff8f7; }
  #appView :is(#intakeDialog, #hubIntakeDialog) :is([data-ttyt-panel="2"], [data-ttyt-panel="3"]) .ttyt-section:has(option[value="yes"]:checked) > h3 { color: #7a1a14; }
  #appView :is(#intakeDialog, #hubIntakeDialog) :is([data-ttyt-panel="2"], [data-ttyt-panel="3"]) select:has(option[value="yes"]:checked) { border-color: #b3261e; color: #b3261e; font-weight: 700; }
  #appView :is(#intakeDialog, #hubIntakeDialog) :is([data-ttyt-panel="2"], [data-ttyt-panel="3"]) select:has(option[value="no"]:checked) { border-color: #9fd3b2; color: #15713f; font-weight: 700; }
  /* Nơi nhận kết quả + chữ ký */
  #appView :is(#intakeDialog, #hubIntakeDialog) .ttyt-delivery { display: grid; gap: 8px; margin: 0; }
  #appView :is(#intakeDialog, #hubIntakeDialog) .ttyt-delivery > legend { margin-bottom: 6px; font-size: 12.5px; font-weight: 600; color: #5b524a; }
  #appView :is(#intakeDialog, #hubIntakeDialog) .ttyt-delivery-opt { border: 1px solid var(--q-line); border-radius: 10px; background: #fff; transition: border-color .15s, background .15s; }
  #appView :is(#intakeDialog, #hubIntakeDialog) .ttyt-delivery-opt:has(input[type=radio]:checked) { border-color: var(--q-bronze); background: #fbf5ec; }
  /* Nút chọn bên trái, nội dung một dòng */
  #appView :is(#intakeDialog, #hubIntakeDialog) .ttyt-delivery .check { display: flex; flex-direction: row; align-items: center; gap: 10px; margin: 0; padding: 10px 14px; border: 0; background: transparent; cursor: pointer; text-align: left; }
  #appView :is(#intakeDialog, #hubIntakeDialog) .ttyt-delivery .check input[type=radio] { flex: none; width: 18px; height: 18px; min-height: 0; margin: 0; accent-color: var(--q-bronze); }
  #appView :is(#intakeDialog, #hubIntakeDialog) .ttyt-delivery .check span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13.5px; font-weight: 600; color: #2a2520; }
  /* Ô địa chỉ nhận tại nhà nằm trong thẻ lựa chọn */
  #appView :is(#intakeDialog, #hubIntakeDialog) .ttyt-delivery-opt > .field { margin: 0; padding: 0 14px 12px 42px; }
  #appView :is(#intakeDialog, #hubIntakeDialog) .ttyt-delivery-opt > .field textarea { width: 100%; min-height: 52px; border: 1px solid #d9cdbb; border-radius: 10px; background: #fff; font-size: 14px; }
  #appView :is(#intakeDialog, #hubIntakeDialog) #ttyt_signatureCanvas { border: 1.5px dashed #c9ad87; border-radius: 12px; background: #fff; }
  /* Nút điều hướng / lưu dính đáy hộp thoại */
  #appView :is(#intakeDialog, #hubIntakeDialog) .ttyt-actions { position: sticky; bottom: 0; z-index: 2; display: flex; align-items: center; gap: 10px; margin: 16px -22px 0; padding: 12px 22px; border-top: 1px solid var(--q-line); background: rgba(255, 255, 255, .97); box-shadow: 0 -6px 18px rgba(20, 16, 10, .06); }
  #appView :is(#intakeDialog, #hubIntakeDialog) .ttyt-actions button { min-height: 40px; padding: 0 18px; border-radius: 10px; font-weight: 700; }
  #appView :is(#intakeDialog, #hubIntakeDialog) .ttyt-actions #ttyt_next { margin-left: auto; }
  #appView :is(#intakeDialog, #hubIntakeDialog) .ttyt-actions #saveIntakeBtn { min-width: 130px; }
  @media (max-width: 760px) {
    #appView :is(#intakeDialog, #hubIntakeDialog) .ttyt-form > .panel-body { padding: 0 14px; }
    #appView :is(#intakeDialog, #hubIntakeDialog) .intake-dialog-head { height: auto; min-height: 52px; padding: 8px 12px; }
    #appView :is(#intakeDialog, #hubIntakeDialog) .intake-dialog-head h2 { min-width: 0; font-size: 13px; letter-spacing: 0; line-height: 1.35; }
    #appView :is(#intakeDialog, #hubIntakeDialog) .intake-dialog-head button { flex: none; padding: 0 10px; }
    #appView :is(#intakeDialog, #hubIntakeDialog) .ttyt-nav { position: static; grid-template-columns: repeat(4, auto); justify-content: space-between; margin: 10px -14px 12px; padding: 8px 14px; }
    #appView :is(#intakeDialog, #hubIntakeDialog) .ttyt-step-label { display: none; }
    #appView :is(#intakeDialog, #hubIntakeDialog) .ttyt-nav button[aria-pressed="true"] .ttyt-step-label { display: inline; }
    #appView :is(#intakeDialog, #hubIntakeDialog) .ttyt-grid, #appView :is(#intakeDialog, #hubIntakeDialog) [data-ttyt-panel="1"] .ttyt-grid { grid-template-columns: minmax(0, 1fr); }
    #appView :is(#intakeDialog, #hubIntakeDialog) [data-ttyt-panel="1"] .ttyt-grid > .field { grid-template-columns: minmax(0, 1fr); gap: 6px; }
    #appView :is(#intakeDialog, #hubIntakeDialog) .ttyt-delivery .check span { white-space: normal; }
    #appView :is(#intakeDialog, #hubIntakeDialog) .ttyt-delivery-opt > .field { padding-left: 14px; }
    #appView :is(#intakeDialog, #hubIntakeDialog) :is([data-ttyt-panel="2"], [data-ttyt-panel="3"]) .ttyt-section { grid-template-columns: minmax(0, 1fr); }
    #appView :is(#intakeDialog, #hubIntakeDialog) :is([data-ttyt-panel="2"], [data-ttyt-panel="3"]) .ttyt-section > h3,
    #appView :is(#intakeDialog, #hubIntakeDialog) :is([data-ttyt-panel="2"], [data-ttyt-panel="3"]) .ttyt-grid > .field:first-child { grid-column: 1; grid-row: auto; justify-self: stretch; width: 100%; }
    #appView :is(#intakeDialog, #hubIntakeDialog) .ttyt-actions { margin: 14px -14px 0; padding: 10px 14px; }
  }

  /* ---------- Dòng thời gian ---------- */
  #appView #medicalWorkspace .timeline { position: relative; }

  /* ---------- Màn hình hẹp ---------- */
  @media (max-width: 1200px) { #appView #medicalWorkspace .ov-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
  @media (max-width: 900px) {
    #appView #medicalWorkspace { grid-template-columns: 1fr; }
    #appView #medicalWorkspace > aside { max-height: none; }
    #appView #medicalWorkspace .plist { max-height: 260px; }
  }
  @media (max-width: 560px) {
    #appView #medicalWorkspace .ov-stats { grid-template-columns: 1fr 1fr; gap: 8px; }
    #appView #medicalWorkspace .ov-stat { grid-template-columns: minmax(0, 1fr) auto; gap: 6px; padding: 10px 12px; }
    #appView #medicalWorkspace .ov-ic { display: none; }
    #appView #medicalWorkspace .ov-txt small { white-space: normal; }
    #appView #medicalWorkspace .ov-stat b { font-size: 22px; }
    #appView #medicalWorkspace .pb-id { flex: 1 1 calc(100% - 60px); }
    #appView #medicalWorkspace .pb-facts { gap: 2px 12px; font-size: 12.5px; }
    #appView #medicalWorkspace .pb-facts > span { padding: 0; border-left: 0; }
    #appView #medicalWorkspace .pb-actions { width: 100%; }
    #appView #medicalWorkspace .pb-actions #printBtn { width: 100%; justify-content: center; }
    #appView #medicalWorkspace .pb-main { flex-wrap: wrap; padding: 14px; }
    #appView #medicalWorkspace .pb-avatar { width: 44px; height: 44px; font-size: 16px; }
    #appView #medicalWorkspace .pb-name { font-size: 19px; }
    #appView #medicalWorkspace .pb-journey { padding: 4px 14px 12px; }
  }
}

/* ==========================================================================
   Giao diện máy tính theo CRM mới (05/11/2026): 2 cột — danh sách hồ sơ thẻ phẳng (320px) và chi tiết;
   tab gạch dưới; dải tóm tắt thay ô số; chip trạng thái theo token; không vạch đồng, bóng đổ, chữ hoa.
   Chỉ ≥ 901px; màn hẹp giữ bố cục cũ.
   ========================================================================== */
@media screen and (min-width: 901px) {
  #appView #medicalWorkspace {
    display: grid; grid-template-columns: 320px minmax(0, 1fr); grid-template-rows: auto auto minmax(0, 1fr);
    column-gap: 20px; row-gap: 0; align-items: start; padding: 24px 32px 40px; transition: none;
  }
  /* Đầu màn một dòng: tiêu đề · số đếm · khoảng trống · nút đặc */
  #appView #medicalWorkspace > aside { display: contents; }
  #appView #medicalWorkspace > aside.panel > .panel-head { grid-column: 1 / -1; grid-row: 1; display: flex; flex-wrap: wrap; align-items: center; gap: 12px; min-height: 40px; margin: 0 0 16px; padding: 0 !important; border: 0 !important; border-radius: 0; background: none; }
  #appView #medicalWorkspace > aside.panel > .panel-head > .spacer { display: block; flex: 1 1 auto; }
  #appView #medicalWorkspace .med-toggle { display: none; }
  #appView #medicalWorkspace > aside.panel > .panel-head > span:first-of-type { overflow: visible; font-size: 24px; font-weight: 700; letter-spacing: -.3px; color: #25211C; }
  #appView #medicalWorkspace #listCount { min-width: 26px; height: 24px; box-sizing: border-box; padding: 0 8px; border-radius: 12px; background: #F1ECE4; color: #6F655A; font-size: 12px; font-weight: 700; line-height: 24px; }
  #appView #medicalWorkspace #newFromCrmBtn { margin: 0; min-height: 40px; padding: 0 16px; gap: 8px; border: 0; border-radius: 10px; background: #9A6A2E; color: #fff; font-size: 14px; font-weight: 700; }
  #appView #medicalWorkspace #newFromCrmBtn:hover { background: #7E5523; }
  #appView #medicalWorkspace #newFromCrmBtn svg, #appView #medicalWorkspace #newFromCrmBtn #iconPlus { color: #fff; stroke: currentColor; }
  #appView #medicalWorkspace .lab-file .lab-results { min-width: 820px; }
  /* Danh sách hồ sơ: một thẻ viền #E4DACA, ô tìm + lọc phía trên, dòng kẻ #EFE9DD */
  #appView #medicalWorkspace .rail-filters { grid-column: 1; grid-row: 2; display: flex; flex-direction: column; align-items: stretch; gap: 10px; padding: 14px; border: 1px solid #E4DACA; border-bottom: 0; border-radius: 16px 16px 0 0; background: #fff; }
  #appView #medicalWorkspace .rail-filters input { min-height: 40px; border: 1px solid #E4DACA; border-radius: 20px; font-size: 14px; }
  #appView #medicalWorkspace .rail-filters select { align-self: flex-start; width: auto; max-width: 100%; min-height: 36px; padding: 0 30px 0 14px; border: 1px solid #E4DACA; border-radius: 18px; background-color: #fff; font-size: 13px; font-weight: 600; color: #25211C; }
  #appView #medicalWorkspace .plist { grid-column: 1; grid-row: 3; min-height: 0; max-height: calc(100svh - 220px); padding: 0; overflow: hidden auto; border: 1px solid #E4DACA; border-radius: 0 0 16px 16px; background: #fff; }
  #appView #medicalWorkspace .pitem { grid-template-columns: 38px minmax(0, 1fr); gap: 10px; margin: 0; padding: 12px 14px; border: 0; border-top: 1px solid #EFE9DD; border-radius: 0; background: #fff; box-shadow: none; }
  #appView #medicalWorkspace .pitem:hover { background: #FAF1E1; }
  #appView #medicalWorkspace .pitem[aria-selected="true"] { background: #FAF1E1; border-color: #EFE9DD; box-shadow: none; }
  #appView #medicalWorkspace .pitem .nm { font-size: 14px; font-weight: 700; color: #25211C; }
  #appView #medicalWorkspace .pitem .row2 { font-size: 12px; color: #6F655A; }
  #appView #medicalWorkspace .pitem .tag { font-size: 12px; }
  #appView #medicalWorkspace .pav, #appView #medicalWorkspace .pb-avatar { background: #9A6A2E; }
  #appView #medicalWorkspace .pav { font-weight: 700; }
  #appView #medicalWorkspace .pav.st-moi { background: #6F655A; }
  #appView #medicalWorkspace .pav.st-cho_xet_nghiem, #appView #medicalWorkspace .pav.st-theo_doi { background: #24498A; }
  #appView #medicalWorkspace .pav.st-cho_tu_van { background: #8A4B0C; }
  #appView #medicalWorkspace .pav.st-ket_thuc { background: #1F5E2E; }
  #appView #medicalWorkspace .owner-group > summary { padding: 10px 14px; border-top: 1px solid #EFE9DD; background: #FAF7F2; color: #6F655A; font-size: 13px; font-weight: 600; text-transform: none; letter-spacing: 0; }
  #appView #medicalWorkspace .hub-pager { border-top: 1px solid #EFE9DD; }
  /* Chip trạng thái theo token */
  #appView #medicalWorkspace .tag { height: auto; min-height: 22px; padding: 0 10px; border: 0; border-radius: 12px; background: #F1ECE4; color: #6F655A; font-size: 12px; font-weight: 600; letter-spacing: 0; text-transform: none; }
  #appView #medicalWorkspace .tag.ok { background: #E6F2E8; color: #1F5E2E; }
  #appView #medicalWorkspace .tag.warn { background: #FFF2E0; color: #8A4B0C; }
  #appView #medicalWorkspace .tag.danger, #appView #medicalWorkspace .tag.lab-high { background: #FBE7E5; color: #9B2F23; }
  #appView #medicalWorkspace .tag.info, #appView #medicalWorkspace .tag.low, #appView #medicalWorkspace .tag.lab-low { background: #E7EEF9; color: #24498A; }
  #appView #medicalWorkspace .tag.brand { background: #EFE2CC; color: #6E4A1C; }

  /* Cột phải */
  #appView #medicalWorkspace > main { grid-column: 2; grid-row: 2 / span 2; }
  #appView #medicalWorkspace .panel:not(.lab-file):not(.care-file):not(.ttyt-saved):not(.intake-add):not(.lab-upload) { border-color: #E4DACA; box-shadow: none; }
  #appView #medicalWorkspace #detailEmpty { border: 1px solid #E4DACA; background: #FAF7F2; }
  #appView #medicalWorkspace .patient-banner { border: 1px solid #E4DACA; border-radius: 16px; background: #fff; box-shadow: none; }
  #appView #medicalWorkspace .pb-main { gap: 14px; padding: 20px 24px 14px; }
  #appView #medicalWorkspace .pb-avatar { width: 52px; height: 52px; font-size: 18px; font-weight: 700; box-shadow: none; }
  #appView #medicalWorkspace .pb-name { font-size: 20px; font-weight: 700; letter-spacing: 0; color: #25211C; }
  #appView #medicalWorkspace .pb-facts { gap: 2px 0; margin-top: 4px; font-size: 13px; color: #6F655A; }
  #appView #medicalWorkspace .pb-facts > span { padding: 0; border: 0; }
  #appView #medicalWorkspace .pb-facts > span + span::before { content: "·"; margin: 0 8px; }
  #appView #medicalWorkspace .pb-facts .mrn { font-family: inherit; font-weight: 400; color: inherit; }
  #appView #medicalWorkspace .pb-actions #printBtn { min-height: 40px; padding: 0 16px; border: 1px solid #E4DACA; border-radius: 10px; background: #fff; color: #25211C; font-size: 14px; font-weight: 600; }
  #appView #medicalWorkspace .pb-actions #printBtn:hover { background: #FAF7F2; }
  /* Chặng chăm sóc */
  #appView #medicalWorkspace .pb-journey { padding: 4px 24px 20px; }
  #appView #medicalWorkspace .journey li + li::before { top: 13px; height: 2px; background: #EFE9DD; }
  #appView #medicalWorkspace .journey li.is-done + li::before, #appView #medicalWorkspace .journey li.is-done + li.is-now::before { background: #9A6A2E; }
  #appView #medicalWorkspace .jdot { width: 26px; height: 26px; border: 2px solid #E4DACA; font-weight: 700; color: #6F655A; }
  #appView #medicalWorkspace .journey button:not(:disabled):hover .jdot { transform: none; border-color: #9A6A2E; color: #6E4A1C; }
  #appView #medicalWorkspace .jlabel { font-size: 13px; font-weight: 500; }
  #appView #medicalWorkspace .journey li.is-done .jdot { border-color: #9A6A2E; background: #9A6A2E; color: #fff; }
  #appView #medicalWorkspace .journey li.is-now .jdot { border-color: #9A6A2E; background: #fff; color: #6E4A1C; box-shadow: none; }
  #appView #medicalWorkspace .journey li.is-now .jlabel { color: #6E4A1C; font-weight: 700; }
  /* Cảnh báo cạnh tên */
  #appView #medicalWorkspace .pb-flag { min-height: 24px; padding: 0 10px; border: 0; border-radius: 12px; font-size: 12px; font-weight: 600; }
  #appView #medicalWorkspace .pb-flag b { font-weight: 700; }
  #appView #medicalWorkspace .pb-flag em { background: #9B2F23; font-weight: 700; }
  #appView #medicalWorkspace .pb-flag.is-allergy, #appView #medicalWorkspace .pb-flag.is-crit { background: #FBE7E5; color: #9B2F23; }
  #appView #medicalWorkspace .pb-flag.is-chronic { background: #FFF2E0; color: #8A4B0C; }
  #appView #medicalWorkspace .pb-flag-btn:hover { background: #F6D5D1; box-shadow: none; }
  #appView #medicalWorkspace .pb-flag-btn:focus-visible { outline-color: #9B2F23; }
  #appView #medicalWorkspace .pb-alerts { padding: 0 24px 16px; }
  #appView #medicalWorkspace .alert-strip { border: 0; border-radius: 12px; background: #FBE7E5; color: #9B2F23; }
  #appView #medicalWorkspace .alert-strip .k { padding: 0 10px; background: #9B2F23; font-weight: 700; letter-spacing: 0; text-transform: none; }
  #appView #medicalWorkspace .alert-strip .k::before { content: none; }
  /* Tab gạch dưới */
  #appView #medicalWorkspace .tabs { gap: 24px; margin-top: 16px; box-shadow: none; border-bottom: 1px solid #EFE9DD; }
  #appView #medicalWorkspace .tab { gap: 6px; min-height: 44px; padding: 0; border-bottom: 2px solid transparent; color: #6F655A; font-size: 14px; font-weight: 600; }
  #appView #medicalWorkspace .tab svg { display: none; }
  #appView #medicalWorkspace .tab:hover { color: #25211C; }
  #appView #medicalWorkspace .tab[aria-selected="true"] { color: #25211C; border-bottom-color: #9A6A2E; }
  #appView #medicalWorkspace .tab .count, #appView #medicalWorkspace .tab[aria-selected="true"] .count { min-width: 20px; height: 20px; box-sizing: border-box; padding: 0 7px; border-radius: 10px; background: #F1ECE4; color: #6F655A; font-size: 11px; font-weight: 700; line-height: 20px; }
  /* Tổng quan: ô số thành dải tóm tắt một dòng */
  #appView #medicalWorkspace .ov-stats { display: flex; flex-wrap: wrap; align-items: center; gap: 0; min-height: 48px; padding: 6px 4px; border-radius: 12px; background: #FAF7F2; }
  #appView #medicalWorkspace .ov-stat, #appView #medicalWorkspace .ov-stat.is-warn { display: flex; flex-wrap: nowrap; align-items: baseline; gap: 6px; min-height: 0; padding: 6px 16px; border: 0; border-left: 1px solid #EFE9DD; border-radius: 0; background: none; box-shadow: none; transform: none; }
  #appView #medicalWorkspace .ov-stat:first-child { border-left: 0; }
  #appView #medicalWorkspace .ov-stat:hover { transform: none; background: #FAF1E1; border-color: #EFE9DD; }
  #appView #medicalWorkspace .ov-stat:first-child:hover { border-left: 0; }
  #appView #medicalWorkspace .ov-ic { display: none; }
  #appView #medicalWorkspace .ov-txt { display: contents; }
  #appView #medicalWorkspace .ov-txt span { order: 1; font-size: 13px; font-weight: 400; color: #6F655A; }
  #appView #medicalWorkspace .ov-stat b { order: 2; font-size: 15px; font-weight: 700; color: #25211C; }
  #appView #medicalWorkspace .ov-txt small { order: 3; font-size: 12px; color: #6F655A; }
  #appView #medicalWorkspace .ov-txt em { color: #9B2F23; }
  #appView #medicalWorkspace .ov-stat.is-warn b { color: #9B2F23; }
  /* Thẻ khối: tiêu đề 16/700, cặp nhãn–giá trị 160px */
  #appView #medicalWorkspace .panel:not(aside):not(.lab-file):not(.care-file):not(.ttyt-saved) > .panel-head { padding: 16px 24px; border-bottom: 0; font-size: 16px; font-weight: 700; }
  #appView #medicalWorkspace .panel:not(aside):not(.lab-file):not(.care-file):not(.ttyt-saved) > .panel-head > svg { display: none; }
  #appView #medicalWorkspace .panel:not(aside):not(.lab-file):not(.care-file):not(.ttyt-saved) > .panel-body { padding: 20px 24px; }
  #appView #medicalWorkspace .journey { min-width: 0; }
  @media (max-width: 1280px) {
    #appView #medicalWorkspace .kv, #appView #medicalWorkspace .clinical-summary > div { grid-template-columns: 120px minmax(0, 1fr) !important; }
    #appView #medicalWorkspace .grid-2 { grid-template-columns: minmax(0, 1fr); }
    #appView #medicalWorkspace .tabs { gap: 18px; }
    #appView #medicalWorkspace table th, #appView #medicalWorkspace table td { padding-left: 8px; padding-right: 8px; }
  }
  #appView #medicalWorkspace .section-title { margin: 0 0 8px; font-size: 16px; font-weight: 700; letter-spacing: 0; text-transform: none; color: #25211C; }
  #appView #medicalWorkspace .section-title::before { content: none; }
  #appView #medicalWorkspace .kv { grid-template-columns: 160px minmax(0, 1fr) !important; gap: 0; }
  #appView #medicalWorkspace .kv dt, #appView #medicalWorkspace .kv dd { padding: 10px 0; border-bottom: 0; border-top: 1px solid #EFE9DD; }
  #appView #medicalWorkspace .kv dt { font-size: 13px; font-weight: 400; color: #6F655A; }
  #appView #medicalWorkspace .kv dd { font-size: 14px; font-weight: 400; color: #25211C; }
  #appView #medicalWorkspace .clinical-summary > div { grid-template-columns: 160px minmax(0, 1fr); padding: 12px 0; border: 0; border-top: 1px solid #EFE9DD; }
  #appView #medicalWorkspace .clinical-summary > div:last-child { border-bottom: 0; }
  #appView #medicalWorkspace .clinical-summary dt { font-size: 13px; font-weight: 400; color: #6F655A; }
  #appView #medicalWorkspace .clinical-summary dd { font-size: 14px; color: #25211C; }
  /* Bảng chỉ số: đầu nền #FAF7F2, số căn phải */
  #appView #medicalWorkspace table th { padding: 10px 12px; background: #FAF7F2; color: #6F655A; font-size: 13px; font-weight: 600; letter-spacing: 0; text-transform: none; border-color: #EFE9DD; }
  #appView #medicalWorkspace table td { border-color: #EFE9DD; color: #25211C; font-weight: 400; }
  #appView #medicalWorkspace table tbody tr:hover { background: #FAF1E1; }
  #appView #medicalWorkspace .lab-file table th:first-child, #appView #medicalWorkspace .lab-file table td:first-child { padding-left: 24px; text-align: left; }
  #appView #medicalWorkspace .lab-file .lab-results th:nth-child(2), #appView #medicalWorkspace .lab-file .lab-results td:nth-child(2),
  #appView #medicalWorkspace .lab-file .lab-results th:nth-child(4), #appView #medicalWorkspace .lab-file .lab-results td:nth-child(4) { text-align: right; padding-right: 12px; }
  #appView #medicalWorkspace .lab-file .lab-results td:nth-child(3), #appView #medicalWorkspace .lab-file .lab-results th:nth-child(3) { text-align: left; }
  #appView #medicalWorkspace .lab-file .lab-results td:first-child { font-weight: 700; }
  #appView #medicalWorkspace tr.abn-low td:first-child { box-shadow: inset 3px 0 0 #24498A; }
  #appView #medicalWorkspace tr.abn-high td:first-child { box-shadow: inset 3px 0 0 #9B2F23; }
  #appView #medicalWorkspace .lab-file tr.abn-low td.num b { color: #24498A; }
  #appView #medicalWorkspace .lab-file tr.abn-high td.num b { color: #9B2F23; }
  #appView #medicalWorkspace .lab-file .lab-results td[colspan] { background: #FAF7F2; color: #6F655A; font-size: 13px; font-weight: 600; text-align: left; }
  /* Thẻ phiếu: xét nghiệm, phiếu y tế, bảng tư vấn */
  #appView #medicalWorkspace :is(.lab-file, .care-file, .ttyt-saved) { border: 1px solid #E4DACA; border-radius: 16px; background: #fff; box-shadow: none; }
  #appView #medicalWorkspace :is(.lab-file-head, .ttyt-head, .care-file-head) { background: #fff; }
  #appView #medicalWorkspace .ttyt-head:hover { background: #FAF1E1; }
  #appView #medicalWorkspace .lab-file-label .lab-file-name { font-weight: 700; }
  #appView #medicalWorkspace .lab-file-label .lab-latest { color: #8A5F27; }
  #appView #medicalWorkspace .lab-file-lab { color: #6F655A; }
  #appView #medicalWorkspace .lab-file-actions button, #appView #medicalWorkspace .care-file-head button, #appView #medicalWorkspace .ttyt-head button { min-width: 0; min-height: 34px; height: 34px; padding: 0 14px; border: 1px solid #E4DACA; border-radius: 10px; background: #fff; color: #25211C; font-size: 13px; font-weight: 600; box-shadow: none; }
  #appView #medicalWorkspace .lab-file-actions button:hover, #appView #medicalWorkspace .care-file-head button:hover, #appView #medicalWorkspace .ttyt-head button:hover { background: #FAF7F2; }
  #appView #medicalWorkspace :is(.lab-file-actions, .care-file-head) button[aria-expanded="true"], #appView #medicalWorkspace :is(.lab-file-actions, .care-file-head) button[aria-expanded="true"]:hover { border-color: #EFE2CC; background: #EFE2CC; color: #6E4A1C; box-shadow: none; }
  /* Thẻ thêm mới */
  #appView #medicalWorkspace :is(.intake-add, .lab-upload) { border: 1px dashed #E4DACA; background: #FAF7F2; }
  #appView #medicalWorkspace :is(.intake-add, .lab-upload) > button { color: #8A5F27; font-weight: 600; }
  #appView #medicalWorkspace :is(.intake-add, .lab-upload) > button:hover { background: #FAF1E1; }
  #appView #medicalWorkspace :is(.intake-add, .lab-upload) .lab-plus { background: linear-gradient(#fff, #fff) center / var(--pl) var(--pw) no-repeat, linear-gradient(#fff, #fff) center / var(--pw) var(--pl) no-repeat, #9A6A2E; }
  #appView #medicalWorkspace .stack > :is(.intake-add, .lab-upload):first-child .lab-plus { box-shadow: 0 0 0 8px #FBF6ED; }
  /* Xem phiếu y tế đã lưu */
  #appView #medicalWorkspace .ttyt-saved .ttyt-summary { --q-line: #EFE9DD; }
  #appView #medicalWorkspace .ttyt-saved .ttyt-read-section > h3 { font-size: 15px; font-weight: 700; letter-spacing: 0; text-transform: none; color: #25211C; }
  #appView #medicalWorkspace .ttyt-saved .ttyt-read-section > h3::before { content: none; }
  #appView #medicalWorkspace .ttyt-saved .ttyt-card { border-color: #EFE9DD; border-radius: 12px; }
  #appView #medicalWorkspace .ttyt-saved .ttyt-card h4 { font-weight: 700; color: #25211C; }
  #appView #medicalWorkspace .ttyt-saved .ttyt-summary dt { color: #6F655A; }
  #appView #medicalWorkspace .ttyt-saved .ttyt-summary dd { font-weight: 600; color: #25211C; }
  #appView #medicalWorkspace .ttyt-saved .ttyt-status { min-height: 22px; padding: 0 8px; border-radius: 12px; font-weight: 600; line-height: 22px; }
  #appView #medicalWorkspace .ttyt-saved .ttyt-status.is-no { background: #E6F2E8; color: #1F5E2E; }
  #appView #medicalWorkspace .ttyt-saved .ttyt-status.is-yes { background: #FBE7E5; color: #9B2F23; }
  #appView #medicalWorkspace .ttyt-saved .ttyt-status.is-unanswered { background: #F1ECE4; color: #6F655A; }
  #appView #medicalWorkspace .ttyt-saved .ttyt-condition.has-condition { border-color: #F3C9C4; background: #FFF8F7; }
  #appView #medicalWorkspace .ttyt-saved .ttyt-condition.has-condition header h4 { color: #9B2F23; }
  #appView #medicalWorkspace .ttyt-saved .ttyt-condition dl { border-top-color: #F3C9C4; }
  #appView #medicalWorkspace .care-view { border-top-color: #EFE9DD; }
  #appView #medicalWorkspace .record-detail h3 { color: #25211C; }
  #appView #medicalWorkspace .record-detail .advice-block { border-color: #EFE9DD; border-left: 1px solid #EFE9DD; background: #FAF7F2; }
  #appView #medicalWorkspace .consult-advice-label { letter-spacing: 0; text-transform: none; color: #6F655A; font-size: 12px; }
  #appView #medicalWorkspace .sent-records { border-color: #E4DACA; border-radius: 16px; }
  #appView #medicalWorkspace .sent-record-content { border-left-color: #EFE9DD; }
  #appView #medicalWorkspace .sent-record-nav button[aria-pressed="true"] { border-color: #EFE2CC; background: #EFE2CC; color: #6E4A1C; }
  #appView #medicalWorkspace .sent-record-nav .sent-record-advice { border-color: #9A6A2E; background: #9A6A2E; color: #fff; box-shadow: none; }
  #appView #medicalWorkspace .sent-record-nav .sent-record-advice:hover { border-color: #7E5523; background: #7E5523; }
  #appView #medicalWorkspace .sent-record-nav .sent-record-advice[aria-pressed="true"] { outline: 2px solid #EFE2CC; }

  /* Popup bảng thu thập thông tin y tế: bo 16, đầu 17/700, chân cố định */
  #appView :is(#intakeDialog, #hubIntakeDialog) { --q-bronze: #9A6A2E; --q-deep: #6E4A1C; --q-line: #EFE9DD; width: min(880px, calc(100vw - 32px)); border-radius: 16px; background: #fff; box-shadow: 0 8px 24px rgba(57, 46, 34, .12); }
  #appView :is(#intakeDialog, #hubIntakeDialog)::backdrop { background: rgba(37, 33, 28, .45); backdrop-filter: none; }
  #appView :is(#intakeDialog, #hubIntakeDialog) .intake-dialog-head { background: #fff; }
  #appView :is(#intakeDialog, #hubIntakeDialog) .intake-dialog-head h2 { font-size: 17px; font-weight: 700; letter-spacing: 0; text-transform: none; color: #25211C; }
  #appView :is(#intakeDialog, #hubIntakeDialog) .intake-dialog-head h2::before { content: none; }
  #appView :is(#intakeDialog, #hubIntakeDialog) .intake-dialog-head button { border-radius: 10px; font-weight: 600; }
  #appView :is(#intakeDialog, #hubIntakeDialog) #ttyt_ocr { border-color: #9A6A2E; font-weight: 600; }
  #appView :is(#intakeDialog, #hubIntakeDialog) #ttyt_ocr:hover { background: #FAF1E1; }
  #appView :is(#intakeDialog, #hubIntakeDialog) .ttyt-nav { background: rgba(255, 255, 255, .97); backdrop-filter: none; }
  #appView :is(#intakeDialog, #hubIntakeDialog) .ttyt-nav button { color: #6F655A; font-weight: 600; }
  #appView :is(#intakeDialog, #hubIntakeDialog) .ttyt-nav button + button::before { background: #EFE9DD; }
  #appView :is(#intakeDialog, #hubIntakeDialog) .ttyt-nav button:hover { background: #FAF7F2; color: #25211C; }
  #appView :is(#intakeDialog, #hubIntakeDialog) .ttyt-step-no { border-color: #E4DACA; font-weight: 700; }
  #appView :is(#intakeDialog, #hubIntakeDialog) .ttyt-nav button[aria-pressed="true"] { background: #EFE2CC; color: #6E4A1C; box-shadow: none; }
  #appView :is(#intakeDialog, #hubIntakeDialog) .ttyt-nav button[aria-pressed="true"] .ttyt-step-no { border-color: #9A6A2E; background: #9A6A2E; }
  #appView :is(#intakeDialog, #hubIntakeDialog) .ttyt-ocr-count { background: #C2362B; font-weight: 700; }
  #appView :is(#intakeDialog, #hubIntakeDialog) .ttyt-intro { display: none; }
  #appView :is(#intakeDialog, #hubIntakeDialog) [data-ttyt-panel] > h3 { font-size: 16px; font-weight: 700; color: #25211C; }
  #appView :is(#intakeDialog, #hubIntakeDialog) .ttyt-section { border-color: #E4DACA; border-radius: 16px; box-shadow: none; }
  #appView :is(#intakeDialog, #hubIntakeDialog) .ttyt-section > h3 { border-bottom-color: #EFE9DD; font-size: 14px; font-weight: 700; color: #25211C; }
  #appView :is(#intakeDialog, #hubIntakeDialog) .ttyt-grid label { font-weight: 600; color: #25211C; }
  #appView :is(#intakeDialog, #hubIntakeDialog) .ttyt-grid :is(input:not([type=radio]):not([type=checkbox]), select, textarea), #appView :is(#intakeDialog, #hubIntakeDialog) .ttyt-delivery-opt > .field textarea { border-color: #E4DACA; }
  #appView :is(#intakeDialog, #hubIntakeDialog) .ttyt-grid :is(input:not([type=radio]):not([type=checkbox]), select, textarea):focus { border-color: #9A6A2E; box-shadow: 0 0 0 3px rgba(154, 106, 46, .18); }
  #appView :is(#intakeDialog, #hubIntakeDialog) :is([data-ttyt-panel="2"], [data-ttyt-panel="3"]) .ttyt-section:has(option[value="yes"]:checked) { border-color: #F3C9C4; background: #FFF8F7; }
  #appView :is(#intakeDialog, #hubIntakeDialog) :is([data-ttyt-panel="2"], [data-ttyt-panel="3"]) .ttyt-section:has(option[value="yes"]:checked) > h3 { color: #9B2F23; }
  #appView :is(#intakeDialog, #hubIntakeDialog) :is([data-ttyt-panel="2"], [data-ttyt-panel="3"]) select:has(option[value="yes"]:checked) { border-color: #9B2F23; color: #9B2F23; }
  #appView :is(#intakeDialog, #hubIntakeDialog) :is([data-ttyt-panel="2"], [data-ttyt-panel="3"]) select:has(option[value="no"]:checked) { border-color: #B7D8BE; color: #1F5E2E; }
  #appView :is(#intakeDialog, #hubIntakeDialog) .ttyt-delivery-opt { border-color: #E4DACA; }
  #appView :is(#intakeDialog, #hubIntakeDialog) .ttyt-delivery-opt:has(input[type=radio]:checked) { border-color: #9A6A2E; background: #FAF1E1; }
  #appView :is(#intakeDialog, #hubIntakeDialog) #ttyt_signatureCanvas { border-color: #E4DACA; }
  #appView :is(#intakeDialog, #hubIntakeDialog) .ttyt-actions { background: #fff; box-shadow: none; }
}

/* ==========================================================================
   Bản in "Hồ sơ sức khỏe khách hàng" (nút In hồ sơ) — A4 dọc, theo mẫu bản in phiên tư vấn.
   ========================================================================== */
@page mpr { size: A4 portrait; margin: 0; }   /* lề nằm trong #printRoot (app.css --pm, 14/11/2026) */
@media print {
  /* Trang in riêng A4 dọc (không theo khổ ngang của bản in báo cáo nhân viên / bảng công). */
  #printRoot .mpr { page: mpr; width: auto; max-width: 186mm; margin: 0 auto; }
  #printRoot .mpr table { table-layout: fixed; }
  #printRoot .mpr :is(td, th, dd, p, div) { overflow-wrap: anywhere; }
  #printRoot .mpr-care table { table-layout: auto; }
  #printRoot .mpr { color: #111; font-family: 'Plus Jakarta Sans', 'Inter', Arial, sans-serif; font-size: 9.5pt; line-height: 1.45; }
  #printRoot .mpr * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  #printRoot .mpr-head { margin-bottom: 10px; padding-bottom: 8px; border-bottom: 3px double #a9783a; text-align: center; }
  #printRoot .mpr-banner { display: block; width: 100%; height: auto; margin: 0 0 8px; }
  #printRoot .mpr-head h1 { margin: 0; font-size: 15pt; font-weight: 800; letter-spacing: .03em; text-transform: uppercase; color: #1f1f1f; }
  #printRoot .mpr-head p { margin: 2px 0 0; font-size: 8.5pt; color: #444; }
  /* Mục đánh số */
  /* Mục được chảy sang trang sau (không nhảy cả khối để lại nửa trang trắng); chỉ khối nhỏ mới giữ nguyên. */
  #printRoot .mpr-sec { margin: 0 0 11px; break-inside: auto; }
  #printRoot .mpr-sec > h2 + * { break-before: avoid; }
  #printRoot :is(.mpr-kv > div, .mpr-flags, .mpr-vitals, .mpr-problems .mpr-item, .mpr-cond td > div) { break-inside: avoid; }
  #printRoot .mpr-problems tr { break-inside: auto; }
  #printRoot .mpr-sec > h2 { display: flex; align-items: center; gap: 7px; margin: 0 0 6px; padding: 4px 0 3px; border-bottom: 1.5px solid #a9783a; font-size: 10.5pt; font-weight: 800; letter-spacing: .02em; text-transform: uppercase; color: #8a5f2a; break-after: avoid; }
  #printRoot .mpr-sec > h2 > span { display: inline-grid; place-items: center; width: 17px; height: 17px; border-radius: 50%; background: #a9783a; color: #fff; font-size: 8.5pt; }
  #printRoot .mpr h3 { margin: 8px 0 4px; font-size: 9.5pt; font-weight: 800; color: #1f1f1f; break-after: avoid; }
  #printRoot .mpr p { margin: 0 0 3px; }
  #printRoot .mpr-sub { color: #444; font-size: 8.5pt; }
  #printRoot .mpr-line { margin-top: 4px; }
  #printRoot .mpr-muted, #printRoot .mpr-na { color: #777; }
  #printRoot .mpr-red { color: #b3261e; }
  /* Thông tin khách: lưới 2 cột nhãn | giá trị */
  #printRoot .mpr-kv { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; margin: 0; }
  #printRoot .mpr-kv > div { display: grid; grid-template-columns: 30mm minmax(0, 1fr); gap: 6px; padding: 2.5px 0; border-bottom: 1px dotted #d6d0c6; }
  #printRoot .mpr-kv > div.wide { grid-column: 1 / -1; }
  #printRoot .mpr-kv dt { color: #555; }
  #printRoot .mpr-kv dd { margin: 0; overflow-wrap: anywhere; }
  #printRoot .mpr-flags { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; margin-top: 7px; }
  #printRoot .mpr-flag { padding: 5px 8px; border: 1px solid #ddd; border-left-width: 3px; border-radius: 4px; font-size: 8.5pt; }
  #printRoot .mpr-flag b { display: block; font-size: 7.5pt; letter-spacing: .06em; text-transform: uppercase; }
  #printRoot .mpr-flag.is-crit { border-color: #e8a19a; border-left-color: #b3261e; background: #fdf0ee; color: #7a1a14; }
  #printRoot .mpr-flag.is-warn { border-color: #f0cfa6; border-left-color: #a2560b; background: #fff6ea; color: #6b3a07; }
  #printRoot .mpr-flag.is-info { border-color: #d9c6a5; border-left-color: #a9783a; background: #fbf7f0; }
  #printRoot .mpr-flag.is-none { color: #555; background: #fafafa; }
  /* Chỉ số sức khỏe: hàng ô */
  #printRoot .mpr-vitals { display: grid; grid-template-columns: repeat(auto-fit, minmax(24mm, 1fr)); border: 1px solid #d9c6a5; border-radius: 4px; }
  #printRoot .mpr-vitals > div { padding: 4px 6px; border-left: 1px solid #ece3d4; text-align: center; }
  #printRoot .mpr-vitals > div:first-child { border-left: 0; }
  #printRoot .mpr-vitals span { display: block; font-size: 7.5pt; color: #666; text-transform: uppercase; letter-spacing: .04em; }
  #printRoot .mpr-vitals b { font-size: 10.5pt; }
  /* Bảng câu hỏi, bệnh, xét nghiệm */
  #printRoot .mpr table { width: 100%; border-collapse: collapse; font-size: 8.8pt; }
  #printRoot .mpr th, #printRoot .mpr td { white-space: normal; padding: 3px 5px; border: 1px solid #d6d0c6; vertical-align: top; text-transform: none; letter-spacing: 0; }
  #printRoot .mpr thead th { background: #f4ede2; color: #3f3a33; font-size: 8pt; font-weight: 800; text-align: center; }
  #printRoot .mpr tr { break-inside: avoid; }
  #printRoot .mpr-qa th { width: 58%; background: #fbf8f3; color: #333; font-weight: 500; text-align: left; font-size: 8.6pt; }
  #printRoot .mpr-cond td:first-child { width: 32%; color: #7a1a14; }
  #printRoot .mpr-cond td div span { color: #555; }
  #printRoot .mpr-lab td { text-align: center; }
  #printRoot .mpr-lab td:first-child { text-align: left; }
  #printRoot .mpr-lab td.num { white-space: nowrap; }
  #printRoot .mpr-lab .mpr-old-unit { font-size: 8.5pt; font-style: italic; }   /* lần trước khác đơn vị */
  #printRoot .mpr-lab tr.mpr-missing td { color: #444; }   /* chỉ số lần này không làm */
  #printRoot .mpr-lab .mpr-nt { font-size: 7.8pt; white-space: nowrap; }   /* "Không XN" gọn một dòng */
  /* Bảng 3 lần xét nghiệm: chữ nhỏ hơn, ô được xuống dòng để không tràn khổ A4. */
  #printRoot .mpr-lab3 { font-size: 8.3pt; }
  #printRoot .mpr-lab3 th { font-size: 7.8pt; padding-left: 3px; padding-right: 3px; }
  #printRoot .mpr-lab3 td { padding-left: 3px; padding-right: 3px; overflow-wrap: anywhere; }
  #printRoot .mpr-lab3 td.num { white-space: normal; }
  #printRoot .mpr-lab3 .mpr-old-unit { font-size: 7.6pt; }
  #printRoot .mpr-lab .mpr-trend { font-size: 8pt; font-weight: 800; }
  #printRoot .fd-print-blood .record-table table { table-layout: fixed; }
  #printRoot .fd-print-blood .record-table th:nth-child(1) { width: 22%; } #printRoot .fd-print-blood .record-table th:nth-child(2) { width: 10%; }
  #printRoot .fd-print-blood .record-table th:nth-child(3) { width: 13%; } #printRoot .fd-print-blood .record-table th:nth-child(4) { width: 18%; }
  #printRoot .fd-print-blood .record-table th:nth-child(5) { width: 22%; } #printRoot .fd-print-blood .record-table th:nth-child(6) { width: 15%; }
  /* Song ngữ (Hồ sơ đầy đủ KH): tiếng Nhật nhỏ ngay dưới từng ô / dòng / đoạn tiếng Việt */
  #printRoot .mpr-ja-in { display: inline-block; margin-top: 1px; color: #333; font-size: 7.6pt; font-weight: 500; font-style: normal; line-height: 1.25; }
  #printRoot .mpr-lab tr.abn .mpr-ja-in, #printRoot tr.abn .mpr-ja-in { color: #b3261e; }
  #printRoot .mpr-care .mpr-ja-in { display: inline; color: #444; }
  #printRoot .mpr-problems .mpr-item + .mpr-item { margin-top: 3px; }
  #printRoot .mpr-sec h2 small.mpr-ja { margin-left: 6px; font-size: 9pt; font-weight: 600; text-transform: none; letter-spacing: 0; }
  #printRoot .mpr-lab .mpr-panel td { background: #f4ede2; font-size: 8pt; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; color: #8a5f2a; }
  #printRoot .mpr-lab tr.abn td { font-weight: 700; color: #b3261e; }
  #printRoot .mpr-lab tr.abn.crit td { background: #fdf0ee; }
  /* Bảng tư vấn CSYT nguyên văn */
  #printRoot .mpr-care { font-size: 9pt; line-height: 1.5; }
  #printRoot .mpr-care :is(h1, h2, h3, h4, h5, h6) { margin: 7px 0 3px; font-size: 9.5pt; font-weight: 800; color: #8a5f2a; text-transform: none; border: 0; break-after: avoid; }
  #printRoot .mpr-care p { margin: 0 0 3px; }
  #printRoot .mpr-care ul, #printRoot .mpr-care ol { margin: 2px 0 4px 16px; padding: 0; }
  #printRoot .mpr-care img { max-width: 100%; max-height: 70mm; }
  #printRoot .mpr-care table { margin: 4px 0; }
  /* Ý kiến chuyên gia: tiếng Việt trên, tiếng Nhật dưới */
  #printRoot .mpr-bi { margin: 0 0 6px; break-inside: avoid; }
  #printRoot .mpr-bi > b { display: block; color: #8a5f2a; }
  #printRoot .mpr-bi p { white-space: pre-wrap; }
  #printRoot .mpr-ja { color: #333; }
  /* Ký và chân trang */
  #printRoot .mpr-sign { display: grid; grid-template-columns: 1fr 1fr; gap: 20mm; margin: 14px 0 0; text-align: center; break-inside: avoid; }
  #printRoot .mpr-sign span { display: block; font-size: 8.5pt; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; }
  #printRoot .mpr-sign b { display: block; margin-top: 16mm; font-size: 10pt; color: #8a5f2a; }
  #printRoot .mpr-foot { margin-top: 12px; padding-top: 6px; border-top: 1px solid #ddd; font-size: 7.5pt; line-height: 1.5; color: #666; }
  /* In ra giấy: mọi chữ phụ (xám) chuyển sang đen cho rõ; chỉ giữ màu đỏ cảnh báo và màu đồng ở tiêu đề. */
  #printRoot .mpr, #printRoot .mpr :is(p, dt, dd, td, th, span, small, li, div, footer),
  #printRoot .mpr :is(.mpr-sub, .mpr-muted, .mpr-na, .mpr-head p, .mpr-kv dt, .mpr-vitals span, .mpr-cond td div span, .mpr-qa th, .mpr-ja, .mpr-foot, .mpr-flag.is-none) { color: #000; }
  #printRoot .mpr .mpr-red, #printRoot .mpr tr.abn td, #printRoot .mpr .mpr-cond td:first-child, #printRoot .mpr .mpr-flag.is-crit, #printRoot .mpr .mpr-flag.is-crit span { color: #b3261e; }
  #printRoot .mpr .mpr-flag.is-warn, #printRoot .mpr .mpr-flag.is-warn span { color: #6b3a07; }
  #printRoot .mpr .mpr-sec > h2 > span { color: #fff; }
  #printRoot .mpr :is(.mpr-qa th, .mpr-kv dt, .mpr-cond td div span) { font-weight: 500; }
  #printRoot .mpr th, #printRoot .mpr td { border-color: #b9b2a6; }
  #printRoot .mpr .mpr-problems th { width: 26%; }
  #printRoot .mpr .mpr-problems tr.abn th, #printRoot .mpr .mpr-problems tr.abn th small { color: #b3261e; }
  #printRoot .mpr .mpr-docs td:first-child { width: 17mm; white-space: nowrap; }
  #printRoot .mpr .mpr-docs td:nth-child(2) { width: 28%; } #printRoot .mpr .mpr-docs td:nth-child(3) { width: 22%; }
  #printRoot .mpr .mpr-docs tr.abn td { background: #fdf3f1; }
  /* Nội dung hồ sơ đã gửi (bản in phiên tư vấn): dòng tiếng Việt trên, tiếng Nhật ngay dưới */
  #printRoot .mpr .mpr-record { font-size: 9pt; line-height: 1.45; color: #000; }
  #printRoot .mpr .mpr-record h3 { margin: 8px 0 3px; padding: 0 0 2px; border-bottom: 1px solid #e3dccf; font-size: 9.5pt; font-weight: 800; color: #8a5f2a; break-after: avoid; }
  #printRoot .mpr .mpr-record h3.record-question { border: 0; color: #000; font-size: 9pt; }
  #printRoot .mpr .mpr-record .record-answer { margin: 0; padding: 2.5px 0; border: 0; border-bottom: 1px dotted #cfc8bc; border-radius: 0; background: none; break-inside: avoid; }
  #printRoot .mpr .mpr-record .record-vi, #printRoot .mpr .mpr-record .record-ja { display: block; color: #000; }
  #printRoot .mpr .mpr-record .record-ja { margin-top: 1px; font-size: 8.6pt; }
  #printRoot .mpr .mpr-record :is(.record-vi, .record-ja):has(> .record-question), #printRoot .mpr .mpr-record .record-answer:has(> .record-question) { display: grid; grid-template-columns: 42% minmax(0, 1fr); gap: 0 8px; }
  #printRoot .mpr .mpr-record .record-question { color: #000; font-weight: 500; }
  #printRoot .mpr .mpr-record .record-response { color: #000; font-weight: 700; }
  #printRoot .mpr .mpr-record .record-high td:last-child, #printRoot .mpr .mpr-record .record-high td:last-child :is(.record-vi, .record-ja) { color: #b3261e; font-weight: 800; }
  #printRoot .mpr .mpr-record .record-table { margin: 4px 0; overflow: visible; }
  #printRoot .mpr .mpr-record .record-table td, #printRoot .mpr .mpr-record .record-table th { text-align: center; }
  #printRoot .mpr .mpr-record .record-table td:first-child { text-align: left; }
  #printRoot .mpr .mpr-record section.record-ja { margin-top: 8px; padding-top: 6px; border-top: 1px solid #cfc8bc; }
  #printRoot .mpr .mpr-record .record-split > .record-table.record-ja { margin-top: 2px; }
}

/* ==========================================================================
   Chuẩn bị phiên tư vấn cùng chuyên gia (#consultDialog), xác nhận gửi (#consultConfirmDialog)
   và popup tiến độ dịch/gửi (.cp-dialog — gắn vào body, chỉ trang Sales tải file này).
   ========================================================================== */
@media screen {
  #appView :is(#consultDialog, #consultConfirmDialog) { --q-bronze: #a9783a; --q-deep: #8a5f2a; --q-line: #e4dccf; border: 0; border-radius: 18px; background: #faf7f2; color: #0a0a0a; box-shadow: 0 30px 90px rgba(20, 16, 10, .35); }
  #appView #consultDialog { width: min(1000px, calc(100vw - 32px)); }
  #appView #consultConfirmDialog { width: min(560px, calc(100vw - 32px)); }
  #appView :is(#consultDialog, #consultConfirmDialog)::backdrop { background: rgba(28, 22, 15, .55); backdrop-filter: blur(2px); }
  #appView :is(#consultDialog, #consultConfirmDialog) .intake-dialog-head { box-sizing: border-box; min-height: 56px; padding: 10px 22px; border-bottom: 1px solid var(--q-line); background: linear-gradient(105deg, #f8efe1, #fff 70%); }
  #appView :is(#consultDialog, #consultConfirmDialog) .intake-dialog-head h2 { display: flex; align-items: center; gap: 10px; font-size: 15px; font-weight: 800; letter-spacing: .02em; color: var(--q-deep); }
  #appView :is(#consultDialog, #consultConfirmDialog) .intake-dialog-head h2::before { content: ""; width: 4px; height: 18px; border-radius: 2px; background: var(--q-bronze); }
  #appView #consultDialog .intake-dialog-head button { min-height: 34px; padding: 0 14px; border-radius: 10px; font-weight: 700; }
  #appView #consultDialog > .panel-body { padding: 14px 22px 0; }
  /* 3 bước đánh số */
  #appView #consultDialog .cx-step { margin: 0 0 12px; padding: 14px 16px; border: 1px solid var(--q-line); border-radius: 14px; background: #fff; box-shadow: 0 1px 2px rgba(20, 16, 10, .04); }
  #appView #consultDialog .cx-step > h3 { display: flex; align-items: center; gap: 9px; margin: 0 0 10px; font-size: 14px; font-weight: 800; color: #0a0a0a; }
  #appView #consultDialog .cx-step > h3 > span { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--q-bronze); color: #fff; font-size: 12px; }
  #appView #consultDialog .consult-topic-field { margin: 0; }
  #appView #consultDialog :is(.consult-topic-field input, #specSel, .consult-document select) { width: 100%; min-height: 42px; border: 1px solid #d9cdbb; border-radius: 10px; background: #fff; font-size: 14px; }
  #appView #consultDialog :is(.consult-topic-field input, #specSel, .consult-document select):focus { border-color: var(--q-bronze); outline: 0; box-shadow: 0 0 0 3px rgba(169, 120, 58, .18); }
  #appView #consultDialog .consult-topic-field .small { margin-top: 6px; color: #5b524a; }
  /* Hồ sơ gửi kèm: 3 thẻ gọn (bỏ khung vuông cao) */
  #appView #consultDialog .consult-documents { gap: 10px; margin: 0; }
  #appView #consultDialog .consult-document { aspect-ratio: auto; gap: 8px; padding: 12px; border: 1.5px dashed #d9c6a5; border-radius: 12px; background: #fdfbf8; transition: border-color .15s, background .15s; }
  #appView #consultDialog .consult-document > label { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 13.5px; font-weight: 800; color: #0a0a0a; }
  #appView #consultDialog .cx-doc-ic { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; background: #f6efe5; color: var(--q-deep); }
  #appView #consultDialog .consult-document-preview { flex: none; min-height: 0; flex-direction: row; justify-content: flex-start; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 8px; background: #f3efe8; color: #8a8078; text-align: left; }
  #appView #consultDialog .consult-document-preview svg { flex: none; opacity: .35; }
  #appView #consultDialog .consult-document-preview strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12.5px; font-weight: 600; }
  #appView #consultDialog .consult-document.is-selected { border-style: solid; border-color: var(--q-bronze); background: #fff; }
  #appView #consultDialog .consult-document.is-selected .consult-document-preview { background: #eef8f1; color: #15713f; }
  #appView #consultDialog .consult-document.is-selected .consult-document-preview svg { opacity: 1; }
  #appView #consultDialog .consult-document .small.muted { margin: 0; font-size: 12px; }
  /* Dịch sang tiếng Nhật: công tắc */
  #appView #consultDialog .consult-translate { margin: 2px 0 0; font-size: 12.5px; font-weight: 600; color: #3f3a33; cursor: pointer; }
  #appView #consultDialog .consult-translate input[type="checkbox"] { appearance: none; -webkit-appearance: none; position: relative; flex: 0 0 34px; width: 34px; height: 20px; border-radius: 99px; background: #d9d3c9; cursor: pointer; transition: background .15s; }
  #appView #consultDialog .consult-translate input[type="checkbox"]::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .25); transition: transform .15s; }
  #appView #consultDialog .consult-translate input[type="checkbox"]:checked { background: var(--q-bronze); }
  #appView #consultDialog .consult-translate input[type="checkbox"]:checked::after { transform: translateX(14px); }
  #appView #consultDialog .consult-translate input:disabled { opacity: .55; cursor: default; }
  /* Chân hộp thoại dính đáy */
  #appView #consultDialog .cx-foot { position: sticky; bottom: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 4px -22px 0; padding: 12px 22px; border-top: 1px solid var(--q-line); background: rgba(255, 255, 255, .97); box-shadow: 0 -6px 18px rgba(20, 16, 10, .06); }
  #appView #consultDialog .cx-foot p { display: flex; align-items: center; gap: 6px; margin: 0; color: #5b524a; }
  #appView #consultDialog .cx-foot p svg { flex: none; color: #a2560b; }
  #appView #consultDialog #sendConsultBtn { flex: none; display: inline-flex; align-items: center; gap: 8px; min-height: 42px; padding: 0 20px; border-radius: 10px; font-weight: 800; }
  /* Xác nhận gửi */
  #appView #consultConfirmDialog > .panel-body { padding: 16px 22px 18px; }
  #appView #consultConfirmDialog .consult-confirm-items { gap: 8px; }
  #appView #consultConfirmDialog .consult-confirm-items > div { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 12px; padding: 10px 12px; border: 1px solid var(--q-line); border-radius: 10px; background: #fff; }
  #appView #consultConfirmDialog .consult-confirm-items dt { margin: 0; font-size: 12.5px; color: #5b524a; }
  #appView #consultConfirmDialog .consult-confirm-items dd { font-weight: 700; }
  #appView #consultConfirmDialog .consult-confirm-items ul { gap: 3px; padding-left: 16px; }
  #appView #consultConfirmDialog .consult-confirm-note { padding: 8px 12px; border-radius: 8px; background: #fff4e0; color: #6b3a07; }
  #appView #consultConfirmDialog .btn-row { justify-content: flex-end; margin-top: 14px; }
  #appView #consultConfirmDialog .btn-row button { min-height: 40px; padding: 0 18px; border-radius: 10px; font-weight: 700; }
  @media (max-width: 720px) {
    #appView #consultDialog > .panel-body { padding: 12px 14px 0; }
    #appView #consultDialog .cx-foot { flex-direction: column; align-items: stretch; margin: 4px -14px 0; padding: 10px 14px; }
    #appView #consultConfirmDialog .consult-confirm-items > div { grid-template-columns: 1fr; gap: 4px; }
  }

  /* Popup tiến độ dịch bằng AI và gửi hồ sơ */
  body:has(#appView:not([hidden])) .cp-dialog { width: min(520px, calc(100vw - 32px)); padding: 0; border: 0; border-radius: 18px; background: #fff; color: #0a0a0a; box-shadow: 0 30px 90px rgba(20, 16, 10, .4); overflow: hidden; }
  body:has(#appView:not([hidden])) .cp-dialog::backdrop { background: rgba(28, 22, 15, .6); backdrop-filter: blur(3px); }
  body:has(#appView:not([hidden])) .cp-dialog h2 { display: flex; align-items: center; gap: 10px; margin: 0; padding: 18px 22px 14px; border-bottom: 1px solid #efe8dc; background: linear-gradient(105deg, #f8efe1, #fff 70%); font-size: 15.5px; font-weight: 800; color: #8a5f2a; }
  body:has(#appView:not([hidden])) .cp-dialog h2::before { content: "AI"; display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; background: linear-gradient(135deg, #c4955a, #8a5f2a); color: #fff; font-size: 11px; font-weight: 800; letter-spacing: .04em; }
  body:has(#appView:not([hidden])) .cp-dialog .cp-meta { order: -1; display: flex; align-items: flex-end; justify-content: space-between; margin: 18px 22px 8px; }
  body:has(#appView:not([hidden])) .cp-dialog { display: none; }
  body:has(#appView:not([hidden])) .cp-dialog[open] { display: flex; flex-direction: column; }
  body:has(#appView:not([hidden])) .cp-dialog h2 { order: -2; }
  body:has(#appView:not([hidden])) .cp-dialog .cp-pct { font-size: 34px; font-weight: 800; line-height: 1; color: #0a0a0a; font-variant-numeric: tabular-nums; }
  body:has(#appView:not([hidden])) .cp-dialog .cp-eta { padding: 4px 10px; border-radius: 99px; background: #f6efe5; color: #8a5f2a; font-size: 12.5px; font-weight: 700; }
  body:has(#appView:not([hidden])) .cp-dialog .cp-bar { margin: 0 22px 16px; height: 10px; background: #efe8dc; }
  body:has(#appView:not([hidden])) .cp-dialog .cp-bar i { background: linear-gradient(90deg, #c4955a, #a9783a, #c4955a); background-size: 200% 100%; animation: cp-shine 1.6s linear infinite; }
  body:has(#appView:not([hidden])) .cp-dialog .cp-steps { gap: 0; margin: 0 22px; padding: 4px 0; border: 1px solid #efe8dc; border-radius: 12px; }
  body:has(#appView:not([hidden])) .cp-dialog .cp-steps li { padding: 9px 14px 9px 44px; color: #8a8078; font-size: 13.5px; line-height: 20px; border-bottom: 1px solid #f4efe6; }
  body:has(#appView:not([hidden])) .cp-dialog .cp-steps li:last-child { border-bottom: 0; }
  body:has(#appView:not([hidden])) .cp-dialog .cp-steps li::before { left: 14px; top: 10px; width: 14px; height: 14px; border-color: #d9d3c9; }
  body:has(#appView:not([hidden])) .cp-dialog .cp-steps li.is-active { background: #fbf6ee; color: #0a0a0a; font-weight: 700; }
  body:has(#appView:not([hidden])) .cp-dialog .cp-steps li.is-active::before { border-color: #a9783a; border-right-color: transparent; }
  body:has(#appView:not([hidden])) .cp-dialog .cp-steps li.is-done { color: #2a2520; }
  body:has(#appView:not([hidden])) .cp-dialog .cp-steps li.is-done::before { border-color: #15803d; background: #15803d; color: #fff; }
  body:has(#appView:not([hidden])) .cp-dialog .cp-note { margin: 12px 22px 18px; padding: 8px 12px; border-radius: 8px; background: #fff4e0; color: #6b3a07; font-size: 12.5px; }
  @keyframes cp-shine { to { background-position: -200% 0; } }
  @media (prefers-reduced-motion: reduce) { body:has(#appView:not([hidden])) .cp-dialog .cp-bar i { animation: none; } }
}

/* ==========================================================================
   Hồ sơ đã gửi chuyên gia: dòng tóm tắt trong thẻ phiên tư vấn + hộp thoại xem toàn bộ (#sentDialog)
   ========================================================================== */
@media screen {
  #appView #medicalWorkspace .sent-open { display: flex; align-items: center; gap: 12px; margin-top: 10px; padding: 10px 12px; border: 1px solid #e4dccf; border-radius: 12px; background: #fdfbf8; }
  #appView #medicalWorkspace .sent-open-ic { flex: none; display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; background: #f6efe5; color: #8a5f2a; }
  #appView #medicalWorkspace .sent-open > div { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
  #appView #medicalWorkspace .sent-open b { font-size: 13.5px; color: #0a0a0a; }
  #appView #medicalWorkspace .sent-open small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #5b524a; font-size: 12px; }
  #appView #medicalWorkspace .sent-open button { flex: none; min-height: 36px; padding: 0 14px; border: 1px solid #a9783a; border-radius: 10px; background: #fff; color: #8a5f2a; font-weight: 700; }
  #appView #medicalWorkspace .sent-open button:hover { background: #f6efe5; }
  #appView #medicalWorkspace .consult-result-notice button { flex: none; border-radius: 10px; font-weight: 700; }

  #appView :is(#sentDialog, #fdViewDialog) { --q-bronze: #a9783a; --q-deep: #8a5f2a; --q-line: #e4dccf; width: min(1180px, calc(100vw - 32px)); height: min(88dvh, 900px); max-height: calc(100dvh - 32px); padding: 0; border: 0; border-radius: 18px; background: #faf7f2; color: #0a0a0a; box-shadow: 0 30px 90px rgba(20, 16, 10, .35); overflow: hidden; }
  #appView :is(#sentDialog, #fdViewDialog)[open] { display: flex; flex-direction: column; }
  #appView :is(#sentDialog, #fdViewDialog)::backdrop { background: rgba(28, 22, 15, .55); backdrop-filter: blur(2px); }
  #appView :is(#sentDialog, #fdViewDialog) .intake-dialog-head { position: static; flex: none; min-height: 60px; padding: 10px 22px; border-bottom: 1px solid var(--q-line); background: linear-gradient(105deg, #f8efe1, #fff 70%); }
  #appView :is(#sentDialog, #fdViewDialog) .intake-dialog-head > div { min-width: 0; }
  #appView :is(#sentDialog, #fdViewDialog) .intake-dialog-head h2 { display: flex; align-items: center; gap: 10px; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15px; font-weight: 800; color: var(--q-deep); }
  #appView :is(#sentDialog, #fdViewDialog) .intake-dialog-head h2::before { content: ""; flex: none; width: 4px; height: 18px; border-radius: 2px; background: var(--q-bronze); }
  #appView :is(#sentDialog #sentDialogMeta, #fdViewDialog #fdViewMeta) { margin: 2px 0 0 14px; color: #5b524a; font-size: 12.5px; }
  #appView :is(#sentDialog, #fdViewDialog) .intake-dialog-head button { flex: none; min-height: 34px; padding: 0 14px; border-radius: 10px; font-weight: 700; }
  /* Bố cục: danh mục bên trái, nội dung cuộn bên phải */
  #appView :is(#sentDialog, #fdViewDialog) .sent-records { flex: 1; min-height: 0; height: auto; margin: 0; padding: 0; border: 0; border-radius: 0; grid-template-columns: 230px minmax(0, 1fr); gap: 0; }
  #appView :is(#sentDialog, #fdViewDialog) .sent-record-nav { gap: 4px; padding: 14px 12px; border-right: 1px solid var(--q-line); background: #f6f1e9; overflow: auto; }
  #appView :is(#sentDialog, #fdViewDialog) .sent-record-nav button { justify-content: flex-start; gap: 10px; min-height: 44px; padding: 0 12px; border: 0; border-radius: 10px; background: transparent; box-shadow: none; color: #3f3a33; font-size: 13.5px; font-weight: 700; text-align: left; }
  #appView :is(#sentDialog, #fdViewDialog) .sent-record-nav button svg { flex: none; color: #8a5f2a; }
  #appView :is(#sentDialog, #fdViewDialog) .sent-record-nav button:hover { background: #efe6d8; color: #0a0a0a; }
  #appView :is(#sentDialog, #fdViewDialog) .sent-record-nav button[aria-pressed="true"] { background: #fff; color: var(--q-deep); box-shadow: 0 1px 3px rgba(20, 16, 10, .12), inset 3px 0 var(--q-bronze); }
  #appView :is(#sentDialog, #fdViewDialog) .sent-record-nav .sent-record-advice { margin-top: 8px; border: 1px solid #b4e0c1; background: #eef8f1; color: #15713f; }
  #appView :is(#sentDialog, #fdViewDialog) .sent-record-nav .sent-record-advice svg { color: #15713f; }
  #appView :is(#sentDialog, #fdViewDialog) .sent-record-content { padding: 18px 24px 28px; border: 0; background: #fff; overflow: auto; }
  /* Nội dung hồ sơ: tiêu đề mục, hàng hỏi–đáp, tiếng Nhật nhỏ bên dưới */
  #appView :is(#sentDialog, #fdViewDialog) .record-detail { font-size: 13.5px; line-height: 1.55; color: #0a0a0a; }
  #appView :is(#sentDialog, #fdViewDialog) .record-detail h3 { margin: 18px 0 8px; padding-bottom: 6px; border-bottom: 1px solid #efe7da; font-size: 14px; font-weight: 800; color: var(--q-deep); }
  #appView :is(#sentDialog, #fdViewDialog) .record-detail h3:first-child { margin-top: 0; font-size: 15.5px; }
  #appView :is(#sentDialog, #fdViewDialog) .record-detail h3.record-question { margin: 12px 0 4px; padding: 0; border: 0; font-size: 13.5px; color: #0a0a0a; }
  #appView :is(#sentDialog, #fdViewDialog) .record-detail .record-answer { margin: 0; padding: 7px 12px; border: 0; border-bottom: 1px dashed #efe7da; border-radius: 0; background: transparent; }
  #appView :is(#sentDialog, #fdViewDialog) .record-detail .record-answer:nth-of-type(odd) { background: #fdfbf8; }
  /* Hỏi | đáp thẳng cột */
  #appView :is(#sentDialog, #fdViewDialog) .record-detail .record-answer:has(> .record-question),
  #appView :is(#sentDialog, #fdViewDialog) .record-detail .record-answer > :is(.record-vi, .record-ja):has(> .record-question) { display: grid; grid-template-columns: minmax(170px, 38%) minmax(0, 1fr); align-items: baseline; gap: 4px 14px; }
  #appView :is(#sentDialog, #fdViewDialog) .record-detail .record-question { color: #3f3a33; font-weight: 500; }
  #appView :is(#sentDialog, #fdViewDialog) .record-detail .record-response { color: #0a0a0a; font-weight: 700; }
  #appView :is(#sentDialog, #fdViewDialog) .record-detail .record-vi { color: #0a0a0a; }
  #appView :is(#sentDialog, #fdViewDialog) .record-detail .record-ja { margin-top: 2px; color: #6b635a; font-size: 12.5px; }
  #appView :is(#sentDialog, #fdViewDialog) .record-detail .record-ja .record-question, #appView :is(#sentDialog, #fdViewDialog) .record-detail .record-ja .record-response { color: #6b635a; }
  #appView :is(#sentDialog, #fdViewDialog) .record-detail section.record-ja { margin-top: 18px; padding-top: 12px; border-top: 2px solid #efe7da; }
  #appView :is(#sentDialog, #fdViewDialog) .record-detail .record-table { margin: 8px 0; overflow: auto; border: 1px solid var(--q-line); border-radius: 10px; }
  #appView :is(#sentDialog, #fdViewDialog) .record-detail .record-table table { width: 100%; min-width: 0; border-collapse: collapse; font-size: 13px; }
  #appView :is(#sentDialog, #fdViewDialog) .record-detail .record-table th { padding: 8px 10px; background: #f4ede2; color: #3f3a33; font-size: 12px; font-weight: 800; text-align: center; }
  #appView :is(#sentDialog, #fdViewDialog) .record-detail .record-table td { padding: 7px 10px; border-top: 1px solid #efe7da; text-align: center; }
  #appView :is(#sentDialog, #fdViewDialog) .record-detail .record-table td:first-child { text-align: left; font-weight: 600; }
  #appView :is(#sentDialog, #fdViewDialog) .record-detail .record-high td { background: #fff6f5; }
  #appView :is(#sentDialog, #fdViewDialog) .record-detail .record-high td:last-child { color: #b3261e; font-weight: 800; }
  #appView :is(#sentDialog, #fdViewDialog) .record-detail hr { margin: 14px 0; border: 0; border-top: 1px solid #efe7da; }
  @media (max-width: 760px) {
    #appView :is(#sentDialog, #fdViewDialog) { height: calc(100dvh - 24px); }
    #appView :is(#sentDialog, #fdViewDialog) .sent-records { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr); }
    #appView :is(#sentDialog, #fdViewDialog) .sent-record-nav { flex-direction: row; overflow-x: auto; padding: 8px; border-right: 0; border-bottom: 1px solid var(--q-line); }
    #appView :is(#sentDialog, #fdViewDialog) .sent-record-nav button { flex: none; min-height: 38px; font-size: 12.5px; }
    #appView :is(#sentDialog, #fdViewDialog) .sent-record-nav .sent-record-advice { margin-top: 0; }
    #appView :is(#sentDialog, #fdViewDialog) .sent-record-content { padding: 14px; }
    #appView #medicalWorkspace .sent-open { flex-wrap: wrap; }
    #appView #medicalWorkspace .sent-open button { width: 100%; }
  }
}

/* ==========================================================================
   Thêm hồ sơ (nhiều bước) + Bộ hồ sơ nhiều loại cần phân tích (#bundleWizard) + tab "Tài liệu y tế"
   ========================================================================== */
@media screen {
  #appView #bundleWizard { --q-bronze: #a9783a; --q-deep: #8a5f2a; --q-line: #e4dccf; width: min(980px, calc(100vw - 32px)); height: min(86dvh, 860px); max-height: calc(100dvh - 32px); padding: 0; border: 0; border-radius: 18px; background: #faf7f2; color: #0a0a0a; box-shadow: 0 30px 90px rgba(20, 16, 10, .35); overflow: hidden; }
  #appView #bundleWizard[open] { display: flex; flex-direction: column; }
  #appView #bundleWizard::backdrop { background: rgba(28, 22, 15, .55); backdrop-filter: blur(2px); }
  #appView #bundleWizard .intake-dialog-head { position: static; flex: none; min-height: 56px; padding: 10px 22px; border-bottom: 1px solid var(--q-line); background: linear-gradient(105deg, #f8efe1, #fff 70%); }
  #appView #bundleWizard .intake-dialog-head h2 { display: flex; align-items: center; gap: 10px; margin: 0; font-size: 15px; font-weight: 800; color: var(--q-deep); }
  #appView #bundleWizard .intake-dialog-head h2::before { content: ""; width: 4px; height: 18px; border-radius: 2px; background: var(--q-bronze); }
  #appView #bundleWizard .intake-dialog-head button { min-height: 34px; padding: 0 14px; border-radius: 10px; font-weight: 700; }
  /* Thanh bước */
  #appView .bw-steps { flex: none; display: flex; gap: 0; margin: 0; padding: 12px 22px; list-style: none; border-bottom: 1px solid var(--q-line); overflow-x: auto; scrollbar-width: none; }
  #appView .bw-steps li { flex: 1; display: flex; align-items: center; gap: 8px; min-width: max-content; padding-right: 14px; color: #8a8078; font-size: 13px; font-weight: 700; white-space: nowrap; }
  #appView .bw-steps li + li::before { content: ""; flex: 0 0 18px; height: 2px; margin-right: 6px; background: #e4d8c6; }
  #appView .bw-steps span { display: inline-grid; place-items: center; flex: none; width: 24px; height: 24px; border: 2px solid #dccdb6; border-radius: 50%; background: #fff; font-size: 11px; font-weight: 800; }
  #appView .bw-steps li.is-done { color: #3f3a33; } #appView .bw-steps li.is-done span { border-color: var(--q-bronze); background: var(--q-bronze); color: #fff; }
  #appView .bw-steps li.is-now { color: var(--q-deep); } #appView .bw-steps li.is-now span { border-color: var(--q-bronze); color: var(--q-deep); box-shadow: 0 0 0 3px #f3e6d2; }
  #appView .bw-body { flex: 1; min-height: 0; overflow: auto; padding: 16px 22px; }
  #appView .bw-foot { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 22px; border-top: 1px solid var(--q-line); background: #fff; }
  #appView .bw-foot:empty { display: none; }
  #appView .bw-foot button { min-height: 40px; padding: 0 18px; border-radius: 10px; font-weight: 700; }
  #appView .bw-foot-note, #appView .bw-hint { color: #5b524a; font-size: 12.5px; }
  #appView .bw-hint { display: flex; align-items: center; gap: 6px; margin: 10px 0 0; }
  /* Bước 1 */
  #appView .bw-seg { display: inline-flex; gap: 2px; margin-bottom: 14px; padding: 3px; border: 1px solid var(--q-line); border-radius: 12px; background: #f6f2ea; }
  #appView .bw-seg button { display: inline-flex; align-items: center; gap: 7px; min-height: 38px; padding: 0 16px; border: 0; border-radius: 9px; background: transparent; box-shadow: none; color: #5b524a; font-weight: 700; }
  #appView .bw-seg button[aria-selected="true"] { background: #fff; color: var(--q-deep); box-shadow: 0 1px 3px rgba(20, 16, 10, .12); }
  #appView .bw-search { display: flex; gap: 8px; margin-bottom: 12px; }
  #appView .bw-search input { flex: 1; min-height: 42px; border-radius: 10px; }
  #appView .bw-results { display: grid; gap: 6px; }
  #appView .bw-cust { display: grid; grid-template-columns: 38px minmax(0, 1fr) auto 20px; align-items: center; gap: 12px; width: 100%; min-height: auto; padding: 10px 12px; border: 1px solid var(--q-line); border-radius: 12px; background: #fff; box-shadow: none; color: inherit; font-weight: 400; text-align: left; }
  #appView .bw-cust:hover { border-color: var(--q-bronze); background: #fdf9f3; }
  #appView .bw-av { display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; background: linear-gradient(135deg, #c4955a, #8a5f2a); color: #fff; font-size: 13px; font-weight: 800; }
  #appView .bw-cust-main { display: flex; flex-direction: column; min-width: 0; }
  #appView .bw-cust-main b { font-size: 14px; } #appView .bw-cust-main small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #5b524a; font-size: 12px; }
  #appView .bw-go { color: #a39a90; }
  #appView .bw-new { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; }
  #appView .bw-new .field { margin: 0; } #appView .bw-new .wide { grid-column: 1 / -1; }
  #appView .bw-new input { width: 100%; min-height: 42px; border-radius: 10px; }
  /* Bước 2 */
  #appView .bw-types { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
  #appView .bw-type { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; min-height: 200px; padding: 20px; border: 1.5px solid var(--q-line); border-radius: 16px; background: #fff; box-shadow: none; color: #0a0a0a; font-weight: 400; text-align: left; transition: border-color .15s, transform .15s; }
  #appView .bw-type:hover { border-color: var(--q-bronze); transform: translateY(-2px); }
  #appView .bw-type b { font-size: 16px; font-weight: 800; }
  #appView .bw-type > span:last-child { color: #5b524a; font-size: 13px; line-height: 1.5; }
  #appView .bw-type-ic { display: inline-grid; place-items: center; width: 52px; height: 52px; border-radius: 14px; background: #f6efe5; color: var(--q-deep); }
  #appView .bw-type.is-bundle { border-color: #d9c6a5; background: linear-gradient(135deg, #fff 55%, #fbf3e6); }
  #appView .bw-type.is-bundle .bw-type-ic { background: var(--q-bronze); color: #fff; }
  #appView .bw-who { display: inline-flex; align-items: center; gap: 6px; color: #5b524a; font-size: 13px; font-weight: 700; }
  /* Bước 3 */
  #appView #bundleWizard .field input { width: 100%; min-height: 42px; border-radius: 10px; }
  #appView .bw-drop { display: flex; flex-direction: column; align-items: center; gap: 6px; margin: 12px 0; padding: 28px 16px; border: 2px dashed #d9c6a5; border-radius: 16px; background: #fff; color: #5b524a; text-align: center; cursor: pointer; transition: border-color .15s, background .15s; }
  #appView .bw-drop:hover, #appView .bw-drop.is-over, #appView .bw-drop:focus-visible { border-color: var(--q-bronze); background: #fdf6ec; outline: 0; }
  #appView .bw-drop b { color: #0a0a0a; font-size: 15px; }
  #appView .bw-drop-ic { display: inline-grid; place-items: center; width: 52px; height: 52px; border-radius: 50%; background: var(--q-bronze); color: #fff; box-shadow: 0 0 0 8px #f3e6d2; margin-bottom: 6px; }
  #appView .bw-total { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; color: #3f3a33; font-size: 13px; font-weight: 700; }
  #appView .bw-bar { flex: 1; height: 8px; border-radius: 99px; background: #efe8dc; overflow: hidden; }
  #appView .bw-bar i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #c4955a, #a9783a); transition: width .25s; }
  #appView .bw-bar.is-over i { background: #b3261e; }
  #appView .bw-files, #appView .bw-docs { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; }
  #appView .bw-files li, #appView .bw-docs li { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border: 1px solid var(--q-line); border-radius: 10px; background: #fff; font-size: 13px; }
  #appView .bw-file-ic { color: var(--q-deep); }
  #appView .bw-file-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
  #appView .bw-files small, #appView .bw-docs small { color: #8a8078; }
  #appView .bw-x { width: 28px; height: 28px; min-height: 0; padding: 0; border-radius: 8px; font-size: 18px; line-height: 1; }
  /* Bước 4 */
  #appView .bw-prog { margin-bottom: 12px; padding: 14px 16px; border: 1px solid var(--q-line); border-radius: 14px; background: #fff; }
  #appView .bw-prog-top { display: flex; align-items: baseline; gap: 12px; margin-bottom: 8px; }
  #appView .bw-prog-top b { font-size: 28px; font-weight: 800; }
  #appView .bw-prog-top span { color: #5b524a; font-size: 13px; }
  #appView .bw-docs em { flex: none; padding: 2px 10px; border-radius: 99px; background: #f0f0f2; color: #5b524a; font-size: 12px; font-style: normal; font-weight: 700; }
  #appView .bw-docs li.is-run em { background: #fff4e0; color: #a2560b; } #appView .bw-docs li.is-cache em { background: #e9effc; color: #1a4fc4; }
  #appView .bw-docs li.is-ok em { background: #e6f6ea; color: #15713f; } #appView .bw-docs li.is-err em { background: #fdecea; color: #b3261e; }
  /* Bước 5 */
  #appView .bw-sum { display: flex; flex-wrap: wrap; gap: 8px 16px; margin-bottom: 12px; font-size: 13.5px; }
  #appView .bw-sum span { display: inline-flex; align-items: center; gap: 6px; }
  #appView .bw-sum .is-red { color: #b3261e; font-weight: 800; } #appView .bw-sum .is-warn { color: #a2560b; font-weight: 800; }
  #appView .bw-failed { display: grid; gap: 6px; margin-bottom: 12px; padding: 10px 12px; border: 1px solid #f5c2bd; border-radius: 12px; background: #fff8f7; color: #7a1a14; font-size: 13px; }
  #appView .bw-failed > div { display: flex; gap: 8px; } #appView .bw-failed button { justify-self: start; }
  #appView .bw-recs { display: grid; gap: 10px; }
  #appView .bw-rec { padding: 12px 14px; border: 1px solid var(--q-line); border-left: 4px solid #d9d3c9; border-radius: 12px; background: #fff; }
  #appView .bw-rec.is-confirmed { border-left-color: #15803d; } #appView .bw-rec.is-excluded { opacity: .6; border-left-color: #a1a1aa; }
  #appView .bw-rec.has-red { border-left-color: #b3261e; } #appView .bw-rec.is-mismatch { background: #fffaf1; }
  #appView .bw-rec header { display: flex; align-items: flex-start; gap: 10px; }
  #appView .bw-rec-ic { display: inline-grid; place-items: center; flex: none; width: 32px; height: 32px; border-radius: 9px; background: #f6efe5; color: var(--q-deep); }
  #appView .bw-rec-head { flex: 1; min-width: 0; display: flex; flex-direction: column; }
  #appView .bw-rec-head b { font-size: 14px; } #appView .bw-rec-head small { color: #5b524a; font-size: 12px; }
  #appView .bw-rec-state { flex: none; padding: 2px 10px; border-radius: 99px; background: #f0f0f2; color: #5b524a; font-size: 11.5px; font-weight: 800; }
  #appView .bw-rec.is-confirmed .bw-rec-state { background: #e6f6ea; color: #15713f; }
  #appView .bw-warn { display: flex; align-items: center; gap: 6px; margin: 8px 0 0; padding: 6px 10px; border-radius: 8px; background: #fff0d9; color: #6b3a07; font-size: 12.5px; }
  #appView .bw-flags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
  #appView .bw-flags span { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border: 1px solid #f5c2bd; border-radius: 99px; background: #fdecea; color: #b3261e; font-size: 12px; font-weight: 700; }
  #appView .bw-concl { margin: 8px 0 0; font-size: 13.5px; line-height: 1.5; white-space: pre-wrap; }
  #appView .bw-meta { margin: 4px 0 0; color: #3f3a33; font-size: 12.5px; }
  #appView .bw-rec footer { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
  #appView .bw-rec footer .spacer { flex: 1; }
  #appView .bw-rec footer [data-file] { max-width: 50%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #8a5f2a; }
  #appView .bw-ok[aria-pressed="true"] { border-color: #15803d; background: #15803d; color: #fff; }
  #appView .bw-no[aria-pressed="true"] { border-color: #71717a; background: #71717a; color: #fff; }
  #appView .bw-edit { margin-top: 10px; padding: 10px; border: 1px dashed #d9c6a5; border-radius: 10px; background: #fdfbf8; }
  #appView .bw-edit-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; margin-bottom: 8px; }
  #appView .bw-edit-grid label { display: flex; flex-direction: column; gap: 3px; font-size: 12px; font-weight: 700; color: #5b524a; }
  #appView .bw-edit-grid .wide { grid-column: 1 / -1; }
  #appView .bw-edit-grid :is(input, select, textarea) { width: 100%; min-height: 36px; border-radius: 8px; }
  /* Tab Tài liệu y tế */
  #appView #medicalWorkspace .doc-summary .panel-head small, #appView #medicalWorkspace .panel-head small { color: #8a8078; font-weight: 500; }
  #appView #medicalWorkspace .doc-problems { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; padding: 14px 16px; }
  #appView #medicalWorkspace .doc-problem { padding: 10px 12px; border: 1px solid var(--m-line); border-top: 3px solid #a1a1aa; border-radius: 12px; background: #fff; }
  #appView #medicalWorkspace .doc-problem.is-red { border-top-color: #b3261e; background: #fffafa; } #appView #medicalWorkspace .doc-problem.is-watch { border-top-color: #d4891f; }
  #appView #medicalWorkspace .doc-problem header { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
  #appView #medicalWorkspace .doc-problem header b { font-size: 14px; }
  #appView #medicalWorkspace .doc-problem header span { font-size: 11px; font-weight: 800; color: #5b524a; }
  #appView #medicalWorkspace .doc-problem.is-red header span { color: #b3261e; }
  #appView #medicalWorkspace .doc-problem ul { display: grid; gap: 4px; margin: 0; padding: 0; list-style: none; }
  #appView #medicalWorkspace .doc-problem li { display: grid; grid-template-columns: 78px 1fr; gap: 8px; font-size: 12.5px; line-height: 1.45; }
  #appView #medicalWorkspace .doc-problem time { color: #8a8078; font-variant-numeric: tabular-nums; }
  #appView #medicalWorkspace .doc-timeline { padding: 6px 16px 14px; }
  /* Dòng thời gian tài liệu: khung đóng / mở. */
  #appView #medicalWorkspace .doc-tl > summary { cursor: pointer; list-style: none; user-select: none; }
  #appView #medicalWorkspace .doc-tl > summary::-webkit-details-marker { display: none; }
  #appView #medicalWorkspace .doc-tl > summary:hover { background: var(--m-bronze-wash, #f7efe3); }
  #appView #medicalWorkspace .doc-tl > summary:focus-visible { outline: 2px solid var(--m-bronze, #a9783a); outline-offset: -2px; }
  #appView #medicalWorkspace .doc-tl-chev { width: 8px; height: 8px; margin-left: 10px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg); transition: transform .15s; opacity: .6; }
  #appView #medicalWorkspace .doc-tl[open] .doc-tl-chev { transform: rotate(-135deg); }
  #appView #medicalWorkspace .doc-tl:not([open]) > summary { border-bottom: 0; }
  #appView #medicalWorkspace .doc-timeline h4 { margin: 12px 0 6px; color: var(--m-bronze-deep); font-size: 13px; font-weight: 800; }
  #appView #medicalWorkspace .doc-row { display: grid; grid-template-columns: 46px 32px minmax(0, 1fr) auto; align-items: start; gap: 10px; padding: 10px 0; border-top: 1px dashed #efe7da; }
  #appView #medicalWorkspace .doc-row time { padding-top: 6px; color: #5b524a; font-size: 12.5px; font-weight: 800; font-variant-numeric: tabular-nums; }
  #appView #medicalWorkspace .doc-ic { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; background: #f6efe5; color: var(--m-bronze-deep); }
  #appView #medicalWorkspace .doc-row.has-red .doc-ic { background: #fdecea; color: #b3261e; }
  #appView #medicalWorkspace .doc-main b { display: block; font-size: 13.5px; } #appView #medicalWorkspace .doc-main small { color: #5b524a; font-size: 12px; }
  #appView #medicalWorkspace .doc-main p { margin: 4px 0 0; font-size: 13px; line-height: 1.5; }
  #appView #medicalWorkspace .doc-bundles { display: grid; gap: 0; margin: 0; padding: 0 16px 8px; list-style: none; }
  #appView #medicalWorkspace .doc-bundles li { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px dashed #efe7da; }
  #appView #medicalWorkspace .doc-bundles li > div { flex: 1; min-width: 0; display: flex; flex-direction: column; }
  #appView #medicalWorkspace .doc-bundles small { color: #5b524a; font-size: 12px; }
  /* ===== Tab "Hồ sơ đầy đủ KH": thẻ phiên bản, lịch sử, phiên đã gửi ===== */
  #appView #medicalWorkspace .fd { display: grid; gap: 14px; }
  #appView #medicalWorkspace .fd-hero { padding: 18px 20px 16px; border: 1px solid #e8dcc8; background: linear-gradient(135deg, #fffaf2 0%, #fff 55%); box-shadow: 0 1px 0 rgba(169, 120, 58, .08), 0 8px 24px rgba(60, 40, 15, .05); }
  #appView #medicalWorkspace .fd-hero.is-loading { display: grid; gap: 10px; }
  #appView #medicalWorkspace .fd-skel { height: 64px; border-radius: 12px; background: linear-gradient(90deg, #f4ede2, #fbf7f0, #f4ede2); background-size: 200% 100%; animation: fd-skel 1.2s ease-in-out infinite; }
  @keyframes fd-skel { to { background-position: -200% 0; } }
  #appView #medicalWorkspace .fd-hero-top { display: flex; align-items: center; gap: 14px; }
  #appView .fd-hero-ic { display: inline-grid; place-items: center; flex: none; width: 46px; height: 46px; border-radius: 14px; background: linear-gradient(135deg, #c4955a, #8a5f2a); color: #fff; box-shadow: 0 6px 14px rgba(138, 95, 42, .28); }
  #appView #medicalWorkspace .fd-hero-title { flex: 1; min-width: 0; }
  #appView #medicalWorkspace .fd-hero-title h3 { display: flex; align-items: center; gap: 10px; margin: 0; font-size: 18px; font-weight: 800; letter-spacing: -.2px; color: #2b2620; }
  #appView #medicalWorkspace .fd-hero-title p { margin: 3px 0 0; color: #6b6158; font-size: 12.5px; }
  #appView .fd-ver { display: inline-grid; place-items: center; min-width: 34px; height: 24px; padding: 0 8px; border-radius: 999px; background: #a9783a; color: #fff; font-size: 12px; font-weight: 800; letter-spacing: .02em; }
  #appView .fd-lang { flex: none; display: inline-flex; align-items: center; gap: 5px; padding: 5px 11px; border-radius: 999px; font-size: 12px; font-weight: 800; white-space: nowrap; }
  #appView .fd-lang.is-ja { background: #e9f6ee; color: #15713f; } #appView .fd-lang.is-vi { background: #f4ede2; color: #8a5f2a; }
  #appView #medicalWorkspace .fd-contents { display: flex; flex-wrap: wrap; gap: 6px 8px; margin: 14px 0 0; padding: 0; list-style: none; }
  #appView #medicalWorkspace .fd-contents li { display: inline-flex; align-items: center; gap: 6px; padding: 6px 11px; border: 1px solid #ebe1d1; border-radius: 10px; background: #fff; font-size: 12.5px; font-weight: 600; color: #3f3a33; }
  #appView #medicalWorkspace .fd-contents li svg { color: #a9783a; }
  #appView #medicalWorkspace .fd-contents li.is-off { border-style: dashed; background: transparent; color: #9a9088; } #appView #medicalWorkspace .fd-contents li.is-off svg { color: #c4b8a6; }
  #appView #medicalWorkspace .fd-changes { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 12px; padding: 9px 12px; border-radius: 10px; background: #fff6e8; font-size: 12.5px; }
  #appView #medicalWorkspace .fd-changes b { margin-right: 4px; color: #8a5f2a; font-weight: 800; }
  #appView #medicalWorkspace .fd-changes span { padding: 2px 9px; border-radius: 999px; background: #fff; color: #3f3a33; box-shadow: inset 0 0 0 1px #f0dcbc; }
  #appView #medicalWorkspace .fd-warn { display: flex; align-items: center; gap: 6px; margin: 10px 0 0; color: #a2560b; font-size: 12.5px; font-weight: 700; }
  #appView #medicalWorkspace .fd-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 16px; padding-top: 14px; border-top: 1px solid #f0e7da; }
  #appView #medicalWorkspace .fd-actions button { display: inline-flex; align-items: center; gap: 7px; min-height: 38px; padding: 0 14px; border-radius: 10px; font-size: 13px; font-weight: 700; }
  #appView #medicalWorkspace .fd-actions .spacer { flex: 1; }
  #appView :is(#medicalWorkspace, #fdViewDialog, #fdSendDialog) button.bronze { border-color: #a9783a; background: #a9783a; color: #fff; }
  #appView :is(#medicalWorkspace, #fdViewDialog, #fdSendDialog) button.bronze:hover { background: #8a5f2a; border-color: #8a5f2a; }
  #appView #medicalWorkspace .fd-versions { display: grid; margin: 0; padding: 0 16px 8px; list-style: none; }
  #appView #medicalWorkspace .fd-versions li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px dashed #efe7da; }
  #appView #medicalWorkspace .fd-versions li:first-child { border-top: 0; }
  #appView #medicalWorkspace .fd-versions li:not(.is-current) .fd-ver { background: #efe6d8; color: #6b4a1f; }
  #appView #medicalWorkspace .fd-ver-main { flex: 1; min-width: 0; display: flex; flex-direction: column; font-size: 13px; }
  #appView #medicalWorkspace .fd-latest { display: inline-flex; align-items: center; gap: 3px; padding: 2px 9px; border-radius: 999px; background: #fff3dc; color: #a2560b; font-size: 11.5px; font-style: normal; font-weight: 800; letter-spacing: 0; box-shadow: inset 0 0 0 1px #f3d9a8; }
  #appView #medicalWorkspace .fd-ver-main .fd-latest { padding: 1px 8px; font-size: 11px; }
  #appView #medicalWorkspace .fd-ver-actions { display: flex; flex: none; gap: 6px; }
  #appView #medicalWorkspace .fd-ver-actions button { display: inline-flex; align-items: center; gap: 5px; }
  #appView #medicalWorkspace .fd-ver-main small { overflow: hidden; color: #6b6158; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
  #appView #medicalWorkspace .fd-subhead { display: flex; align-items: center; gap: 8px; margin: 8px 2px 0; color: #3f3a33; font-size: 14px; font-weight: 800; }
  #appView #medicalWorkspace .fd-subhead svg { color: #a9783a; } #appView #medicalWorkspace .fd-subhead small { padding: 1px 8px; border-radius: 999px; background: #f4ede2; color: #8a5f2a; font-size: 11.5px; }
  /* Hộp thoại xem hồ sơ: dùng khung #sentDialog (danh mục trái, nội dung phải) + thanh công cụ */
  #appView #fdViewDialog .fd-view-tools { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
  #appView #fdViewDialog .fd-view-tools > button { min-height: 34px; padding: 0 13px; border-radius: 10px; font-size: 13px; font-weight: 700; }
  #appView .fd-seg { display: inline-flex; gap: 2px; padding: 3px; border: 1px solid #e4dccf; border-radius: 11px; background: #f6f1e9; }
  #appView .fd-seg button { min-height: 28px; padding: 0 12px; border: 0; border-radius: 8px; background: transparent; box-shadow: none; color: #5b524a; font-size: 12.5px; font-weight: 700; }
  #appView .fd-seg button[aria-pressed="true"] { background: #fff; color: #8a5f2a; box-shadow: 0 1px 3px rgba(20, 16, 10, .14); }
  #appView .fd-seg button:disabled { opacity: .45; cursor: not-allowed; }
  #appView #fdViewDialog .fd-sec + .fd-sec { margin-top: 26px; }
  /* Danh mục trái: rộng hơn, tên mục một dòng, luôn song ngữ (Việt trên, Nhật dưới) */
  #appView #fdViewDialog .sent-records { grid-template-columns: 290px minmax(0, 1fr); }
  #appView #fdViewDialog .sent-record-nav button { min-height: 52px; padding: 6px 12px; }
  #appView #fdViewDialog .fd-nav-label { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
  #appView #fdViewDialog .fd-nav-label b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; }
  #appView #fdViewDialog .fd-nav-label small { overflow: hidden; color: #8a7f74; font-size: 11.5px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
  #appView #fdViewDialog .sent-record-nav button[aria-pressed="true"] .fd-nav-label small { color: #a9783a; }
  @media (max-width: 760px) { #appView #fdViewDialog .sent-records { grid-template-columns: 1fr; } }
  /* Bảng xét nghiệm: cột cố định để các nhóm chỉ số thẳng hàng (Chỉ số · Đơn vị · Tham chiếu · Mới nhất · Lần trước · Đánh giá) */
  #appView #fdViewDialog .fd-sec.is-blood .record-table table { table-layout: fixed; }
  #appView #fdViewDialog .fd-sec.is-blood .record-table th:nth-child(1) { width: 22%; } #appView #fdViewDialog .fd-sec.is-blood .record-table th:nth-child(2) { width: 10%; }
  #appView #fdViewDialog .fd-sec.is-blood .record-table th:nth-child(3) { width: 13%; } #appView #fdViewDialog .fd-sec.is-blood .record-table th:nth-child(4) { width: 18%; }
  #appView #fdViewDialog .fd-sec.is-blood .record-table th:nth-child(5) { width: 22%; } #appView #fdViewDialog .fd-sec.is-blood .record-table th:nth-child(6) { width: 15%; }
  #appView #fdViewDialog .fd-sec-title { display: flex; align-items: baseline; flex-wrap: wrap; gap: 6px 10px; margin: 0 0 12px; padding-bottom: 8px; border-bottom: 2px solid #f0e3cf; color: #2b2620; font-size: 16px; font-weight: 800; }
  #appView #fdViewDialog .fd-sec-title > span { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: #a9783a; color: #fff; font-size: 12px; }
  #appView #fdViewDialog .fd-sec-title small { color: #8a7f74; font-size: 12.5px; font-weight: 600; }
  /* Hộp thoại gửi chuyên gia */
  #appView #fdSendDialog { width: min(620px, calc(100vw - 32px)); padding: 0; border: 0; border-radius: 18px; background: #faf7f2; color: #0a0a0a; box-shadow: 0 30px 90px rgba(20, 16, 10, .35); }
  #appView #fdSendDialog::backdrop { background: rgba(28, 22, 15, .55); backdrop-filter: blur(2px); }
  #appView #fdSendDialog .intake-dialog-head { position: static; padding: 12px 20px; border-bottom: 1px solid #e4dccf; background: linear-gradient(105deg, #f8efe1, #fff 70%); }
  #appView #fdSendDialog .intake-dialog-head h2 { margin: 0; font-size: 16px; font-weight: 800; color: #8a5f2a; }
  #appView #fdSendDialog .fd-send-body { display: grid; gap: 14px; padding: 18px 20px 20px; }
  #appView #fdSendDialog .fd-send-doc { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid #e8dcc8; border-radius: 14px; background: #fff; }
  #appView #fdSendDialog .fd-send-doc > div { flex: 1; min-width: 0; display: flex; flex-direction: column; } #appView #fdSendDialog .fd-send-doc small { color: #6b6158; font-size: 12px; }
  #appView #fdSendDialog .fd-check { display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px; border-radius: 12px; background: #fff6e8; font-size: 13px; font-weight: 600; cursor: pointer; }
  #appView #fdSendDialog .fd-check input { width: 18px; height: 18px; margin-top: 1px; accent-color: #a9783a; } #appView #fdSendDialog .fd-check small { display: block; color: #6b6158; font-weight: 500; }
  #appView #fdSendDialog .field { display: grid; gap: 6px; } #appView #fdSendDialog .field label { font-size: 12.5px; font-weight: 800; color: #3f3a33; }
  #appView #fdSendDialog .field :is(input, select) { min-height: 42px; border-radius: 10px; }
  #appView #fdSendDialog .fd-note { display: flex; align-items: center; gap: 6px; margin: 0; color: #6b6158; font-size: 12.5px; }
  #appView #fdSendDialog .fd-send-foot { display: flex; justify-content: flex-end; gap: 10px; } #appView #fdSendDialog .fd-send-foot button { min-height: 40px; padding: 0 18px; border-radius: 10px; font-weight: 700; }
  @media (max-width: 720px) {
    #appView #medicalWorkspace .fd-hero-top { flex-wrap: wrap; row-gap: 8px; } #appView #medicalWorkspace .fd-actions .spacer { display: none; }
    #appView #medicalWorkspace .fd-hero-title { flex-basis: calc(100% - 60px); } #appView #medicalWorkspace .fd-hero-title h3 { font-size: 16px; }
    #appView #medicalWorkspace .fd-hero-top .fd-lang { margin-left: 60px; }
    #appView #medicalWorkspace .fd-versions li { flex-wrap: wrap; } #appView #medicalWorkspace .fd-ver-actions { width: 100%; padding-left: 46px; }
    #appView #medicalWorkspace .fd-actions { display: grid; grid-template-columns: 1fr 1fr; } #appView #medicalWorkspace .fd-actions .bronze { grid-column: 1 / -1; }
    #appView #fdViewDialog .fd-view-tools { width: 100%; }
  }

  /* Bước 6: đưa vào hồ sơ */
  #appView .bw-progress { display: grid; justify-items: center; gap: 12px; padding: 48px 0; color: #5b524a; font-size: 13.5px; }
  #appView .bw-spin { width: 30px; height: 30px; border: 3px solid #eadfcd; border-top-color: var(--q-bronze); border-radius: 50%; animation: bw-spin .8s linear infinite; }
  @keyframes bw-spin { to { transform: rotate(360deg); } }
  #appView .bw-apply { display: grid; gap: 12px; }
  #appView .bw-ap { padding: 12px 14px 8px; border: 1px solid var(--q-line); border-radius: 14px; background: #fff; }
  #appView .bw-ap > header { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; margin-bottom: 6px; color: var(--q-deep); }
  #appView .bw-ap > header b { font-size: 14.5px; } #appView .bw-ap > header small { color: #5b524a; font-size: 12px; }
  #appView .bw-ap h4 { margin: 10px 0 2px; color: #8a6a3f; font-size: 11.5px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; }
  #appView .bw-ap-row { display: grid; grid-template-columns: 20px minmax(140px, 34%) minmax(0, 1fr); align-items: start; gap: 10px; padding: 8px 0; border-top: 1px dashed #efe7da; font-size: 13px; cursor: pointer; }
  #appView .bw-ap h4 + .bw-ap-row, #appView .bw-ap > header + .bw-ap-row { border-top: 0; }
  #appView .bw-ap-row input { width: 17px; height: 17px; margin: 1px 0 0; accent-color: var(--q-bronze); }
  #appView .bw-ap-row:has(input:disabled) { cursor: default; } #appView .bw-ap-row:has(input:disabled) .bw-ap-v b { color: #8a8078; }
  #appView .bw-ap-k { color: #5b524a; font-weight: 600; }
  #appView .bw-ap-v { display: flex; flex-direction: column; gap: 2px; min-width: 0; overflow-wrap: anywhere; }
  #appView .bw-ap-v b { color: #2b2620; font-weight: 700; } #appView .bw-ap-v small { color: #7a7066; font-size: 11.5px; }
  #appView .bw-ap-v em { color: #6b5d4c; font-size: 12px; font-style: normal; }
  #appView .bw-ap-row.is-conflict em { color: #a2560b; font-weight: 700; } #appView .bw-ap-v em.is-bad { color: #b3261e; font-weight: 700; }
  @media (prefers-reduced-motion: reduce) { #appView .bw-spin { animation-duration: 2.4s; } }
  @media (max-width: 720px) {
    #appView .bw-types, #appView .bw-new, #appView .bw-edit-grid { grid-template-columns: 1fr; }
    #appView .bw-ap-row { grid-template-columns: 20px minmax(0, 1fr); row-gap: 2px; } #appView .bw-ap-v { grid-column: 2; }
    #appView .bw-body { padding: 12px 14px; } #appView .bw-foot { flex-wrap: wrap; padding: 10px 14px; } #appView .bw-steps { padding: 10px 14px; }
    #appView .bw-steps li:not(.is-now) { font-size: 0; gap: 0; padding-right: 6px; } #appView .bw-steps li:not(.is-now) span { font-size: 11px; }
    #appView #medicalWorkspace .doc-row { grid-template-columns: 40px minmax(0, 1fr); } #appView #medicalWorkspace .doc-ic { display: none; }
    #appView #medicalWorkspace .doc-row > button { grid-column: 2; justify-self: start; }
  }
}

/* Xem file tài liệu y tế trong hộp thoại (không mở tab mới). */
@media screen {
  .doc-viewer { width: min(1100px, calc(100vw - 24px)); height: min(92vh, 1200px); max-height: none; padding: 0; border: 1px solid var(--hair); border-radius: 14px; background: var(--surface); color: var(--ink); overflow: hidden; }
  .doc-viewer[open] { display: flex; flex-direction: column; }
  .doc-viewer::backdrop { background: rgba(20, 14, 6, .55); }
  .doc-viewer > header { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--hair); }
  .doc-viewer > header h2 { margin: 0; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
  .doc-viewer > header .spacer { flex: 1; }
  .doc-viewer #dvDownload { display: inline-flex; align-items: center; min-height: 32px; padding: 0 14px; border: 1px solid var(--hair); border-radius: 10px; color: var(--ink); background: var(--surface); text-decoration: none; font-size: 13px; font-weight: 600; }
  .doc-viewer #dvDownload:hover { border-color: var(--bronze, #a9783a); color: var(--bronze-deep, #7a5525); }
  .doc-viewer #dvDownload[hidden] { display: none; }
  .doc-viewer .dv-body { flex: 1 1 auto; min-height: 0; display: flex; align-items: center; justify-content: center; background: #525659; overflow: auto; }
  .doc-viewer .dv-body iframe { width: 100%; height: 100%; border: 0; background: #fff; }
  .doc-viewer .dv-body img { max-width: 100%; max-height: 100%; object-fit: contain; background: #fff; }
  .doc-viewer .dv-loading { color: #fff; font-size: 14px; }
  .doc-viewer .hub-error { margin: 16px; }
}

/* Hộp thoại cờ đỏ hồ sơ */
@media screen {
  .rf-dialog { width: min(760px, calc(100vw - 24px)); max-height: calc(100vh - 32px); padding: 0; border: 1px solid #f5c2bd; border-radius: 14px; background: var(--surface); color: var(--ink); overflow: hidden; }
  .rf-dialog[open] { display: flex; flex-direction: column; }
  .rf-dialog::backdrop { background: rgba(20, 14, 6, .55); }
  .rf-dialog > header { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid #f5c2bd; background: #fdecea; }
  .rf-dialog > header h2 { flex: 1; display: flex; align-items: center; gap: 8px; margin: 0; font-size: 17px; color: #b3261e; }
  .rf-dialog .rf-note { margin: 10px 18px 0; font-size: 12.5px; color: var(--muted); }
  .rf-dialog .rf-list { flex: 1 1 auto; min-height: 0; overflow: auto; margin: 0; padding: 10px 18px 14px 40px; display: grid; gap: 12px; }
  .rf-dialog .rf-list > li::marker { color: #b3261e; font-weight: 800; }
  .rf-dialog .rf-flag { font-weight: 800; color: #b3261e; font-size: 14.5px; line-height: 1.4; }
  .rf-dialog .rf-src { display: grid; grid-template-columns: 82px 1fr auto; gap: 10px; align-items: start; margin-top: 6px; padding: 8px 10px; border: 1px solid var(--hair); border-radius: 10px; background: var(--paper); }
  .rf-dialog .rf-src time { color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; padding-top: 1px; }
  .rf-dialog .rf-src b { display: block; font-size: 13.5px; }
  .rf-dialog .rf-src small { display: block; color: var(--muted); font-size: 12px; margin-top: 1px; }
  .rf-dialog .rf-src p { margin: 4px 0 0; font-size: 13px; line-height: 1.45; }
  .rf-dialog > footer { display: flex; justify-content: flex-end; padding: 10px 18px; border-top: 1px solid var(--hair); }
  @media (max-width: 560px) { .rf-dialog .rf-src { grid-template-columns: 1fr; } }
}

/* 05/11: thẻ xét nghiệm / phiếu y tế — nút ít dùng (PDF gốc, Xóa phiếu) gom vào ⋯ ở màn rộng; màn hẹp giữ nút như cũ */
#appView .lab-file-actions [data-lab-more] { display: none; }
@media (min-width: 901px) {
  #appView .lab-file-actions .lab-more-item { display: none !important; }
  #appView .lab-file-actions [data-lab-more] { display: inline-grid; }
}

/* ==========================================================================
   Điện thoại (≤ 900px, 11/2026, theo CRM mobile): Hồ sơ sức khỏe là 2 màn — danh sách (thẻ mỗi hồ sơ) và chi tiết một cột.
   Mở hồ sơ thì danh sách ẩn (staff.js gắn .is-collapsed), nút « thành ← quay lại danh sách. Tab cuộn ngang, thẻ phẳng theo token,
   popup Bảng thu thập thông tin y tế toàn màn. Máy tính (≥ 901px) không đổi.
   ========================================================================== */
@media screen and (max-width: 900px) {
  #appView #medicalWorkspace { display: block; padding: 12px 12px 16px; }
  #appView #medicalWorkspace:not(.is-collapsed) > main { display: none; }
  #appView #medicalWorkspace.is-collapsed > aside > :not(.panel-head) { display: none; }
  /* Đầu màn: tiêu đề 18/800 · số đếm · nút đặc Thêm hồ sơ; chi tiết: ← · tiêu đề */
  #appView #medicalWorkspace > aside.panel:not(.lab-file):not(.care-file):not(.ttyt-saved):not(.intake-add):not(.lab-upload) { max-height: none; padding: 0; overflow: visible; border: 0; border-radius: 0; background: none; box-shadow: none; }
  #appView #medicalWorkspace > aside.panel:not(.lab-file):not(.care-file):not(.ttyt-saved) > .panel-head { gap: 8px; min-height: 40px; margin: 0 0 12px; padding: 0; border: 0; border-radius: 0; background: none; }
  #appView #medicalWorkspace > aside.panel > .panel-head > span:first-of-type { font-size: 18px; font-weight: 800; letter-spacing: -.2px; color: #25211C; }
  #appView #medicalWorkspace #listCount { min-width: 26px; height: 24px; box-sizing: border-box; padding: 0 8px; border-radius: 12px; background: #F1ECE4; color: #6F655A; font-size: 12px; font-weight: 700; line-height: 24px; }
  #appView #medicalWorkspace #newFromCrmBtn { min-height: 40px; height: 40px; padding: 0 14px; gap: 6px; border: 0; border-radius: 10px; background: #9A6A2E; color: #fff; font-size: 14px; font-weight: 700; }
  #appView #medicalWorkspace #newFromCrmBtn:hover { background: #7E5523; }
  #appView #medicalWorkspace #newFromCrmBtn svg { color: #fff; stroke: currentColor; }
  #appView #medicalWorkspace:not(.is-collapsed) .med-toggle { display: none; }
  #appView #medicalWorkspace.is-collapsed #listCount, #appView #medicalWorkspace.is-collapsed #newFromCrmBtn { display: none; }
  #appView #medicalWorkspace.is-collapsed .med-toggle { width: 40px; height: 40px; margin-left: -8px; border: 0; border-radius: 10px; background: none; color: #25211C; }
  #appView #medicalWorkspace.is-collapsed .med-toggle:hover { background: #F5F0E8; }
  #appView #medicalWorkspace.is-collapsed .med-toggle svg { display: none; }
  #appView #medicalWorkspace.is-collapsed .med-toggle::before { content: ""; width: 22px; height: 22px; background: currentColor; -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M19 12H5M11 6l-6 6 6 6'/%3E%3C/svg%3E") center / contain no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M19 12H5M11 6l-6 6 6 6'/%3E%3C/svg%3E") center / contain no-repeat; }
  /* Lọc: ô tìm viên thuốc cả hàng, chọn trạng thái dạng chip */
  #appView #medicalWorkspace .rail-filters { display: flex; flex-direction: column; align-items: stretch; gap: 8px; margin: 0 0 12px; padding: 0; border: 0; }
  #appView #medicalWorkspace .rail-filters input { min-height: 44px; border: 1px solid #E4DACA; border-radius: 22px; font-size: 16px; }
  #appView #medicalWorkspace .rail-filters select { align-self: flex-start; width: auto; max-width: 100%; height: 36px; min-height: 36px; padding: 0 30px 0 14px; border: 1px solid #E4DACA; border-radius: 18px; background-color: #fff; color: #25211C; font-size: 16px; font-weight: 600; }
  /* Danh sách: mỗi hồ sơ một thẻ */
  #appView #medicalWorkspace .plist { display: flex; flex-direction: column; gap: 8px; min-height: 0; max-height: none; padding: 0; overflow: visible; }
  #appView #medicalWorkspace .pitem { min-height: 64px; margin: 0; padding: 12px 14px; border: 1px solid #E4DACA; border-radius: 16px; background: #fff; box-shadow: none; }
  #appView #medicalWorkspace .pitem:hover, #appView #medicalWorkspace .pitem[aria-selected="true"] { border-color: #E4DACA; background: #FAF1E1; box-shadow: none; }
  #appView #medicalWorkspace .pitem .nm { font-size: 15px; color: #25211C; }
  #appView #medicalWorkspace .pitem .row2 { color: #6F655A; font-size: 13px; }
  #appView #medicalWorkspace .pav, #appView #medicalWorkspace .pb-avatar { background: #9A6A2E; font-weight: 700; }
  #appView #medicalWorkspace .pav.st-moi { background: #6F655A; }
  #appView #medicalWorkspace .pav.st-cho_xet_nghiem, #appView #medicalWorkspace .pav.st-theo_doi { background: #24498A; }
  #appView #medicalWorkspace .pav.st-cho_tu_van { background: #8A4B0C; }
  #appView #medicalWorkspace .pav.st-ket_thuc { background: #1F5E2E; }
  #appView #medicalWorkspace .owner-group { border-color: #E4DACA; border-radius: 16px; }
  #appView #medicalWorkspace .owner-group > summary { min-height: 44px; box-sizing: border-box; padding: 12px 14px; color: #25211C; font-size: 14px; }
  #appView #medicalWorkspace .owner-group-body .pitem { border-color: #EFE9DD; }
  #appView #medicalWorkspace .plist .hub-pager { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 8px 0; }
  #appView #medicalWorkspace .plist .hub-pager button { min-height: 40px; }
  /* Chip trạng thái theo token */
  #appView #medicalWorkspace .tag { height: auto; min-height: 22px; padding: 0 10px; border: 0; border-radius: 12px; background: #F1ECE4; color: #6F655A; font-size: 12px; font-weight: 600; letter-spacing: 0; text-transform: none; }
  #appView #medicalWorkspace .tag.ok { background: #E6F2E8; color: #1F5E2E; }
  #appView #medicalWorkspace .tag.warn { background: #FFF2E0; color: #8A4B0C; }
  #appView #medicalWorkspace .tag.danger, #appView #medicalWorkspace .tag.lab-high { background: #FBE7E5; color: #9B2F23; }
  #appView #medicalWorkspace .tag.info, #appView #medicalWorkspace .tag.low, #appView #medicalWorkspace .tag.lab-low { background: #E7EEF9; color: #24498A; }
  #appView #medicalWorkspace .tag.brand { background: #EFE2CC; color: #6E4A1C; }

  /* Chi tiết: thẻ phẳng viền #E4DACA, không bóng */
  #appView #medicalWorkspace .panel:not(.lab-file):not(.care-file):not(.ttyt-saved):not(.intake-add):not(.lab-upload) { border-color: #E4DACA; box-shadow: none; }
  #appView #medicalWorkspace .patient-banner { border: 1px solid #E4DACA; border-radius: 16px; background: #fff; box-shadow: none; }
  #appView #medicalWorkspace .pb-main { flex-wrap: nowrap; align-items: flex-start; gap: 10px; padding: 14px 14px 10px; }
  #appView #medicalWorkspace .pb-avatar { display: none; }
  #appView #medicalWorkspace .pb-id { flex: 1 1 auto; min-width: 0; }
  #appView #medicalWorkspace .pb-name { gap: 6px 8px; font-size: 18px; font-weight: 700; letter-spacing: 0; color: #25211C; overflow-wrap: anywhere; }
  #appView #medicalWorkspace .pb-facts { gap: 2px 12px; margin-top: 6px; color: #6F655A; font-size: 13px; }
  #appView #medicalWorkspace .pb-facts > span { padding: 0; border: 0; }
  #appView #medicalWorkspace .pb-facts .mrn { font-family: inherit; font-weight: 600; color: #25211C; }
  #appView #medicalWorkspace .pb-actions { flex: 0 0 auto; width: auto; }
  #appView #medicalWorkspace .pb-actions #printBtn { width: auto; min-height: 40px; height: 40px; padding: 0 12px; gap: 6px; border: 1px solid #E4DACA; border-radius: 10px; background: #fff; color: #25211C; font-size: 13px; font-weight: 600; white-space: nowrap; }
  #appView #medicalWorkspace .pb-flag { min-height: 24px; padding: 0 10px; border: 0; border-radius: 12px; font-size: 12px; font-weight: 600; }
  #appView #medicalWorkspace .pb-flag.is-allergy, #appView #medicalWorkspace .pb-flag.is-crit { background: #FBE7E5; color: #9B2F23; }
  #appView #medicalWorkspace .pb-flag.is-chronic { background: #FFF2E0; color: #8A4B0C; }
  #appView #medicalWorkspace .pb-flag-btn { min-height: 32px; }
  #appView #medicalWorkspace .pb-alerts { padding: 0 14px 12px; }
  /* Chặng chăm sóc: cuộn ngang trong thẻ */
  #appView #medicalWorkspace .pb-journey { padding: 4px 14px 14px; }
  #appView #medicalWorkspace .journey { min-width: 520px; }
  #appView #medicalWorkspace .journey li + li::before { top: 13px; height: 2px; background: #EFE9DD; }
  #appView #medicalWorkspace .journey li.is-done + li::before, #appView #medicalWorkspace .journey li.is-done + li.is-now::before { background: #9A6A2E; }
  #appView #medicalWorkspace .journey button { min-height: 44px; }
  #appView #medicalWorkspace .jdot { width: 26px; height: 26px; border: 2px solid #E4DACA; font-weight: 700; color: #6F655A; }
  #appView #medicalWorkspace .jlabel { font-size: 12px; font-weight: 500; }
  #appView #medicalWorkspace .journey li.is-done .jdot { border-color: #9A6A2E; background: #9A6A2E; color: #fff; }
  #appView #medicalWorkspace .journey li.is-now .jdot { border-color: #9A6A2E; background: #fff; color: #6E4A1C; box-shadow: none; }
  #appView #medicalWorkspace .journey li.is-now .jlabel { color: #6E4A1C; font-weight: 700; }
  /* Tab chữ cuộn ngang sát mép */
  #appView #medicalWorkspace .tabs { flex-wrap: nowrap; gap: 20px; margin: 12px -12px 0; padding: 0 12px; box-shadow: none; border-bottom: 1px solid #EFE9DD; overflow-x: auto; scrollbar-width: none; }
  #appView #medicalWorkspace .tabs::-webkit-scrollbar { display: none; }
  #appView #medicalWorkspace .tabs::after { content: ""; flex: 0 0 1px; }
  #appView #medicalWorkspace .tabs + div { height: 12px !important; }
  #appView #medicalWorkspace .tab { gap: 6px; min-height: 44px; padding: 0; border-bottom: 2px solid transparent; color: #6F655A; font-size: 14px; font-weight: 600; white-space: nowrap; }
  #appView #medicalWorkspace .tab svg { display: none; }
  #appView #medicalWorkspace .tab[aria-selected="true"] { color: #25211C; border-bottom-color: #9A6A2E; }
  #appView #medicalWorkspace .tab .count, #appView #medicalWorkspace .tab[aria-selected="true"] .count { min-width: 20px; height: 20px; box-sizing: border-box; padding: 0 7px; border-radius: 10px; background: #F1ECE4; color: #6F655A; font-size: 11px; font-weight: 700; line-height: 20px; }
  /* Tổng quan: dải tóm tắt lưới 2 cột — nhãn trên, số dưới */
  #appView #medicalWorkspace .ov-stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  #appView #medicalWorkspace .ov-stat, #appView #medicalWorkspace .ov-stat.is-warn { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; min-height: 0; padding: 10px 12px; border: 0; border-radius: 12px; background: #FAF7F2; box-shadow: none; transform: none; }
  #appView #medicalWorkspace .ov-stat:hover { transform: none; background: #FAF1E1; }
  #appView #medicalWorkspace .ov-ic { display: none; }
  #appView #medicalWorkspace .ov-txt { display: contents; }
  #appView #medicalWorkspace .ov-txt span { order: 1; font-size: 12px; font-weight: 500; color: #6F655A; }
  #appView #medicalWorkspace .ov-stat b { order: 2; font-size: 18px; font-weight: 700; line-height: 24px; color: #25211C; }
  #appView #medicalWorkspace .ov-txt small { order: 3; max-width: 100%; font-size: 12px; color: #6F655A; white-space: normal; }
  #appView #medicalWorkspace .ov-txt em { color: #9B2F23; }
  #appView #medicalWorkspace .ov-stat.is-warn b { color: #9B2F23; }
  /* Thẻ khối: tiêu đề 16/700, cặp nhãn–giá trị 1 cột gọn */
  #appView #medicalWorkspace .panel:not(aside):not(.lab-file):not(.care-file):not(.ttyt-saved) > .panel-head { padding: 14px 16px 4px; border-bottom: 0; font-size: 16px; font-weight: 700; }
  #appView #medicalWorkspace .panel:not(aside):not(.lab-file):not(.care-file):not(.ttyt-saved) > .panel-head > svg { display: none; }
  #appView #medicalWorkspace .panel:not(aside):not(.lab-file):not(.care-file):not(.ttyt-saved) > .panel-body { padding: 12px 16px 16px; }
  #appView #medicalWorkspace .grid-2 { grid-template-columns: minmax(0, 1fr); }
  #appView #medicalWorkspace .section-title { margin: 0 0 8px; font-size: 16px; font-weight: 700; letter-spacing: 0; text-transform: none; color: #25211C; }
  #appView #medicalWorkspace .section-title::before { content: none; }
  #appView #medicalWorkspace .kv { grid-template-columns: 112px minmax(0, 1fr) !important; gap: 0; }
  #appView #medicalWorkspace .kv dt, #appView #medicalWorkspace .kv dd { padding: 10px 0; border-bottom: 0; border-top: 1px solid #EFE9DD; }
  #appView #medicalWorkspace .kv dt { padding-right: 10px; font-size: 13px; font-weight: 400; color: #6F655A; }
  #appView #medicalWorkspace .kv dd { font-size: 14px; font-weight: 400; color: #25211C; overflow-wrap: anywhere; }
  #appView #medicalWorkspace .clinical-summary > div { padding: 10px 0; border: 0; border-top: 1px solid #EFE9DD; }
  #appView #medicalWorkspace .clinical-summary dt { font-size: 13px; font-weight: 400; color: #6F655A; }
  #appView #medicalWorkspace .clinical-summary dd { font-size: 14px; color: #25211C; }
  /* Thẻ phiếu: xét nghiệm gọn, phiếu y tế, bảng tư vấn */
  #appView #medicalWorkspace :is(.lab-file, .care-file, .ttyt-saved) { border: 1px solid #E4DACA; border-radius: 16px; background: #fff; box-shadow: none; }
  #appView #medicalWorkspace :is(.lab-file-head, .ttyt-head, .care-file-head) { background: #fff; }
  #appView #medicalWorkspace :is(.lab-file-head, .ttyt-head) { gap: 8px 10px; min-height: 0; padding: 12px 14px; }
  #appView #medicalWorkspace .lab-file-label .lab-file-name { font-weight: 700; }
  #appView #medicalWorkspace .lab-file-label .lab-latest { color: #8A5F27; }
  #appView #medicalWorkspace .lab-file-lab { color: #6F655A; font-size: 13px; }
  #appView #medicalWorkspace .lab-file-actions { display: flex; flex: 0 0 100%; flex-wrap: nowrap; gap: 8px; margin-left: 0; }
  #appView #medicalWorkspace .lab-file-actions > button:not(.ui-more) { flex: 1 1 auto; }
  #appView #medicalWorkspace .lab-file-actions button, #appView #medicalWorkspace .care-file-head button, #appView #medicalWorkspace .ttyt-head button { min-width: 0; height: 40px; min-height: 40px; padding: 0 12px; border: 1px solid #E4DACA; border-radius: 10px; background: #fff; color: #25211C; font-size: 13px; font-weight: 600; box-shadow: none; white-space: normal; line-height: 1.2; }
  #appView #medicalWorkspace :is(.lab-file-actions, .care-file-head) button[aria-expanded="true"], #appView #medicalWorkspace :is(.lab-file-actions, .care-file-head) button[aria-expanded="true"]:hover { border-color: #EFE2CC; background: #EFE2CC; color: #6E4A1C; box-shadow: none; }
  #appView #medicalWorkspace table th { padding: 8px 10px; background: #FAF7F2; color: #6F655A; font-size: 12px; font-weight: 600; letter-spacing: 0; text-transform: none; border-color: #EFE9DD; }
  #appView #medicalWorkspace table td { padding: 8px 10px; border-color: #EFE9DD; color: #25211C; font-size: 13px; }
  #appView #medicalWorkspace .lab-file .lab-results th:first-child, #appView #medicalWorkspace .lab-file .lab-results td:first-child { text-align: left; font-weight: 600; }
  #appView #medicalWorkspace .lab-file .lab-results td[colspan] { padding: 6px 10px; background: #FAF7F2; color: #6F655A; font-size: 12px; font-weight: 600; text-align: left; }
  #appView #medicalWorkspace tr.abn-low td:first-child { box-shadow: inset 3px 0 0 #24498A; }
  #appView #medicalWorkspace tr.abn-high td:first-child { box-shadow: inset 3px 0 0 #9B2F23; }
  #appView #medicalWorkspace .lab-file tr.abn-low td.num b { color: #24498A; }
  #appView #medicalWorkspace .lab-file tr.abn-high td.num b { color: #9B2F23; }
  /* Thẻ xét nghiệm gọn: mỗi chỉ số 2 dòng — tên · kết quả · đơn vị · diễn tiến / tham chiếu · đánh giá; ghi chú dòng 3 */
  #appView .lab-file-actions .lab-more-item { display: none !important; }
  #appView .lab-file-actions [data-lab-more] { display: inline-grid; width: 40px; min-width: 40px; height: 40px; min-height: 40px; padding: 0; border: 0; background: none; }
  #appView #medicalWorkspace .lab-file [id^="labDetail_"] > .tbl-wrap { overflow: visible; border: 0; border-radius: 0; }
  #appView #medicalWorkspace .lab-file .lab-results, #appView #medicalWorkspace .lab-file .lab-results tbody { display: block; width: 100%; min-width: 0; table-layout: auto; }
  #appView #medicalWorkspace .lab-file .lab-results thead { display: none; }
  #appView #medicalWorkspace .lab-file .lab-results tr { display: grid; grid-template-columns: minmax(0, 1fr) auto auto auto; column-gap: 8px; row-gap: 2px; align-items: center; padding: 10px 14px; border-top: 1px solid #EFE9DD; }
  #appView #medicalWorkspace .lab-file .lab-results tr:hover { background: none; }
  #appView #medicalWorkspace .lab-file .lab-results td, #appView #medicalWorkspace .lab-file .lab-results td:first-child { display: block; height: auto; min-width: 0; padding: 0; border: 0; background: none; box-shadow: none; text-align: left; }
  #appView #medicalWorkspace .lab-file .lab-results td:nth-child(1) { grid-column: 1; grid-row: 1; font-size: 14px; }
  #appView #medicalWorkspace .lab-file .lab-results td:nth-child(2) { grid-column: 2; grid-row: 1; text-align: right; padding: 0; }
  #appView #medicalWorkspace .lab-file .lab-results td:nth-child(3) { grid-column: 3; grid-row: 1; color: #6F655A; font-size: 12px; }
  #appView #medicalWorkspace .lab-file .lab-results td:nth-child(4) { grid-column: 1; grid-row: 2; color: #6F655A; font-size: 12px; text-align: left; padding: 0; }
  #appView #medicalWorkspace .lab-file .lab-results td:nth-child(4):not(:empty)::before { content: "Tham chiếu "; }
  #appView #medicalWorkspace .lab-file .lab-results td:nth-child(5) { display: none; }
  #appView #medicalWorkspace .lab-file .lab-results td:nth-child(6) { grid-column: 2 / 4; grid-row: 2; justify-self: end; }
  #appView #medicalWorkspace .lab-file .lab-results td:nth-child(7) { grid-column: 1 / -1; grid-row: 3; color: #6F655A; font-size: 12px; }
  #appView #medicalWorkspace .lab-file .lab-results td:nth-child(7):empty { display: none; }
  #appView #medicalWorkspace .lab-file .lab-results td:nth-child(8) { grid-column: 4; grid-row: 1 / 3; }
  #appView #medicalWorkspace .lab-file .lab-results td:nth-child(8) button { display: inline-grid; place-items: center; width: 40px; min-width: 40px; height: 40px; min-height: 40px; padding: 0; font-size: 0; }
  #appView #medicalWorkspace .lab-file .lab-results td:nth-child(8) button svg { width: 18px; height: 18px; }
  #appView #medicalWorkspace .lab-file .lab-results tr:has(> td[colspan]) { display: block; padding: 0; }
  #appView #medicalWorkspace .lab-file .lab-results td[colspan] { padding: 6px 14px; }
  #appView #medicalWorkspace .lab-file .lab-results tr.abn-low { box-shadow: inset 3px 0 0 #24498A; }
  #appView #medicalWorkspace .lab-file .lab-results tr.abn-high { box-shadow: inset 3px 0 0 #9B2F23; }
  #appView #medicalWorkspace .ttyt-head:hover { background: #FAF1E1; }
  #appView #medicalWorkspace .ttyt-saved .ttyt-read-section > h3 { font-size: 15px; font-weight: 700; letter-spacing: 0; text-transform: none; color: #25211C; }
  #appView #medicalWorkspace .ttyt-saved .ttyt-read-section > h3::before { content: none; }
  #appView #medicalWorkspace .ttyt-saved .panel-body { padding: 12px 14px 14px; }
  #appView #medicalWorkspace .ttyt-saved .ttyt-card { border-color: #EFE9DD; border-radius: 12px; }
  #appView #medicalWorkspace .ttyt-saved .ttyt-status.is-no { background: #E6F2E8; color: #1F5E2E; }
  #appView #medicalWorkspace .ttyt-saved .ttyt-status.is-yes { background: #FBE7E5; color: #9B2F23; }
  #appView #medicalWorkspace .ttyt-saved .ttyt-status.is-unanswered { background: #F1ECE4; color: #6F655A; }
  #appView #medicalWorkspace .sent-records { border-color: #E4DACA; border-radius: 16px; }
  /* Thẻ thêm mới */
  #appView #medicalWorkspace :is(.intake-add, .lab-upload) { border: 1px dashed #E4DACA; border-radius: 16px; background: #FAF7F2; }
  #appView #medicalWorkspace :is(.intake-add, .lab-upload) > button { min-height: 56px; padding: 12px 14px; color: #8A5F27; font-size: 14px; font-weight: 600; text-align: left; }
  #appView #medicalWorkspace :is(.intake-add, .lab-upload) .lab-plus { width: 28px; height: 28px; background: linear-gradient(#fff, #fff) center / var(--pl) var(--pw) no-repeat, linear-gradient(#fff, #fff) center / var(--pw) var(--pl) no-repeat, #9A6A2E; }
  #appView #medicalWorkspace .stack > :is(.intake-add, .lab-upload):first-child > button { min-height: 160px; text-align: center; }
  #appView #medicalWorkspace .stack > :is(.intake-add, .lab-upload):first-child .lab-plus { width: 48px; height: 48px; box-shadow: 0 0 0 6px #FBF6ED; }

  /* Popup Bảng thu thập thông tin y tế (Hồ sơ sức khỏe + Thêm/Sửa khách): toàn màn, đầu dính trên, nút dính đáy */
  #appView :is(#intakeDialog, #hubIntakeDialog) { --q-bronze: #9A6A2E; --q-deep: #6E4A1C; --q-line: #EFE9DD; width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0; padding: 0; border-radius: 0; background: #fff; box-shadow: none; }
  #appView :is(#intakeDialog, #hubIntakeDialog)::backdrop { background: rgba(37, 33, 28, .45); backdrop-filter: none; }
  #appView :is(#intakeDialog, #hubIntakeDialog) .intake-dialog-head { position: sticky; top: 0; z-index: 3; display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 56px; padding: 8px 12px 8px 16px; border-bottom: 1px solid #EFE9DD; background: #fff; }
  #appView :is(#intakeDialog, #hubIntakeDialog) .intake-dialog-head h2 { display: block; margin: 0; font-size: 16px; font-weight: 700; letter-spacing: 0; line-height: 1.3; text-transform: lowercase; color: #25211C; }
  #appView :is(#intakeDialog, #hubIntakeDialog) .intake-dialog-head h2::first-letter { text-transform: uppercase; }
  #appView :is(#intakeDialog, #hubIntakeDialog) .intake-dialog-head h2::before { content: none; }
  #appView :is(#intakeDialog, #hubIntakeDialog) .intake-dialog-head button { min-height: 44px; padding: 0 14px; border: 1px solid #E4DACA; border-radius: 10px; background: #fff; color: #25211C; font-weight: 600; }
  #appView #medicalWorkspace #intakeDialog .ttyt-form.panel, #appView #hubIntakeDialog .ttyt-form.panel { margin: 0; border: 0; border-radius: 0; background: #fff; box-shadow: none; }
  #appView :is(#intakeDialog, #hubIntakeDialog) .ttyt-form > .panel-body { padding: 0 16px; }
  #appView :is(#intakeDialog, #hubIntakeDialog) #ttyt_ocr { min-height: 44px; border-color: #9A6A2E; font-weight: 600; }
  #appView :is(#intakeDialog, #hubIntakeDialog) .ttyt-intro { display: none; }
  #appView :is(#intakeDialog, #hubIntakeDialog) .ttyt-nav { margin: 12px -16px 12px; padding: 8px 16px; background: #fff; }
  #appView :is(#intakeDialog, #hubIntakeDialog) .ttyt-nav button { min-height: 44px; color: #6F655A; font-weight: 600; }
  #appView :is(#intakeDialog, #hubIntakeDialog) .ttyt-nav button[aria-pressed="true"] { background: #EFE2CC; color: #6E4A1C; box-shadow: none; }
  #appView :is(#intakeDialog, #hubIntakeDialog) .ttyt-nav button[aria-pressed="true"] .ttyt-step-no { border-color: #9A6A2E; background: #9A6A2E; }
  #appView :is(#intakeDialog, #hubIntakeDialog) .ttyt-step-no { border-color: #E4DACA; font-weight: 700; }
  #appView :is(#intakeDialog, #hubIntakeDialog) .ttyt-section { padding: 12px 14px; border-color: #E4DACA; border-radius: 16px; box-shadow: none; }
  #appView :is(#intakeDialog, #hubIntakeDialog) .ttyt-section > h3 { border-bottom-color: #EFE9DD; color: #25211C; }
  #appView :is(#intakeDialog, #hubIntakeDialog) [data-ttyt-panel] > h3 { font-size: 16px; font-weight: 700; color: #25211C; }
  #appView :is(#intakeDialog, #hubIntakeDialog) .ttyt-grid label { color: #25211C; }
  #appView :is(#intakeDialog, #hubIntakeDialog) .ttyt-grid :is(input:not([type=radio]):not([type=checkbox]), select, textarea), #appView :is(#intakeDialog, #hubIntakeDialog) .ttyt-delivery-opt > .field textarea { min-height: 44px; border-color: #E4DACA; font-size: 16px; }
  #appView :is(#intakeDialog, #hubIntakeDialog) .ttyt-delivery-opt { border-color: #E4DACA; }
  #appView :is(#intakeDialog, #hubIntakeDialog) .ttyt-delivery .check { min-height: 44px; }
  #appView :is(#intakeDialog, #hubIntakeDialog) .ttyt-actions { flex-wrap: wrap; margin: 14px -16px 0; padding: 10px 16px calc(10px + env(safe-area-inset-bottom, 0px)); background: #fff; box-shadow: none; }
  #appView :is(#intakeDialog, #hubIntakeDialog) .ttyt-actions button { min-height: 44px; }
}

/* ===== MOBILE 11/2026 (≤ 760px) — docs/MOBILE-UI-SPEC.md =====
   Hồ sơ sức khỏe: danh sách → chi tiết; dải bệnh nhân gọn dính trên (tên · mã/giới/tuổi · nút in) + tab dính ngay dưới;
   bảng chỉ số → dòng thẻ; hộp thoại lớn toàn màn (đầu dính + ✕), hộp thoại nhỏ thành tấm trượt. */
@media screen and (max-width: 760px) {
  body.sales-shell { --med-bar: 64px; --m-x-ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round'%3E%3Cpath d='M6 6l12 12M18 6L6 18'/%3E%3C/svg%3E"); }

  /* ---------- Danh sách ---------- */
  #appView #medicalWorkspace { padding: 12px 12px 20px; }
  #appView #medicalWorkspace > aside.panel > .panel-head > span:first-of-type { font-size: 20px; font-weight: 800; letter-spacing: -.3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  #appView #medicalWorkspace #newFromCrmBtn { border-radius: 12px; }
  #appView #medicalWorkspace .rail-filters input { min-height: 46px; height: 46px; border-color: var(--m-line); border-radius: 12px; }
  #appView #medicalWorkspace .rail-filters select { border-color: var(--m-line); font-size: 14px; }
  #appView #medicalWorkspace .plist { gap: 10px; }
  #appView #medicalWorkspace .pitem { min-height: 0; padding: 14px; border-color: var(--m-line); border-radius: 14px; }
  #appView #medicalWorkspace .pitem:hover, #appView #medicalWorkspace .pitem[aria-selected="true"] { border-color: var(--m-line); background: #fff; }
  #appView #medicalWorkspace .pitem .row1 { align-items: flex-start; gap: 8px; }
  #appView #medicalWorkspace .pitem .nm { font-size: 15px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  #appView #medicalWorkspace .pitem .row1 .tag { flex: none; }
  #appView #medicalWorkspace .pitem .row2 { gap: 10px; margin-top: 4px; }
  #appView #medicalWorkspace .pitem .row2 .mono { font-family: inherit; font-size: 13px; }
  #appView #medicalWorkspace .tag { border-radius: 999px; }

  /* ---------- Chi tiết: đầu màn ---------- */
  #appView #medicalWorkspace.is-collapsed > aside.panel > .panel-head { margin-bottom: 8px; }

  /* Dải bệnh nhân: tách khung, phần tên dính ngay dưới thanh đầu (cao cố định để tab dính ngay dưới) */
  #appView #medicalWorkspace .patient-banner { display: contents; }
  #appView #medicalWorkspace .pb-main {
    position: sticky; top: 52px; z-index: 22; box-sizing: border-box; display: flex; flex-wrap: nowrap; align-items: center; gap: 10px;
    height: var(--med-bar); margin: 0 -12px; padding: 0 12px; background: #fff; border-bottom: 1px solid var(--m-line-soft);
  }
  #appView #medicalWorkspace .pb-id { flex: 1 1 auto; min-width: 0; }
  #appView #medicalWorkspace .pb-name { display: flex; flex-wrap: nowrap; align-items: center; gap: 6px; min-width: 0; overflow: hidden; font-size: 17px; font-weight: 800; line-height: 24px; letter-spacing: -.2px; }
  #appView #medicalWorkspace .pb-name > span:first-child { flex: 0 0 auto; max-width: 72%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  #appView #medicalWorkspace .pb-name .ja { display: none; }
  #appView #medicalWorkspace .pb-flag { flex: 0 8 auto; min-width: 30px; max-width: none; height: 22px; min-height: 22px; overflow: hidden; padding: 0 8px; gap: 4px; font-size: 12px; line-height: 22px; white-space: nowrap; text-overflow: ellipsis; }
  #appView #medicalWorkspace .pb-flag svg { flex: none; }
  #appView #medicalWorkspace .pb-flag-btn { min-height: 22px; }
  /* Có cảnh báo (dị ứng, bệnh mạn tính, cờ đỏ): thêm một dòng chip dưới tên */
  #appView #medicalWorkspace #detailWrap:has(.pb-flag) { --med-bar: 90px; }
  #appView #medicalWorkspace #detailWrap:has(.pb-flag) .pb-name { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, max-content); grid-template-rows: 24px 22px; justify-content: start; gap: 4px 0; height: 50px; }
  #appView #medicalWorkspace #detailWrap:has(.pb-flag) .pb-name > span:first-child { grid-row: 1; grid-column: 1 / span 6; max-width: 100%; }
  #appView #medicalWorkspace #detailWrap:has(.pb-flag) .pb-flag { grid-row: 2; display: block; min-width: 0; max-width: 100%; margin-right: 6px; overflow: hidden; text-align: left; text-overflow: ellipsis; }
  #appView #medicalWorkspace #detailWrap:has(.pb-flag) .pb-flag svg { display: inline-block; margin-right: 3px; vertical-align: -2px; }
  #appView #medicalWorkspace .pb-facts { display: block; margin-top: 2px; overflow: hidden; color: var(--m-sub); font-size: 12.5px; line-height: 18px; text-overflow: ellipsis; white-space: nowrap; }
  #appView #medicalWorkspace .pb-facts > span { display: inline; padding: 0; border: 0; }
  #appView #medicalWorkspace .pb-facts > span + span::before { content: " · "; color: var(--m-faint); }
  #appView #medicalWorkspace .pb-facts .mrn { font-family: inherit; font-weight: 600; color: var(--m-ink); }
  #appView #medicalWorkspace .pb-actions { flex: none; width: auto; }
  #appView #medicalWorkspace .pb-actions #printBtn { display: inline-grid; place-items: center; width: 40px; min-width: 40px; height: 40px; min-height: 40px; padding: 0; border: 1px solid var(--m-line); border-radius: 12px; background: #fff; color: var(--m-ink); font-size: 0; }
  #appView #medicalWorkspace .pb-actions #printBtn svg { width: 18px; height: 18px; }
  /* Chặng chăm sóc: dải cuộn ngang dưới tên, không khung */
  #appView #medicalWorkspace .pb-journey { margin: 0 -12px; padding: 8px 12px 4px; overflow-x: auto; scrollbar-width: none; }
  #appView #medicalWorkspace .pb-journey::-webkit-scrollbar { display: none; }
  #appView #medicalWorkspace .journey { min-width: 480px; }
  #appView #medicalWorkspace .journey button { min-height: 48px; }
  #appView #medicalWorkspace .jdot { width: 24px; height: 24px; font-size: 12px; }
  #appView #medicalWorkspace .journey li + li::before { top: 12px; }
  #appView #medicalWorkspace .pb-alerts:not(:empty) { margin: 0 -12px; padding: 0 12px 8px; }
  /* Tab: dính ngay dưới dải tên */
  #appView #medicalWorkspace .tabs { position: sticky; top: calc(52px + var(--med-bar)); z-index: 21; gap: 22px; margin: 4px -12px 0; padding: 0 12px; background: #fff; border-bottom: 1px solid var(--m-line-soft); }
  #appView #medicalWorkspace .tab { min-height: 44px; }
  #appView #medicalWorkspace .tab[aria-selected="true"] .count { background: var(--m-accent-wash); color: #6E4A1C; }
  #appView #medicalWorkspace .tabs + div { height: 12px !important; }

  /* ---------- Tổng quan ---------- */
  #appView #medicalWorkspace .ov-stats { gap: 10px; }
  #appView #medicalWorkspace .ov-stat, #appView #medicalWorkspace .ov-stat.is-warn { min-height: 0; padding: 12px; border-radius: 12px; background: var(--m-wash); }
  #appView #medicalWorkspace .ov-stat:hover { background: var(--m-wash); }
  #appView #medicalWorkspace .ov-stat b { font-size: 20px; font-weight: 800; line-height: 26px; }
  #appView #medicalWorkspace .ov-stats > .ov-stat:last-child:nth-child(odd) { grid-column: 1 / -1; }
  #appView #medicalWorkspace .panel:not(aside):not(.lab-file):not(.care-file):not(.ttyt-saved):not(.intake-add):not(.lab-upload) { border-color: var(--m-line); border-radius: 14px; }
  #appView #medicalWorkspace .panel:not(aside):not(.lab-file):not(.care-file):not(.ttyt-saved) > .panel-head { flex-wrap: wrap; gap: 6px 8px; padding: 14px 14px 6px; font-size: 15px; line-height: 1.35; }
  #appView #medicalWorkspace .panel:not(aside):not(.lab-file):not(.care-file):not(.ttyt-saved) > .panel-head > span:first-of-type { flex: 1 1 200px; min-width: 0; }
  #appView #medicalWorkspace .panel:not(aside):not(.lab-file):not(.care-file):not(.ttyt-saved) > .panel-head > .spacer { display: none; }
  #appView #medicalWorkspace .panel:not(aside):not(.lab-file):not(.care-file):not(.ttyt-saved) > .panel-body { padding: 10px 14px 14px; }
  #appView #medicalWorkspace .kv { grid-template-columns: 104px minmax(0, 1fr) !important; }
  /* Chỉ số bất thường (bảng có thanh vị trí) → dòng thẻ: tên · kết quả + đơn vị / tham chiếu · cờ */
  #appView #medicalWorkspace .panel > .tbl-wrap:has(.rr) { overflow: visible; border: 0; border-radius: 0; }
  #appView #medicalWorkspace .panel > .tbl-wrap > table:has(.rr) { display: block; width: 100%; min-width: 0; }
  #appView #medicalWorkspace .panel > .tbl-wrap > table:has(.rr) thead { display: none; }
  #appView #medicalWorkspace .panel > .tbl-wrap > table:has(.rr) tbody { display: block; }
  #appView #medicalWorkspace .panel > .tbl-wrap > table:has(.rr) tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; column-gap: 10px; row-gap: 2px; padding: 10px 14px; border-top: 1px solid var(--m-line-soft); }
  #appView #medicalWorkspace .panel > .tbl-wrap > table:has(.rr) td { display: block; min-width: 0; padding: 0; border: 0; background: none; box-shadow: none; text-align: left; }
  #appView #medicalWorkspace .panel > .tbl-wrap > table:has(.rr) td:nth-child(1) { grid-column: 1; grid-row: 1; font-size: 14px; font-weight: 600; }
  #appView #medicalWorkspace .panel > .tbl-wrap > table:has(.rr) td:nth-child(2) { grid-column: 2; grid-row: 1; text-align: right; white-space: nowrap; }
  #appView #medicalWorkspace .panel > .tbl-wrap > table:has(.rr) td:nth-child(2) b { font-size: 16px; font-weight: 800; }
  #appView #medicalWorkspace .panel > .tbl-wrap > table:has(.rr) td:nth-child(3) { grid-column: 1; grid-row: 2; color: var(--m-sub); font-size: 12px; text-align: left; }
  #appView #medicalWorkspace .panel > .tbl-wrap > table:has(.rr) td:nth-child(3):not(:empty)::before { content: "Tham chiếu "; }
  #appView #medicalWorkspace .panel > .tbl-wrap > table:has(.rr) td:nth-child(4) { display: none; }
  #appView #medicalWorkspace .panel > .tbl-wrap > table:has(.rr) td:nth-child(5) { grid-column: 2; grid-row: 2; justify-self: end; }
  #appView #medicalWorkspace .panel > .tbl-wrap > table:has(.rr) tr.abn-high { box-shadow: inset 3px 0 0 var(--m-bad); }
  #appView #medicalWorkspace .panel > .tbl-wrap > table:has(.rr) tr.abn-low { box-shadow: inset 3px 0 0 #24498A; }
  #appView #medicalWorkspace .panel > .tbl-wrap > table:has(.rr) tr.abn-high td:nth-child(2) b { color: var(--m-bad); }
  #appView #medicalWorkspace .panel > .tbl-wrap > table:has(.rr) tr.abn-low td:nth-child(2) b { color: #24498A; }

  /* ---------- Phiếu y tế (thẻ đã lưu) ---------- */
  #appView #medicalWorkspace .panel > .panel-head > [data-delete-intake] { min-height: 40px; margin-left: auto; padding: 0 12px; border: 1px solid var(--m-line); border-radius: 12px; background: #fff; color: var(--m-bad); font-size: 13px; font-weight: 600; }
  #appView #medicalWorkspace .panel > .panel-body > .grid-4 { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px !important; }
  #appView #medicalWorkspace .panel > .panel-body > .grid-4 > div { padding: 10px 12px; border-radius: 12px; background: var(--m-wash); }
  #appView #medicalWorkspace .panel > .panel-body > .grid-4 .lbl { margin: 0 0 2px; color: var(--m-sub); font-size: 12px; font-weight: 500; }
  #appView #medicalWorkspace .panel > .panel-body > .grid-4 .mono { font-family: inherit; font-size: 16px !important; font-weight: 800 !important; }
  #appView #medicalWorkspace .panel > .panel-body > .field > .lbl { display: block; margin: 12px 0 2px; color: var(--m-sub); font-size: 13px; font-weight: 600; }
  #appView #medicalWorkspace .panel > .panel-body > .field > p { margin: 0; font-size: 14px; }

  /* ---------- Thẻ thêm mới (vùng nét đứt) ---------- */
  #appView #medicalWorkspace :is(.intake-add, .lab-upload, .care-upload) { border-radius: 14px; }
  #appView #medicalWorkspace .stack > :is(.intake-add, .lab-upload, .care-upload):first-child > button { min-height: 120px; padding: 18px; font-size: 14px; }
  #appView #medicalWorkspace .stack > :is(.intake-add, .lab-upload, .care-upload):not(:first-child) > button { flex-direction: row; justify-content: flex-start; min-height: 56px; padding: 12px 14px; font-size: 14px; text-align: left; }
  #appView #medicalWorkspace .stack > :is(.intake-add, .lab-upload, .care-upload):not(:first-child) .lab-plus { flex: none; width: 28px; height: 28px; font-size: 22px; }

  /* ---------- Thẻ xét nghiệm ---------- */
  #appView #medicalWorkspace .lab-file { border-color: var(--m-line); border-radius: 14px; }
  #appView #medicalWorkspace .lab-file-head { padding: 14px; }
  #appView #medicalWorkspace .lab-file-actions button, #appView #medicalWorkspace .ttyt-head button { height: 40px; border-color: var(--m-line); border-radius: 12px; }
  #appView #medicalWorkspace .lab-file .lab-results tr { padding: 10px 14px; }
  #appView #medicalWorkspace .lab-file .lab-results td:nth-child(2) b { font-size: 16px; font-weight: 800; }
  #appView #medicalWorkspace .lab-file .lab-results td .tag { min-height: 22px; white-space: nowrap; }

  /* ---------- Bảng tư vấn CSYT ---------- */
  #appView #medicalWorkspace .care-file { border-color: var(--m-line); border-radius: 14px; }
  #appView #medicalWorkspace .care-file-head { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; padding: 14px; }
  #appView #medicalWorkspace .care-file-head > .care-file-title { grid-column: 1 / -1; }
  #appView #medicalWorkspace .care-file-head > .spacer, #appView #medicalWorkspace .care-file-head > [hidden] { display: none; }
  #appView #medicalWorkspace .care-file-head > button { width: 100%; height: 40px; border-color: var(--m-line); border-radius: 12px; }
  #appView #medicalWorkspace .care-file-head > [data-care-delete] { color: var(--m-bad); }
  #appView #medicalWorkspace .care-view { background: var(--m-wash); }
  #appView #medicalWorkspace .care-doc:not(.care-pdf) { min-height: 160px; }
  #appView #medicalWorkspace .care-doc.care-pdf { height: 70dvh; }

  /* ---------- Hồ sơ đầy đủ KH ---------- */
  #appView #medicalWorkspace .fd-hero { padding: 14px; border-color: var(--m-line); border-radius: 14px; background: #fff; box-shadow: none; }
  #appView #medicalWorkspace .fd-hero-top { flex-wrap: wrap; gap: 8px; }
  #appView #medicalWorkspace .fd-hero-top .fd-hero-ic { display: none; }
  #appView #medicalWorkspace .fd-hero-title { flex: 1 1 100%; }
  #appView #medicalWorkspace .fd-hero-title h3 { flex-wrap: wrap; gap: 6px 8px; font-size: 17px; line-height: 1.3; }
  #appView #medicalWorkspace .fd-hero-title p { font-size: 13px; color: var(--m-sub); }
  #appView #medicalWorkspace :is(.fd-ver, .fd-latest) { white-space: nowrap; }
  #appView #medicalWorkspace .fd-hero-top .fd-lang { margin-left: 0; }
  #appView #medicalWorkspace .fd-contents { gap: 6px; margin-top: 12px; }
  #appView #medicalWorkspace .fd-contents li { padding: 6px 10px; border-color: var(--m-line-soft); border-radius: 999px; font-size: 12.5px; }
  #appView #medicalWorkspace .fd-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 14px; padding-top: 14px; border-top-color: var(--m-line-soft); }
  #appView #medicalWorkspace .fd-actions .spacer { display: none; }
  #appView #medicalWorkspace .fd-actions button { justify-content: center; min-height: 44px; border-radius: 12px; font-size: 14px; }
  #appView #medicalWorkspace .fd-actions .bronze { grid-column: 1 / -1; min-height: 46px; font-size: 15px; }
  #appView #medicalWorkspace .fd-versions { padding: 0 14px 8px; }

  /* ---------- Tài liệu y tế ---------- */
  #appView #medicalWorkspace details.panel { border-color: var(--m-line); border-radius: 14px; }
  #appView #medicalWorkspace .doc-bundles { padding: 0 14px 6px; }
  #appView #medicalWorkspace .doc-bundles > li { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: center; gap: 8px; padding: 12px 0; }
  #appView #medicalWorkspace .doc-bundles > li > div { grid-column: 1 / 3; min-width: 0; display: flex; flex-direction: column; }
  #appView #medicalWorkspace .doc-bundles > li > div b { font-size: 15px; overflow-wrap: anywhere; }
  #appView #medicalWorkspace .doc-bundles > li > div small { color: var(--m-sub); font-size: 12.5px; }
  #appView #medicalWorkspace .doc-bundles > li > .tag { grid-column: 3; grid-row: 1; justify-self: end; }
  #appView #medicalWorkspace .doc-bundles > li > button { width: 100%; min-width: 0; min-height: 40px; padding: 0 6px; border-color: var(--m-line); border-radius: 12px; font-size: 13px; white-space: nowrap; }
  #appView #medicalWorkspace .doc-bundles > li > [data-del-bundle] { color: var(--m-bad); }

  #appView #medicalWorkspace .doc-row { gap: 4px 10px; }
  #appView #medicalWorkspace .doc-row > button { min-height: 40px; border-radius: 12px; }

  /* ==========================================================================
     Hộp thoại
     ========================================================================== */
  /* Lớn → toàn màn: đầu dính 56px, nội dung cuộn */
  #appView :is(#intakeDialog, #hubIntakeDialog, #sentDialog, #fdViewDialog, #bundleWizard)[open] {
    position: fixed; inset: 0; width: 100%; max-width: 100%; height: 100dvh; max-height: 100dvh; margin: 0; padding: 0;
    border: 0; border-radius: 0; background: #fff; box-shadow: none; animation: none;
  }
  /* Nhỏ → tấm trượt từ dưới */
  #appView :is(#fdSendDialog, #redFlagDialog)[open] {
    position: fixed; inset: auto 0 0 0; width: 100%; max-width: 100%; max-height: 92dvh; margin: 0; padding: 0;
    border: 0; border-radius: 20px 20px 0 0; background: #fff; box-shadow: 0 -10px 40px #392e2233; overflow: auto; overscroll-behavior: contain;
  }
  /* Đầu hộp thoại: tiêu đề 16/800 + nút ✕ 40px */
  #appView dialog[open] > .intake-dialog-head, #appView #redFlagDialog > header {
    position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 8px; min-height: 56px; box-sizing: border-box;
    padding: 8px 8px 8px 16px; border-bottom: 1px solid var(--m-line-soft); background: #fff;
  }
  #appView dialog[open] > .intake-dialog-head h2, #appView #redFlagDialog > header h2 {
    flex: 1 1 auto; min-width: 0; margin: 0; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden;
    font-size: 16px; font-weight: 800; line-height: 1.3; letter-spacing: -.1px; color: var(--m-ink); text-transform: none; white-space: normal;
  }
  #appView dialog[open] > .intake-dialog-head h2::before { content: none; }
  #appView dialog[open] > .intake-dialog-head h2::first-letter { text-transform: none; }
  #appView :is(#intakeDialog, #hubIntakeDialog) .intake-dialog-head h2 { text-transform: lowercase; }
  #appView :is(#intakeDialog, #hubIntakeDialog) .intake-dialog-head h2::first-letter { text-transform: uppercase; }
  #appView dialog[open] > .intake-dialog-head > div:first-child { flex: 1 1 auto; min-width: 0; }
  #appView dialog[open] > .intake-dialog-head > div:first-child h2 { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  #appView dialog[open] > .intake-dialog-head > div:first-child p { margin: 2px 0 0; overflow: hidden; color: var(--m-sub); font-size: 12.5px; text-overflow: ellipsis; white-space: nowrap; }
  #appView dialog[open] .intake-dialog-head :is(#closeIntakeDialog, #closeSentDialog, #fdViewClose, #fdSendClose, #bwClose),
  #appView dialog[open] > header > #rfClose, #appView dialog#hubIntakeDialog[open] > .intake-dialog-head > button:last-child {
    position: relative; flex: none; display: inline-grid; place-items: center; width: 40px; min-width: 40px; height: 40px; min-height: 40px;
    padding: 0; border: 0; border-radius: 12px; background: var(--m-wash); color: var(--m-ink); font-size: 0; box-shadow: none;
  }
  #appView dialog[open] .intake-dialog-head :is(#closeIntakeDialog, #closeSentDialog, #fdViewClose, #fdSendClose, #bwClose)::before,
  #appView dialog[open] > header > #rfClose::before, #appView dialog#hubIntakeDialog[open] > .intake-dialog-head > button:last-child::before {
    content: ""; width: 18px; height: 18px; background: currentColor; -webkit-mask: var(--m-x-ico) center / contain no-repeat; mask: var(--m-x-ico) center / contain no-repeat;
  }

  /* ---------- Bảng thu thập thông tin y tế (#intakeDialog / #hubIntakeDialog) ---------- */
  #appView :is(#intakeDialog, #hubIntakeDialog) .ttyt-form > .panel-body { padding: 0 16px; }
  #appView :is(#intakeDialog, #hubIntakeDialog) .ttyt-ocr-bar { margin: 12px 0 0; gap: 8px; }
  #appView :is(#intakeDialog, #hubIntakeDialog) #ttyt_ocr { width: 100%; min-height: 44px; justify-content: center; border: 1px dashed #C9AE85; border-radius: 12px; background: var(--m-accent-wash); color: #6E4A1C; font-size: 14px; }
  #appView :is(#intakeDialog, #hubIntakeDialog) .ttyt-ocr-bar p { font-size: 13px; }
  /* Thanh trang: dính dưới đầu hộp thoại, 4 bước thẳng hàng */
  #appView :is(#intakeDialog, #hubIntakeDialog) .ttyt-nav {
    position: sticky; top: 56px; z-index: 4; display: flex; align-items: center; gap: 6px; margin: 12px -16px 0; padding: 8px 16px;
    border-bottom: 1px solid var(--m-line-soft); background: #fff; overflow-x: auto; scrollbar-width: none;
  }
  #appView :is(#intakeDialog, #hubIntakeDialog) .ttyt-nav::-webkit-scrollbar { display: none; }
  #appView :is(#intakeDialog, #hubIntakeDialog) .ttyt-nav button { flex: 0 0 auto; gap: 6px; min-height: 40px; padding: 0 10px 0 6px; border-radius: 20px; font-size: 13px; }
  #appView :is(#intakeDialog, #hubIntakeDialog) .ttyt-nav button + button::before { content: none; }
  #appView :is(#intakeDialog, #hubIntakeDialog) .ttyt-nav button:not([aria-pressed="true"]) { padding: 0 6px; }
  #appView :is(#intakeDialog, #hubIntakeDialog) .ttyt-nav button[aria-pressed="true"] { flex: 1 1 auto; justify-content: flex-start; background: var(--m-accent-wash); }
  #appView :is(#intakeDialog, #hubIntakeDialog) .ttyt-step-no { width: 28px; height: 28px; }
  /* Nhóm trường: phẳng, phân nhóm bằng tiêu đề */
  #appView :is(#intakeDialog, #hubIntakeDialog) [data-ttyt-panel] > h3 { margin: 16px 0 4px; font-size: 16px; font-weight: 800; line-height: 1.35; }
  #appView :is(#intakeDialog, #hubIntakeDialog) [data-ttyt-panel]:not(:is([data-ttyt-panel="2"], [data-ttyt-panel="3"])) .ttyt-section { margin: 0; padding: 16px 0 4px; border: 0; border-radius: 0; background: none; box-shadow: none; }
  #appView :is(#intakeDialog, #hubIntakeDialog) [data-ttyt-panel]:not(:is([data-ttyt-panel="2"], [data-ttyt-panel="3"])) .ttyt-section + .ttyt-section { border-top: 1px solid var(--m-line-soft); }
  #appView :is(#intakeDialog, #hubIntakeDialog) [data-ttyt-panel]:not(:is([data-ttyt-panel="2"], [data-ttyt-panel="3"])) .ttyt-section > h3 { margin: 0 0 10px; padding: 0; border: 0; font-size: 15px; font-weight: 700; }
  #appView :is(#intakeDialog, #hubIntakeDialog) .ttyt-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 10px; }
  #appView :is(#intakeDialog, #hubIntakeDialog) .ttyt-grid > .field { margin: 0; grid-column: 1 / -1; }
  /* Cặp ngắn 2 cột: chiều cao + cân nặng, vòng bụng + vòng mông */
  #appView :is(#intakeDialog, #hubIntakeDialog) .ttyt-grid > .field:is(:has(#ttyt_heightCm), :has(#ttyt_weightKg), :has(#ttyt_waistCm), :has(#ttyt_hipCm)) { grid-column: auto; }
  #appView :is(#intakeDialog, #hubIntakeDialog) .ttyt-grid label, #appView :is(#intakeDialog, #hubIntakeDialog) .ttyt-grid .lbl { margin-bottom: 4px; color: var(--m-sub); font-size: 13px; font-weight: 600; line-height: 1.4; }
  #appView :is(#intakeDialog, #hubIntakeDialog) .ttyt-grid :is(input:not([type=radio]):not([type=checkbox]), select) { width: 100%; min-height: 46px; border-color: var(--m-line); border-radius: 12px; font-size: 16px; }
  #appView :is(#intakeDialog, #hubIntakeDialog) .ttyt-grid textarea { width: 100%; min-height: 88px; border-color: var(--m-line); border-radius: 12px; font-size: 16px; }
  #appView :is(#intakeDialog, #hubIntakeDialog) .ttyt-grid input[readonly] { background: var(--m-wash); color: var(--m-sub); }
  #appView :is(#intakeDialog, #hubIntakeDialog) .ttyt-delivery legend { margin-bottom: 6px; color: var(--m-sub); font-size: 13px; font-weight: 600; }
  #appView :is(#intakeDialog, #hubIntakeDialog) .ttyt-delivery-opt { border-color: var(--m-line); border-radius: 12px; }
  #appView :is(#intakeDialog, #hubIntakeDialog) #ttyt_signatureCanvas { width: 100%; height: 160px; border-color: var(--m-line); border-radius: 12px; }
  #appView :is(#intakeDialog, #hubIntakeDialog) #ttyt_clearSignature { min-height: 40px; border-radius: 12px; }
  /* Trang tiền sử: mỗi bệnh một thẻ gọn, câu hỏi trên, ô chọn dưới */
  #appView :is(#intakeDialog, #hubIntakeDialog) :is([data-ttyt-panel="2"], [data-ttyt-panel="3"]) .ttyt-section { display: block; margin: 0 0 10px; padding: 12px 14px; border: 1px solid var(--m-line); border-radius: 14px; }
  #appView :is(#intakeDialog, #hubIntakeDialog) :is([data-ttyt-panel="2"], [data-ttyt-panel="3"]) .ttyt-section > h3 { margin: 0 0 8px; padding: 0; border: 0; font-size: 14px; font-weight: 600; line-height: 1.4; }
  #appView :is(#intakeDialog, #hubIntakeDialog) :is([data-ttyt-panel="2"], [data-ttyt-panel="3"]) .ttyt-section > .ttyt-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
  #appView :is(#intakeDialog, #hubIntakeDialog) :is([data-ttyt-panel="2"], [data-ttyt-panel="3"]) .ttyt-section > .ttyt-grid > .field:is(:first-child, :not(:first-child)) { grid-column: 1; grid-row: auto; justify-self: stretch; width: 100%; }
  #appView :is(#intakeDialog, #hubIntakeDialog) :is([data-ttyt-panel="2"], [data-ttyt-panel="3"]) .ttyt-section > .ttyt-grid textarea { min-height: 72px; }
  #appView :is(#intakeDialog, #hubIntakeDialog) :is([data-ttyt-panel="2"], [data-ttyt-panel="3"]) > h3 + .ttyt-section { margin-top: 10px; }
  /* Thanh nút: một hàng dính đáy — ‹ Trước · Sau › · Lưu phiếu */
  #appView :is(#intakeDialog, #hubIntakeDialog) .ttyt-actions {
    position: sticky; bottom: 0; z-index: 4; display: flex; flex-wrap: nowrap; gap: 8px; margin: 16px -16px 0;
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px)); border-top: 1px solid var(--m-line); background: #fff; box-shadow: 0 -6px 20px #392e221a;
  }
  #appView :is(#intakeDialog, #hubIntakeDialog) .ttyt-actions button { flex: 1 1 0; min-width: 0; min-height: 46px; margin: 0; padding: 0 8px; border-radius: 12px; font-size: 15px; white-space: nowrap; }
  #appView :is(#intakeDialog, #hubIntakeDialog) .ttyt-actions #ttyt_next { margin-left: 0; }
  #appView :is(#intakeDialog, #hubIntakeDialog) .ttyt-actions #saveIntakeBtn { flex: 1.4 1 0; min-width: 0; }
  #appView :is(#intakeDialog, #hubIntakeDialog) .ttyt-actions #ttyt_prev:disabled { opacity: .45; }

  /* ---------- Xem hồ sơ (#fdViewDialog) + hồ sơ đã gửi (#sentDialog) ---------- */
  #appView :is(#sentDialog, #fdViewDialog)[open] { display: flex; flex-direction: column; overflow: hidden; }
  #appView :is(#sentDialog, #fdViewDialog) > .intake-dialog-head { flex: none; background: #fff; }
  #appView #fdViewDialog > .intake-dialog-head { flex-wrap: wrap; align-items: flex-start; padding: 8px 12px 10px 16px; }
  #appView #fdViewDialog > .intake-dialog-head > div:first-child { flex: 1 1 calc(100% - 56px); padding: 6px 48px 0 0; }
  #appView #fdViewDialog > .intake-dialog-head > div:first-child p { margin-left: 0; }
  #appView #fdViewDialog .fd-view-tools { display: flex; flex-wrap: nowrap; align-items: center; gap: 8px; width: 100%; }
  #appView #fdViewDialog .fd-view-tools > .fd-seg { flex: 1 1 auto; min-width: 0; }
  #appView #fdViewDialog .fd-seg button { flex: 1 1 0; min-height: 34px; padding: 0 8px; font-size: 13px; white-space: nowrap; }
  #appView #fdViewDialog .fd-view-tools > button { flex: none; min-height: 40px; padding: 0 12px; border-color: var(--m-line); border-radius: 12px; }
  #appView #fdViewDialog #fdViewClose { position: absolute; top: 8px; right: 8px; }
  /* Gửi chuyên gia: dải nút dính đáy */
  #appView #fdViewDialog #fdViewSend { position: fixed; left: 12px; right: 12px; bottom: calc(10px + env(safe-area-inset-bottom, 0px)); z-index: 6; justify-content: center; min-height: 46px; border-radius: 12px; font-size: 15px; box-shadow: 0 0 0 10px #fff, 0 -14px 24px #fff; }
  #appView #fdViewDialog:has(#fdViewSend:not([hidden])) .sent-record-content { padding-bottom: calc(84px + env(safe-area-inset-bottom, 0px)); }
  #appView :is(#sentDialog, #fdViewDialog) .sent-records { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; height: auto; }
  #appView :is(#sentDialog, #fdViewDialog) .sent-record-nav { flex: none; flex-direction: row; flex-wrap: nowrap; gap: 6px; padding: 8px 12px; border: 0; border-bottom: 1px solid var(--m-line-soft); background: #fff; overflow-x: auto; scrollbar-width: none; }
  #appView :is(#sentDialog, #fdViewDialog) .sent-record-nav::-webkit-scrollbar { display: none; }
  #appView :is(#sentDialog, #fdViewDialog) .sent-record-nav button { flex: 0 0 auto; min-height: 36px; height: 36px; padding: 0 14px; border: 1px solid var(--m-line); border-radius: 18px; background: #fff; box-shadow: none; color: var(--m-ink); font-size: 13px; font-weight: 600; white-space: nowrap; }
  #appView :is(#sentDialog, #fdViewDialog) .sent-record-nav button svg { display: none; }
  #appView :is(#sentDialog, #fdViewDialog) .sent-record-nav button[aria-pressed="true"] { border-color: #E3C79E; background: var(--m-accent-wash); color: #6E4A1C; box-shadow: none; }
  #appView :is(#sentDialog, #fdViewDialog) .sent-record-nav .sent-record-advice { flex-basis: auto; margin: 0; border-color: #B4E0C1; background: var(--m-ok-wash); color: var(--m-ok); outline: 0; }
  #appView #fdViewDialog .fd-nav-label small { display: none; }
  #appView #fdViewDialog .fd-nav-label b { font-weight: 600; }
  #appView :is(#sentDialog, #fdViewDialog) .sent-record-content { flex: 1 1 auto; min-height: 0; padding: 14px 16px 24px; overflow: auto; overscroll-behavior: contain; }
  #appView :is(#sentDialog, #fdViewDialog) .record-detail { font-size: 14px; }
  #appView :is(#sentDialog, #fdViewDialog) .record-detail h3 { font-size: 15px; color: var(--m-ink); }
  #appView :is(#sentDialog, #fdViewDialog) .record-detail .record-answer { padding: 9px 0; background: none; }
  #appView :is(#sentDialog, #fdViewDialog) .record-detail .record-answer:nth-of-type(odd) { background: none; }
  #appView :is(#sentDialog, #fdViewDialog) .record-detail .record-answer:has(> .record-question),
  #appView :is(#sentDialog, #fdViewDialog) .record-detail .record-answer > :is(.record-vi, .record-ja):has(> .record-question) { grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; }
  #appView :is(#sentDialog, #fdViewDialog) .record-detail .record-question { color: var(--m-sub); font-size: 13px; }
  #appView :is(#sentDialog, #fdViewDialog) .record-detail .record-response { text-align: right; overflow-wrap: anywhere; }
  #appView #fdViewDialog .fd-sec-title { font-size: 16px; }
  /* Bảng xét nghiệm trong hồ sơ → dòng thẻ: tên · kết quả + đơn vị / tham chiếu · đánh giá / lần trước */
  #appView :is(#sentDialog, #fdViewDialog) .record-detail .record-table:has(th:nth-child(6)) { overflow: visible; border-radius: 12px; }
  #appView :is(#sentDialog, #fdViewDialog) .record-table:has(th:nth-child(6)) table { display: block; width: 100%; min-width: 0; table-layout: auto; }
  #appView :is(#sentDialog, #fdViewDialog) .record-table:has(th:nth-child(6)) thead { display: none; }
  #appView :is(#sentDialog, #fdViewDialog) .record-table:has(th:nth-child(6)) tbody { display: block; }
  #appView :is(#sentDialog, #fdViewDialog) .record-table:has(th:nth-child(6)) tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 10px; row-gap: 2px; padding: 10px 12px; }
  #appView :is(#sentDialog, #fdViewDialog) .record-table:has(th:nth-child(6)) tr + tr { border-top: 1px solid var(--m-line-soft); }
  #appView :is(#sentDialog, #fdViewDialog) .record-table:has(th:nth-child(6)) td { display: block; min-width: 0; padding: 0; border: 0; background: none; text-align: left; font-size: 13px; }
  #appView :is(#sentDialog, #fdViewDialog) .record-table:has(th:nth-child(6)) td:nth-child(1) { grid-column: 1; grid-row: 1; font-size: 14px; font-weight: 600; }
  #appView :is(#sentDialog, #fdViewDialog) .record-table:has(th:nth-child(6)) td:nth-child(4) { grid-column: 2; grid-row: 1; justify-self: end; font-size: 16px; font-weight: 800; text-align: right; }
  #appView :is(#sentDialog, #fdViewDialog) .record-table:has(th:nth-child(6)) td:nth-child(2) { grid-column: 2; grid-row: 2; justify-self: end; color: var(--m-sub); font-size: 12px; }
  #appView :is(#sentDialog, #fdViewDialog) .record-table:has(th:nth-child(6)) td:nth-child(3) { grid-column: 1; grid-row: 2; color: var(--m-sub); font-size: 12px; }
  #appView :is(#sentDialog, #fdViewDialog) .record-table:has(th:nth-child(6)) td:nth-child(3):not(:empty)::before { content: "Tham chiếu "; }
  #appView :is(#sentDialog, #fdViewDialog) .record-table:has(th:nth-child(6)) td:nth-child(5) { grid-column: 1; grid-row: 3; color: var(--m-sub); font-size: 12px; }
  #appView :is(#sentDialog, #fdViewDialog) .record-table:has(th:nth-child(6)) td:nth-child(5):not(:empty)::before { content: "Lần trước "; }
  #appView :is(#sentDialog, #fdViewDialog) .record-table:has(th:nth-child(6)) td:nth-child(6) { grid-column: 2; grid-row: 3; justify-self: end; font-size: 12px; font-weight: 700; }
  #appView :is(#sentDialog, #fdViewDialog) .record-table:has(th:nth-child(6)) tr.record-high { box-shadow: inset 3px 0 0 var(--m-bad); }
  #appView :is(#sentDialog, #fdViewDialog) .record-table:has(th:nth-child(6)) tr.record-high td { background: none; }
  #appView :is(#sentDialog, #fdViewDialog) .record-table:has(th:nth-child(6)) tr.record-high td:nth-child(4), #appView :is(#sentDialog, #fdViewDialog) .record-table:has(th:nth-child(6)) tr.record-high td:nth-child(6) { color: var(--m-bad); }

  /* Bảng 5 cột (Chỉ số · Kết quả · Đơn vị · Tham chiếu · Đánh giá) → dòng thẻ */
  #appView :is(#sentDialog, #fdViewDialog) .record-detail .record-table:has(th:nth-child(5)):not(:has(th:nth-child(6))) { overflow: visible; border-radius: 12px; }
  #appView :is(#sentDialog, #fdViewDialog) .record-table:has(th:nth-child(5)):not(:has(th:nth-child(6))) table { display: block; width: 100%; min-width: 0; table-layout: auto; }
  #appView :is(#sentDialog, #fdViewDialog) .record-table:has(th:nth-child(5)):not(:has(th:nth-child(6))) thead { display: none; }
  #appView :is(#sentDialog, #fdViewDialog) .record-table:has(th:nth-child(5)):not(:has(th:nth-child(6))) tbody { display: block; }
  #appView :is(#sentDialog, #fdViewDialog) .record-table:has(th:nth-child(5)):not(:has(th:nth-child(6))) tr { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: baseline; column-gap: 6px; row-gap: 2px; padding: 10px 12px; }
  #appView :is(#sentDialog, #fdViewDialog) .record-table:has(th:nth-child(5)):not(:has(th:nth-child(6))) tr + tr { border-top: 1px solid var(--m-line-soft); }
  #appView :is(#sentDialog, #fdViewDialog) .record-table:has(th:nth-child(5)):not(:has(th:nth-child(6))) td { display: block; min-width: 0; padding: 0; border: 0; background: none; text-align: left; font-size: 13px; }
  #appView :is(#sentDialog, #fdViewDialog) .record-table:has(th:nth-child(5)):not(:has(th:nth-child(6))) td:nth-child(1) { grid-column: 1; grid-row: 1; font-size: 14px; font-weight: 600; }
  #appView :is(#sentDialog, #fdViewDialog) .record-table:has(th:nth-child(5)):not(:has(th:nth-child(6))) td:nth-child(2) { grid-column: 2; grid-row: 1; font-size: 16px; font-weight: 800; text-align: right; }
  #appView :is(#sentDialog, #fdViewDialog) .record-table:has(th:nth-child(5)):not(:has(th:nth-child(6))) td:nth-child(3) { grid-column: 3; grid-row: 1; color: var(--m-sub); font-size: 12px; }
  #appView :is(#sentDialog, #fdViewDialog) .record-table:has(th:nth-child(5)):not(:has(th:nth-child(6))) td:nth-child(4) { grid-column: 1; grid-row: 2; color: var(--m-sub); font-size: 12px; }
  #appView :is(#sentDialog, #fdViewDialog) .record-table:has(th:nth-child(5)):not(:has(th:nth-child(6))) td:nth-child(4):not(:empty)::before { content: "Tham chiếu "; }
  #appView :is(#sentDialog, #fdViewDialog) .record-table:has(th:nth-child(5)):not(:has(th:nth-child(6))) td:nth-child(5) { grid-column: 2 / 4; grid-row: 2; justify-self: end; font-size: 12px; font-weight: 700; }
  #appView :is(#sentDialog, #fdViewDialog) .record-table:has(th:nth-child(5)):not(:has(th:nth-child(6))) tr.record-high { box-shadow: inset 3px 0 0 var(--m-bad); }
  #appView :is(#sentDialog, #fdViewDialog) .record-table:has(th:nth-child(5)):not(:has(th:nth-child(6))) tr.record-high td { background: none; }
  #appView :is(#sentDialog, #fdViewDialog) .record-table:has(th:nth-child(5)):not(:has(th:nth-child(6))) tr.record-high :is(td:nth-child(2), td:nth-child(5)) { color: var(--m-bad); }
  #appView :is(#sentDialog, #fdViewDialog) .record-detail .advice-block { padding: 12px 14px; border-radius: 12px; box-shadow: none; }

  /* ---------- Phiên đã gửi chuyên gia (thẻ trong tab Hồ sơ đầy đủ) ---------- */
  #appView #medicalWorkspace .panel > .panel-head > .tag { margin-right: auto; }
  #appView #medicalWorkspace .panel > .panel-head > [data-consult-print] { display: inline-grid; place-items: center; width: 40px; min-width: 40px; height: 40px; min-height: 40px; padding: 0; border: 1px solid var(--m-line); border-radius: 12px; background: #fff; font-size: 0; }
  #appView #medicalWorkspace .panel > .panel-head > [data-consult-print] svg { width: 18px; height: 18px; }
  #appView #medicalWorkspace .panel > .panel-head > [data-consult-delete] { min-height: 40px; padding: 0 12px; border: 1px solid var(--m-line); border-radius: 12px; background: #fff; color: var(--m-bad); font-size: 13px; font-weight: 600; }
  #appView #medicalWorkspace .sent-open { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; padding: 0; border: 0; border-radius: 0; background: none; box-shadow: none; }
  #appView #medicalWorkspace .sent-open > .sent-open-ic { display: none; }
  #appView #medicalWorkspace .sent-open > div { flex: 1 1 100%; min-width: 0; }
  #appView #medicalWorkspace .sent-open > div small { display: block; overflow: visible; color: var(--m-sub); font-size: 12.5px; white-space: normal; }
  #appView #medicalWorkspace .sent-open > button { flex: 1 1 100%; justify-content: center; min-height: 44px; border-radius: 12px; }
  #appView #medicalWorkspace .notice { border-radius: 12px; }

  /* ---------- Gửi hồ sơ cho chuyên gia (#fdSendDialog) ---------- */
  #appView #fdSendDialog > .intake-dialog-head { background: #fff; }
  #appView #fdSendDialog > .intake-dialog-head h2, #appView :is(#sentDialog, #fdViewDialog) > .intake-dialog-head h2 { color: var(--m-ink); }
  #appView #fdSendDialog .fd-send-body { gap: 14px; padding: 14px 16px 0; }
  #appView #fdSendDialog .fd-send-doc { flex-wrap: wrap; gap: 6px 10px; padding: 12px 14px; border-color: var(--m-line); border-radius: 14px; }
  #appView #fdSendDialog .fd-send-doc .fd-hero-ic { display: none; }
  #appView #fdSendDialog .fd-send-doc > div { flex: 1 1 100%; }
  #appView #fdSendDialog .fd-send-doc b { font-size: 15px; }
  #appView #fdSendDialog .fd-send-doc small { font-size: 12.5px; line-height: 1.45; }
  #appView #fdSendDialog .fd-check { gap: 12px; padding: 12px; font-size: 14px; }
  #appView #fdSendDialog .fd-check input { flex: none; width: 20px; height: 20px; }
  #appView #fdSendDialog .field label { color: var(--m-sub); font-size: 13px; font-weight: 600; }
  #appView #fdSendDialog .field :is(input, select) { width: 100%; min-height: 46px; border-color: var(--m-line); border-radius: 12px; font-size: 16px; }
  #appView #fdSendDialog .fd-note { align-items: flex-start; font-size: 13px; }
  #appView #fdSendDialog .fd-send-foot { position: sticky; bottom: 0; display: flex; gap: 8px; margin: 0 -16px; padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px)); border-top: 1px solid var(--m-line); background: #fff; }
  #appView #fdSendDialog .fd-send-foot button { flex: 1 1 0; justify-content: center; min-height: 46px; border-radius: 12px; font-size: 15px; }
  #appView #fdSendDialog .fd-send-foot .bronze { flex: 1.6 1 0; }

  /* ---------- Cờ đỏ (#redFlagDialog) ---------- */
  #appView #redFlagDialog[open] { display: flex; flex-direction: column; }
  #appView #redFlagDialog > header { flex: none; border-bottom-color: #F3C9C4; background: var(--m-bad-wash); }
  #appView #redFlagDialog > header h2 { display: flex; align-items: center; gap: 6px; color: var(--m-bad); }
  #appView #redFlagDialog > header #rfClose { background: #fff; }
  #appView #redFlagDialog .rf-note { margin: 10px 16px 0; font-size: 13px; }
  #appView #redFlagDialog .rf-list { padding: 10px 16px 14px 34px; }
  #appView #redFlagDialog .rf-src { grid-template-columns: minmax(0, 1fr); border-color: var(--m-line-soft); border-radius: 12px; }
  #appView #redFlagDialog .rf-src button { justify-self: start; min-height: 40px; border-radius: 12px; }
  #appView #redFlagDialog > footer { padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px)); }
  #appView #redFlagDialog > footer button { width: 100%; min-height: 46px; border-radius: 12px; }

  /* ---------- Thêm bộ hồ sơ nhiều loại (#bundleWizard) ---------- */
  #appView #bundleWizard[open] { display: flex; flex-direction: column; overflow: hidden; }
  #appView #bundleWizard > .intake-dialog-head { flex: none; }
  #appView #bundleWizard .bw-steps { flex: none; margin: 0; padding: 10px 16px; border-bottom: 1px solid var(--m-line-soft); overflow-x: auto; scrollbar-width: none; }
  #appView #bundleWizard .bw-steps::-webkit-scrollbar { display: none; }
  #appView #bundleWizard .bw-body { flex: 1 1 auto; min-height: 0; padding: 14px 16px; overflow: auto; overscroll-behavior: contain; }
  #appView #bundleWizard .bw-foot { flex: none; display: flex; flex-wrap: wrap; gap: 8px; padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px)); border-top: 1px solid var(--m-line); background: #fff; }
  #appView #bundleWizard .bw-foot:empty { display: none; }
  #appView #bundleWizard .bw-foot button { flex: 1 1 0; justify-content: center; min-width: 0; min-height: 46px; padding: 0 10px; border-radius: 12px; font-size: 15px; white-space: nowrap; }
  #appView #bundleWizard .bw-foot button:is(.primary, .bronze) { flex: 1.6 1 0; }
  #appView #bundleWizard > .intake-dialog-head { background: #fff; }
  #appView #bundleWizard > .intake-dialog-head h2 { color: var(--m-ink); }
  #appView #bundleWizard .bw-foot .spacer, #appView #bundleWizard .bw-foot > span:empty { display: none; }
  #appView #bundleWizard .bw-foot .bw-foot-note { flex: 1 1 100%; font-size: 12.5px; }
  #appView #bundleWizard .bw-x { width: 40px; height: 40px; border-radius: 12px; font-size: 20px; }
  #appView #bundleWizard .bw-rec { padding: 12px 14px; border-color: var(--m-line); border-radius: 14px; }
  #appView #bundleWizard .bw-rec-ic { display: none; }
  #appView #bundleWizard .bw-rec-head b { font-size: 15px; line-height: 1.35; }
  #appView #bundleWizard .bw-rec-head small { font-size: 12.5px; }
  #appView #bundleWizard .bw-rec-state { font-size: 12px; }
  #appView #bundleWizard .bw-warn { display: block; padding: 8px 10px; border-radius: 10px; line-height: 1.45; }
  #appView #bundleWizard .bw-concl { font-size: 13.5px; }
  #appView #bundleWizard .bw-rec footer { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  #appView #bundleWizard .bw-rec footer .spacer { display: none; }
  #appView #bundleWizard .bw-rec footer [data-file] { grid-column: 1 / -1; justify-self: start; max-width: 100%; min-height: 36px; padding: 0 4px; }
  #appView #bundleWizard .bw-rec footer button:not([data-file]) { width: 100%; min-height: 40px; border-radius: 12px; font-size: 14px; }
  #appView #bundleWizard .bw-edit-grid { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  #appView #bundleWizard .bw-edit-grid label { display: grid; gap: 4px; color: var(--m-sub); font-size: 13px; font-weight: 600; }
  #appView #bundleWizard .bw-edit [data-saveedit] { width: 100%; min-height: 44px; margin-top: 10px; border-radius: 12px; }
  #appView #bundleWizard .bw-sum { gap: 6px 10px; font-size: 13.5px; }
}
/* Xem file tài liệu / tiến trình gửi: gắn vào body (ngoài #appView) */
@media screen and (max-width: 760px) {
  body.sales-shell dialog.doc-viewer[open] { inset: 0; width: 100%; max-width: 100%; height: 100dvh; max-height: 100dvh; margin: 0; padding: 0; border: 0; border-radius: 0; animation: none; }
  body.sales-shell .doc-viewer > header { gap: 8px; min-height: 56px; padding: 8px 8px 8px 16px; }
  body.sales-shell .doc-viewer > header h2 { flex: 1 1 auto; font-size: 16px; font-weight: 800; }
  body.sales-shell .doc-viewer > header .spacer { display: none; }
  body.sales-shell .doc-viewer #dvDownload { min-height: 40px; border-radius: 12px; }
  body.sales-shell .doc-viewer #dvClose { width: 40px; min-width: 40px; height: 40px; min-height: 40px; padding: 0; border: 0; border-radius: 12px; background: #FAF6EF; font-size: 0; }
  body.sales-shell .doc-viewer #dvClose::before { content: ""; display: block; width: 18px; height: 18px; margin: auto; background: #25211C; -webkit-mask: var(--m-x-ico) center / contain no-repeat; mask: var(--m-x-ico) center / contain no-repeat; }
  body.sales-shell dialog.cp-dialog[open] { padding: 20px 16px calc(20px + env(safe-area-inset-bottom, 0px)); background: #fff; color: #25211C; border: 0; }
  body.sales-shell .cp-dialog h2 { font-size: 16px; font-weight: 800; }
}

/* ===== MOBILE 11/2026 — Đợt 2: mật độ & căn chữ (docs/MOBILE-UI-SPEC.md "Đợt 2") =====
   Ghi đè khối đợt 1 ở trên: dải bệnh nhân thấp hơn, chặng chăm sóc thành dải chip, ô số → một dải,
   dòng chỉ số ~48px, cặp nhãn–giá trị một dòng 32px, đầu thẻ 1 dòng, nút 32px trong thẻ. */
@media screen and (max-width: 760px) {
  body.sales-shell { --med-bar: 58px; }
  /* Danh sách hồ sơ: thẻ gọn ~64px */
  #appView #medicalWorkspace .plist { gap: 8px; }
  #appView #medicalWorkspace .pitem { padding: 10px 12px; }
  #appView #medicalWorkspace .pitem .pav { width: 36px; height: 36px; font-size: 13px; }
  #appView #medicalWorkspace .pitem .nm { font-size: 15px; line-height: 1.25; }
  #appView #medicalWorkspace .pitem .row2 { margin-top: 2px; gap: 0; overflow: hidden; color: var(--m-sub); font-size: 13px; line-height: 1.35; white-space: nowrap; text-overflow: ellipsis; }
  #appView #medicalWorkspace .pitem .row2 > span + span::before { content: "\00a0·\00a0"; }
  #appView #medicalWorkspace .pitem .row2 .mono { font-size: 13px; }

  /* Đầu màn chi tiết: 18/800, 1 dòng */
  #appView #medicalWorkspace.is-collapsed > aside.panel > .panel-head { min-height: 40px; margin-bottom: 0; }
  #appView #medicalWorkspace.is-collapsed > aside.panel > .panel-head > span:first-of-type { font-size: 18px; }

  /* Dải bệnh nhân: tên 18/800 · (chip cảnh báo 1 hàng) · dòng phụ 13px */
  #appView #medicalWorkspace .pb-main { height: var(--med-bar); padding: 0 12px; gap: 8px; }
  #appView #medicalWorkspace .pb-name { font-size: 18px; line-height: 22px; }
  #appView #medicalWorkspace .pb-facts { margin-top: 2px; font-size: 13px; line-height: 18px; }
  #appView #medicalWorkspace #detailWrap:has(.pb-flag) { --med-bar: 80px; }
  #appView #medicalWorkspace #detailWrap:has(.pb-flag) .pb-name { grid-template-rows: 22px 20px; gap: 4px 0; height: 46px; }
  #appView #medicalWorkspace #detailWrap:has(.pb-flag) .pb-flag { height: 20px; min-height: 20px; padding: 0 8px; font-size: 12px; font-weight: 600; line-height: 20px; }
  #appView #medicalWorkspace .pb-actions #printBtn { width: 40px; height: 40px; }
  /* Chặng chăm sóc: dải chip cuộn ngang 40px (bước xong ✓, bước hiện tại tô nền) */
  #appView #medicalWorkspace .pb-journey { padding: 6px 12px 0; }
  #appView #medicalWorkspace .journey { display: flex; gap: 6px; min-width: 0; width: max-content; }
  #appView #medicalWorkspace .journey li { flex: none; }
  #appView #medicalWorkspace .journey li + li::before { content: none; }
  #appView #medicalWorkspace .journey button { flex-direction: row; gap: 6px; width: auto; min-height: 36px; height: 36px; padding: 0 12px 0 6px; border: 1px solid var(--m-line-soft); border-radius: 18px; background: #fff; }
  #appView #medicalWorkspace .journey li.is-now button { border-color: #E3C79E; background: var(--m-accent-wash); }
  #appView #medicalWorkspace .jdot { width: 22px; height: 22px; border-width: 1.5px; font-size: 11px; }
  #appView #medicalWorkspace .jdot svg { width: 11px; height: 11px; }
  #appView #medicalWorkspace .jlabel { font-size: 12px; font-weight: 600; line-height: 1.25; }
  #appView #medicalWorkspace .journey li:not(.is-now):not(.is-done) .jlabel { color: var(--m-sub); }
  #appView #medicalWorkspace .tabs { margin-top: 6px; }
  #appView #medicalWorkspace .tabs + div { height: 10px !important; }

  /* Khối chung: padding 12, đầu thẻ 15/700 */
  #appView #medicalWorkspace .stack { gap: 10px; }
  #appView #medicalWorkspace .grid-2 { gap: 10px; }
  #appView #medicalWorkspace .panel:not(aside):not(.lab-file):not(.care-file):not(.ttyt-saved) > .panel-head { flex-wrap: nowrap; align-items: flex-start; gap: 8px; padding: 12px 12px 4px; font-size: 15px; line-height: 1.25; }
  #appView #medicalWorkspace .panel:not(aside):not(.lab-file):not(.care-file):not(.ttyt-saved) > .panel-head > span:first-of-type { flex: 1 1 auto; min-width: 0; text-wrap: balance; }
  #appView #medicalWorkspace .panel:not(aside):not(.lab-file):not(.care-file):not(.ttyt-saved) > .panel-head > :not(:first-child) { flex: none; }
  #appView #medicalWorkspace .panel:not(aside):not(.lab-file):not(.care-file):not(.ttyt-saved) > .panel-head small { font-size: 12px; font-weight: 500; color: var(--m-sub); white-space: nowrap; }
  #appView #medicalWorkspace .panel:not(aside):not(.lab-file):not(.care-file):not(.ttyt-saved) > .panel-body { padding: 4px 12px 10px; }
  #appView #medicalWorkspace .panel-body > p:last-child { margin-bottom: 0; }

  /* Tổng quan: 4 ô số → một dải (2 cột, kẻ mảnh) */
  #appView #medicalWorkspace .ov-stats { gap: 0; overflow: hidden; border-radius: 12px; background: var(--m-wash); }
  #appView #medicalWorkspace .ov-stat, #appView #medicalWorkspace .ov-stat.is-warn { gap: 0; padding: 8px 12px; border: 0; border-radius: 0; background: none; box-shadow: inset 1px 0 #EADFCF, inset 0 1px #EADFCF; }
  #appView #medicalWorkspace .ov-stat:hover { background: none; }
  #appView #medicalWorkspace .ov-stats > .ov-stat:nth-child(2n+1) { box-shadow: inset 0 1px #EADFCF; }
  #appView #medicalWorkspace .ov-stats > .ov-stat:nth-child(-n+2) { box-shadow: inset 1px 0 #EADFCF; }
  #appView #medicalWorkspace .ov-stats > .ov-stat:first-child { box-shadow: none; }
  #appView #medicalWorkspace .ov-stats > .ov-stat:last-child:nth-child(odd) { grid-column: auto; }
  #appView #medicalWorkspace .ov-txt span { font-size: 12px; font-weight: 600; line-height: 16px; }
  #appView #medicalWorkspace .ov-stat b { font-size: 17px; font-weight: 800; line-height: 22px; }
  #appView #medicalWorkspace .ov-txt small { overflow: hidden; font-size: 12px; line-height: 16px; white-space: nowrap; text-overflow: ellipsis; }

  /* Cặp nhãn | giá trị: một dòng 32px (nhãn trái 13 phụ, giá trị 14) */
  #appView #medicalWorkspace .kv { grid-template-columns: 116px minmax(0, 1fr) !important; }
  #appView #medicalWorkspace .kv dt, #appView #medicalWorkspace .kv dd { padding: 6px 0; line-height: 1.35; }
  #appView #medicalWorkspace .kv dt { overflow: hidden; font-size: 13px; white-space: nowrap; text-overflow: ellipsis; }
  #appView #medicalWorkspace .kv dd { margin: 0; font-size: 14px; font-weight: 500; }
  #appView #medicalWorkspace .kv > :is(dt, dd):nth-child(-n+2) { border-top: 0; }
  #appView #medicalWorkspace .clinical-summary > div { gap: 2px; padding: 6px 0; }
  #appView #medicalWorkspace .clinical-summary > div:first-child { border-top: 0; }
  #appView #medicalWorkspace .clinical-summary dt { font-size: 12px; font-weight: 600; line-height: 16px; }
  #appView #medicalWorkspace .clinical-summary dd { font-size: 14px; line-height: 1.35; }
  #appView #medicalWorkspace .clinical-summary dd :is(.chip, .tag) { gap: 4px; height: 22px; min-height: 22px; padding: 0 8px; border-radius: 999px; font-size: 12px; font-weight: 600; line-height: 22px; }
  #appView #medicalWorkspace .clinical-summary dd .chip svg { width: 12px; height: 12px; }
  #appView #medicalWorkspace .clinical-summary dd p { margin: 0; font-size: 14px; color: var(--m-ink); }

  /* Dòng chỉ số (bất thường ở Tổng quan, chi tiết phiếu xét nghiệm): ~48px — tên + giá trị cùng dòng, tham chiếu + cờ dòng phụ */
  #appView #medicalWorkspace .panel > .tbl-wrap > table:has(.rr) tr,
  #appView #medicalWorkspace .lab-file .lab-results tr { row-gap: 2px; padding: 6px 12px; }
  #appView #medicalWorkspace .panel > .tbl-wrap > table:has(.rr) td:nth-child(1),
  #appView #medicalWorkspace .lab-file .lab-results td:nth-child(1) { overflow: hidden; font-size: 14px; font-weight: 500; line-height: 1.35; white-space: nowrap; text-overflow: ellipsis; }
  #appView #medicalWorkspace .panel > .tbl-wrap > table:has(.rr) td:nth-child(2) b,
  #appView #medicalWorkspace .lab-file .lab-results td:nth-child(2) b { font-size: 14px; font-weight: 800; }
  #appView #medicalWorkspace .panel > .tbl-wrap > table:has(.rr) :is(td:nth-child(2), td:nth-child(3)),
  #appView #medicalWorkspace .lab-file .lab-results :is(td:nth-child(3), td:nth-child(4)) { font-size: 12px; line-height: 16px; }
  #appView #medicalWorkspace .panel > .tbl-wrap > table:has(.rr) td .tag,
  #appView #medicalWorkspace .lab-file .lab-results td .tag { gap: 3px; height: 18px; min-height: 18px; padding: 0 6px; font-size: 12px; font-weight: 600; line-height: 18px; }
  #appView #medicalWorkspace :is(.panel > .tbl-wrap > table:has(.rr), .lab-file .lab-results) td .tag svg { width: 11px; height: 11px; }
  #appView #medicalWorkspace .lab-file .lab-results td .tag:not(.lab-high):not(.lab-low):not(.danger):not(.warn) { padding: 0; background: none; color: var(--m-ok); font-weight: 500; }
  #appView #medicalWorkspace .lab-file .lab-results td:nth-child(8) button { width: 36px; min-width: 36px; height: 36px; min-height: 36px; border: 0; background: none; }
  #appView #medicalWorkspace .lab-file .lab-results td[colspan] { padding: 4px 12px; }

  /* Thẻ phiếu xét nghiệm: 2 dòng — [⚗ tên ★ ngày ……… ˅ ⋯] / [cơ sở ……… nhãn bất thường]; nút Xem chi tiết thành mũi tên 32px */
  #appView #medicalWorkspace .lab-file-head { display: grid; grid-template-columns: auto minmax(0, max-content) auto max-content minmax(68px, 1fr); align-items: center; gap: 4px 6px; min-height: 0; padding: 10px 12px; }
  #appView #medicalWorkspace .lab-file-head .lab-file-label { display: contents; }
  #appView #medicalWorkspace .lab-file-head .lab-file-label > svg { grid-column: 1; grid-row: 1; width: 16px; height: 16px; }
  #appView #medicalWorkspace .lab-file-head .lab-file-name { grid-column: 2; grid-row: 1; min-width: 0; overflow: hidden; font-size: 15px; font-weight: 700; white-space: nowrap; text-overflow: ellipsis; }
  #appView #medicalWorkspace .lab-file-head .lab-latest { grid-column: 3; grid-row: 1; margin: 0; font-size: 14px; }
  #appView #medicalWorkspace .lab-file-head .lab-file-date { grid-column: 4; grid-row: 1; justify-self: start; font-size: 14px; font-weight: 600; white-space: nowrap; }
  #appView #medicalWorkspace .lab-file-head .lab-file-lab { grid-column: 1 / 4; grid-row: 2; min-width: 0; overflow: hidden; font-size: 13px; line-height: 1.35; white-space: nowrap; text-overflow: ellipsis; }
  #appView #medicalWorkspace .lab-file-head .lab-file-badges { grid-column: 4 / 6; grid-row: 2; justify-self: end; margin: 0; }
  #appView #medicalWorkspace .lab-file-head .lab-file-badges:empty { display: none; }
  #appView #medicalWorkspace .lab-file-head .lab-file-badges .tag { height: 20px; min-height: 20px; padding: 0 8px; font-size: 12px; font-weight: 600; }
  #appView #medicalWorkspace .lab-file-head .lab-file-actions { grid-column: 5; grid-row: 1; display: flex; flex: none; gap: 4px; justify-self: end; margin: 0; }
  #appView #medicalWorkspace .lab-file-head .lab-file-actions > button:not(.ui-more) { flex: none; height: 32px; min-height: 32px; padding: 0 10px; border-radius: 10px; font-size: 13px; }
  #appView #medicalWorkspace .lab-file-head .lab-file-actions [data-lab-more] { width: 32px; min-width: 32px; height: 32px; min-height: 32px; }
  #appView #medicalWorkspace .lab-file-head .lab-file-actions > button[data-lab-detail]:not(.ui-more) { display: inline-grid; place-items: center; width: 32px; min-width: 32px; padding: 0; font-size: 0; }
  #appView #medicalWorkspace .lab-file-head .lab-file-actions > button[data-lab-detail]:not(.ui-more)::before { content: ""; width: 16px; height: 16px; background: currentColor; transition: transform .15s; -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") center / contain no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") center / contain no-repeat; }
  #appView #medicalWorkspace .lab-file-head .lab-file-actions > button[data-lab-detail][aria-expanded="true"]:not(.ui-more)::before { transform: rotate(180deg); }

  /* Phiếu y tế đã lưu: đầu 1 dòng, 3 chỉ số thành một dải */
  #appView #medicalWorkspace .panel:not(aside):not(.lab-file):not(.care-file):not(.ttyt-saved) > .panel-head:has(> [data-delete-intake]) { align-items: center; }
  #appView #medicalWorkspace .panel:not(aside):not(.lab-file):not(.care-file):not(.ttyt-saved) > .panel-head:has(> [data-delete-intake]) > span:first-of-type { flex: 0 1 auto; white-space: nowrap; }
  #appView #medicalWorkspace .panel:not(aside):not(.lab-file):not(.care-file):not(.ttyt-saved) > .panel-head:has(> [data-delete-intake]) > .muted { flex: 1 1 auto; min-width: 0; overflow: hidden; color: var(--m-sub); font-size: 13px; white-space: nowrap; text-overflow: ellipsis; }
  #appView #medicalWorkspace .panel > .panel-head > [data-delete-intake] { height: 32px; min-height: 32px; margin: 0; padding: 0 10px; border-radius: 10px; font-size: 12px; }
  #appView #medicalWorkspace .panel > .panel-head > .tag { height: 20px; min-height: 20px; padding: 0 8px; font-size: 12px; line-height: 20px; }
  #appView #medicalWorkspace .panel > .panel-body > .grid-4 { gap: 0 !important; margin-bottom: 8px !important; overflow: hidden; border-radius: 12px; background: var(--m-wash); }
  #appView #medicalWorkspace .panel > .panel-body > .grid-4 > div { padding: 8px 12px; border-radius: 0; background: none; box-shadow: inset 1px 0 #EADFCF; }
  #appView #medicalWorkspace .panel > .panel-body > .grid-4 > div:first-child { box-shadow: none; }
  #appView #medicalWorkspace .panel > .panel-body > .grid-4 .lbl { font-size: 12px; font-weight: 600; line-height: 16px; }
  #appView #medicalWorkspace .panel > .panel-body > .grid-4 .mono { font-size: 17px !important; line-height: 22px; }
  #appView #medicalWorkspace .panel > .panel-body > p { margin: 0 0 4px; font-size: 13px; }
  #appView #medicalWorkspace .panel > .panel-body > .field { margin: 0; }
  #appView #medicalWorkspace .panel > .panel-body > .field > .lbl { margin: 8px 0 2px; font-size: 12px; }

  /* Thẻ thêm mới: một dòng 56px (cả khi chưa có dữ liệu) */
  #appView #medicalWorkspace .stack > :is(.intake-add, .lab-upload, .care-upload):is(:first-child, :not(:first-child)) > button { flex-direction: row; justify-content: flex-start; gap: 10px; min-height: 56px !important; padding: 10px 12px; font-size: 14px; text-align: left; }
  #appView #medicalWorkspace .stack > :is(.intake-add, .lab-upload, .care-upload):is(:first-child, :not(:first-child)) .lab-plus { flex: none; width: 28px !important; height: 28px !important; box-shadow: none !important; font-size: 22px; }

  /* Bảng tư vấn CSYT: tên + 4 nút một hàng 2×2 gọn */
  #appView #medicalWorkspace .care-file-head { gap: 6px; padding: 10px 12px; }
  #appView #medicalWorkspace .care-file-head > button { height: 32px; min-height: 32px; border-radius: 10px; font-size: 13px; }
  #appView #medicalWorkspace .care-file-title strong { font-size: 15px; }
  #appView #medicalWorkspace .care-file-head > svg { display: none; }
  #appView #medicalWorkspace .care-file-title { flex-direction: row; flex-wrap: wrap; align-items: baseline; gap: 0 8px; }
  #appView #medicalWorkspace .care-doc:not(.care-pdf) { min-height: 96px; }
  #appView #medicalWorkspace .care-file-title span { font-size: 13px; }

  /* Hồ sơ đầy đủ KH */
  #appView #medicalWorkspace :is(#fdRoot, .fd-hero, .fd-hero-top) { min-width: 0; max-width: 100%; }
  #appView #medicalWorkspace .fd-hero { padding: 12px; overflow: hidden; }
  #appView #medicalWorkspace .fd-hero-top { gap: 4px 8px; }
  #appView #medicalWorkspace .fd-hero-title h3 { gap: 4px 6px; font-size: 15px; line-height: 1.25; }
  #appView #medicalWorkspace .fd-hero-title p { margin-top: 2px; font-size: 13px; line-height: 1.35; }
  #appView #medicalWorkspace .fd-ver, #appView #medicalWorkspace .fd-latest, #appView #medicalWorkspace .fd-hero-top .fd-lang { height: 20px; min-height: 20px; padding: 0 8px; font-size: 12px; font-weight: 600; line-height: 20px; }
  /* Đầu thẻ: tiêu đề + v1 dòng 1; "Bản mới nhất" + trạng thái dịch chung dòng 2; dòng phụ dòng 3 */
  #appView #medicalWorkspace .fd-hero-top { align-items: center; }
  #appView #medicalWorkspace .fd-hero-top .fd-hero-title, #appView #medicalWorkspace .fd-hero-top .fd-hero-title h3 { display: contents; }
  #appView #medicalWorkspace .fd-hero-top .fd-hero-title p { order: 9; flex: 1 1 100%; text-wrap: balance; }
  #appView #medicalWorkspace .fd-hero-top { font-size: 15px; font-weight: 700; line-height: 1.25; color: var(--m-ink); }
  #appView #medicalWorkspace .fd-hero-top .fd-lang { order: 5; }
  #appView #medicalWorkspace .fd-hero-top .fd-latest { order: 4; }
  #appView #medicalWorkspace .fd-contents { flex-wrap: nowrap; gap: 4px; margin: 8px -12px 0; padding: 0 12px; overflow-x: auto; scrollbar-width: none; }
  #appView #medicalWorkspace .fd-contents::-webkit-scrollbar { display: none; }
  #appView #medicalWorkspace .fd-contents li { flex: none; white-space: nowrap; }
  #appView #medicalWorkspace .fd-contents li { gap: 4px; padding: 3px 8px; font-size: 12px; font-weight: 600; }
  #appView #medicalWorkspace .fd-contents li svg { width: 12px; height: 12px; }
  #appView #medicalWorkspace .fd-actions { gap: 6px; margin-top: 10px; padding-top: 10px; }
  #appView #medicalWorkspace .fd-actions button { min-height: 36px; height: 36px; border-radius: 10px; font-size: 13px; }
  #appView #medicalWorkspace .fd-actions .bronze { min-height: 40px; height: 40px; font-size: 14px; }
  #appView #medicalWorkspace .fd-subhead { margin: 6px 0 0; font-size: 15px; }
  /* Thẻ phiên đã gửi chuyên gia */
  #appView #medicalWorkspace .panel > .panel-head > [data-consult-print] { width: 32px; min-width: 32px; height: 32px; min-height: 32px; border-radius: 10px; }
  #appView #medicalWorkspace .panel > .panel-head > [data-consult-delete] { height: 32px; min-height: 32px; padding: 0 10px; border-radius: 10px; font-size: 12px; }
  #appView #medicalWorkspace .panel:not(aside):not(.lab-file):not(.care-file):not(.ttyt-saved) > .panel-head:has(> [data-consult-print]) { flex-wrap: wrap; align-items: center; }
  #appView #medicalWorkspace .panel:not(aside):not(.lab-file):not(.care-file):not(.ttyt-saved) > .panel-head:has(> [data-consult-print]) > span:first-of-type { flex: 1 1 60%; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
  #appView #medicalWorkspace .notice { padding: 8px 10px; font-size: 13px; line-height: 1.35; }
  #appView #medicalWorkspace .stack > .panel[style*="margin-bottom"] { margin-bottom: 0 !important; }
  #appView #medicalWorkspace .notice button { min-height: 32px; height: 32px; margin-top: 6px; border-radius: 10px; font-size: 13px; }
  #appView #medicalWorkspace .sent-open { gap: 6px; margin-top: 8px; }
  #appView #medicalWorkspace .sent-open > div { flex: 1 1 0; }
  #appView #medicalWorkspace .sent-open > div b { font-size: 14px; }
  #appView #medicalWorkspace .sent-open > div small { overflow: hidden; font-size: 12px; white-space: nowrap; text-overflow: ellipsis; }
  #appView #medicalWorkspace .sent-open { flex-wrap: nowrap; }
  #appView #medicalWorkspace .sent-open > button { flex: none; width: auto; align-self: center; height: 32px; min-height: 32px; padding: 0 10px; border-radius: 10px; font-size: 13px; }

  /* Tài liệu y tế */
  #appView #medicalWorkspace .doc-summary .panel-head small, #appView #medicalWorkspace .doc-tl .panel-head small { white-space: normal; }
  #appView #medicalWorkspace .doc-problem { padding: 8px 10px; }
  #appView #medicalWorkspace .doc-row { padding: 8px 0; }
  #appView #medicalWorkspace .doc-bundles > li { grid-template-columns: minmax(0, 1fr) auto auto auto; gap: 4px 6px; padding: 8px 0; }
  #appView #medicalWorkspace .doc-bundles > li > div { grid-column: 1 / -2; }
  #appView #medicalWorkspace .doc-bundles > li > .tag { grid-column: -2; height: 20px; min-height: 20px; padding: 0 8px; font-size: 12px; }
  #appView #medicalWorkspace .doc-bundles > li > button { grid-row: 2; height: 32px; min-height: 32px; border-radius: 10px; font-size: 12px; }
  #appView #medicalWorkspace .doc-bundles > li > button:first-of-type { grid-column: 1; justify-self: start; width: auto; padding: 0 12px; }

  /* Phiếu thu thập: khoảng trắng giữa trường, nhãn 12/600, cặp 2 cột */
  #appView :is(#intakeDialog, #hubIntakeDialog) > .intake-dialog-head h2 { display: block; overflow: hidden; font-size: 15px; white-space: nowrap; text-overflow: ellipsis; }
  #appView :is(#intakeDialog, #hubIntakeDialog) .ttyt-ocr-bar { margin-top: 10px; }
  #appView :is(#intakeDialog, #hubIntakeDialog) #ttyt_ocr { min-height: 40px; height: 40px; font-size: 13px; }
  #appView :is(#intakeDialog, #hubIntakeDialog) .ttyt-nav { top: 56px; margin-top: 8px; padding: 6px 16px; }
  #appView :is(#intakeDialog, #hubIntakeDialog) .ttyt-nav button { min-height: 36px; height: 36px; }
  #appView :is(#intakeDialog, #hubIntakeDialog) [data-ttyt-panel] > h3 { margin: 12px 0 0; font-size: 15px; font-weight: 700; line-height: 1.25; text-wrap: balance; }
  #appView :is(#intakeDialog, #hubIntakeDialog) [data-ttyt-panel]:not(:is([data-ttyt-panel="2"], [data-ttyt-panel="3"])) .ttyt-section { padding: 12px 0 0; }
  #appView :is(#intakeDialog, #hubIntakeDialog) [data-ttyt-panel]:not(:is([data-ttyt-panel="2"], [data-ttyt-panel="3"])) .ttyt-section + .ttyt-section { margin-top: 12px; }
  #appView :is(#intakeDialog, #hubIntakeDialog) [data-ttyt-panel]:not(:is([data-ttyt-panel="2"], [data-ttyt-panel="3"])) .ttyt-section > h3 { margin: 0 0 8px; font-size: 15px; line-height: 1.25; }
  #appView :is(#intakeDialog, #hubIntakeDialog) .ttyt-grid { gap: 8px; }
  #appView :is(#intakeDialog, #hubIntakeDialog) .ttyt-grid label, #appView :is(#intakeDialog, #hubIntakeDialog) .ttyt-grid .lbl, #appView :is(#intakeDialog, #hubIntakeDialog) .ttyt-delivery legend { display: block; margin: 0 0 2px; overflow: hidden; font-size: 12px; font-weight: 600; line-height: 16px; white-space: nowrap; text-overflow: ellipsis; }
  /* Câu hỏi dài (trang nghề nghiệp, tiền sử): cho xuống dòng */
  #appView :is(#intakeDialog, #hubIntakeDialog) :is([data-ttyt-panel="1"], [data-ttyt-panel="2"], [data-ttyt-panel="3"]) .ttyt-grid label { overflow: visible; font-size: 13px; line-height: 1.35; white-space: normal; }
  #appView :is(#intakeDialog, #hubIntakeDialog) .ttyt-grid > .field:is(:has(#ttyt_gender), :has(#ttyt_birthDate), :has(#ttyt_bloodPressure), :has(#ttyt_bmi)) { grid-column: auto; }
  #appView :is(#intakeDialog, #hubIntakeDialog) .ttyt-grid textarea { min-height: 64px; }
  #appView :is(#intakeDialog, #hubIntakeDialog) .ttyt-delivery { gap: 6px; }
  #appView :is(#intakeDialog, #hubIntakeDialog) .ttyt-delivery .check { min-height: 40px; padding: 8px 12px; }
  #appView :is(#intakeDialog, #hubIntakeDialog) .ttyt-delivery .check span { font-size: 13px; line-height: 1.35; }
  #appView :is(#intakeDialog, #hubIntakeDialog) #ttyt_signatureCanvas { height: 140px; margin: 4px 0; }
  #appView :is(#intakeDialog, #hubIntakeDialog) :is([data-ttyt-panel="2"], [data-ttyt-panel="3"]) .ttyt-section { margin: 0 0 8px; padding: 10px 12px; }
  #appView :is(#intakeDialog, #hubIntakeDialog) :is([data-ttyt-panel="2"], [data-ttyt-panel="3"]) .ttyt-section > h3 { margin: 0 0 6px; font-size: 14px; font-weight: 600; line-height: 1.35; }
  #appView :is(#intakeDialog, #hubIntakeDialog) :is([data-ttyt-panel="2"], [data-ttyt-panel="3"]) > h3 + .ttyt-section { margin-top: 8px; }
  /* Mỗi bệnh: câu hỏi trái · ô Có/Không 124px phải trên cùng hàng; chi tiết (khi "Có") cả hàng bên dưới */
  #appView :is(#intakeDialog, #hubIntakeDialog) :is([data-ttyt-panel="2"], [data-ttyt-panel="3"]) .ttyt-section { display: grid; grid-template-columns: minmax(0, 1fr) 124px; align-items: center; gap: 8px 10px; }
  #appView :is(#intakeDialog, #hubIntakeDialog) :is([data-ttyt-panel="2"], [data-ttyt-panel="3"]) .ttyt-section > h3 { grid-column: 1; grid-row: 1; margin: 0; text-wrap: wrap; }
  #appView :is(#intakeDialog, #hubIntakeDialog) :is([data-ttyt-panel="2"], [data-ttyt-panel="3"]) .ttyt-section > .ttyt-grid { display: contents; }
  #appView :is(#intakeDialog, #hubIntakeDialog) :is([data-ttyt-panel="2"], [data-ttyt-panel="3"]) .ttyt-section > .ttyt-grid > .field:first-child { grid-column: 2; grid-row: 1; }
  #appView :is(#intakeDialog, #hubIntakeDialog) :is([data-ttyt-panel="2"], [data-ttyt-panel="3"]) .ttyt-section > .ttyt-grid > .field:not(:first-child) { grid-column: 1 / -1; grid-row: auto; }
  #appView :is(#intakeDialog, #hubIntakeDialog) :is([data-ttyt-panel="2"], [data-ttyt-panel="3"]) .ttyt-section select { padding-right: 26px; font-size: 15px; }
  #appView :is(#intakeDialog, #hubIntakeDialog) :is([data-ttyt-panel="2"], [data-ttyt-panel="3"]) .ttyt-section > .ttyt-grid textarea { height: 46px; min-height: 46px; }
  #appView :is(#intakeDialog, #hubIntakeDialog) .ttyt-actions { margin-top: 12px; padding-top: 8px; padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px)); }

  /* Xem hồ sơ / hồ sơ đã gửi: nội dung gọn */
  #appView :is(#sentDialog, #fdViewDialog) .sent-record-content { padding: 10px 12px 20px; }
  #appView :is(#sentDialog, #fdViewDialog) .record-detail { font-size: 14px; line-height: 1.35; }
  #appView :is(#sentDialog, #fdViewDialog) .record-detail h3 { margin: 16px 0 8px; font-size: 15px; font-weight: 700; }
  #appView :is(#sentDialog, #fdViewDialog) .record-detail h3:first-child { margin-top: 0; }
  #appView :is(#sentDialog, #fdViewDialog) .record-detail .record-answer { padding: 6px 0; line-height: 1.35; }
  #appView :is(#sentDialog, #fdViewDialog) .record-detail p { margin: 4px 0; }
  #appView #fdViewDialog .fd-sec-title { margin-bottom: 8px; padding-bottom: 6px; font-size: 15px; }
  #appView #fdViewDialog .fd-sec + .fd-sec { margin-top: 16px; }
  #appView :is(#sentDialog, #fdViewDialog) .record-table:has(th:nth-child(6)) tr, #appView :is(#sentDialog, #fdViewDialog) .record-table:has(th:nth-child(5)):not(:has(th:nth-child(6))) tr { padding: 6px 12px; }
  #appView :is(#sentDialog, #fdViewDialog) .record-table:has(th:nth-child(6)) td:nth-child(1), #appView :is(#sentDialog, #fdViewDialog) .record-table:has(th:nth-child(5)):not(:has(th:nth-child(6))) td:nth-child(1) { font-size: 14px; font-weight: 500; line-height: 1.35; }
  #appView :is(#sentDialog, #fdViewDialog) .record-table:has(th:nth-child(6)) td:nth-child(4), #appView :is(#sentDialog, #fdViewDialog) .record-table:has(th:nth-child(5)):not(:has(th:nth-child(6))) td:nth-child(2) { font-size: 14px; line-height: 1.35; }
  #appView :is(#sentDialog, #fdViewDialog) .record-table:has(th:nth-child(6)) :is(td:nth-child(2), td:nth-child(3), td:nth-child(5), td:nth-child(6)), #appView :is(#sentDialog, #fdViewDialog) .record-table:has(th:nth-child(5)):not(:has(th:nth-child(6))) :is(td:nth-child(3), td:nth-child(4), td:nth-child(5)) { line-height: 16px; }
  #appView #fdViewDialog > .intake-dialog-head { padding-bottom: 8px; }
  #appView #fdViewDialog .fd-view-tools > button, #appView #fdViewDialog .fd-seg button { height: 34px; min-height: 34px; }

  /* Gửi chuyên gia */
  #appView #fdSendDialog .fd-send-body { gap: 10px; padding-top: 12px; }
  #appView #fdSendDialog .fd-send-doc { gap: 4px 8px; padding: 10px 12px; }
  #appView #fdSendDialog .fd-send-doc b { font-size: 15px; }
  #appView #fdSendDialog .fd-send-doc small { font-size: 13px; line-height: 1.35; }
  #appView #fdSendDialog .fd-send-doc .fd-lang { height: 20px; padding: 0 8px; font-size: 12px; line-height: 20px; }
  #appView #fdSendDialog .fd-check { padding: 10px 12px; font-size: 14px; line-height: 1.35; }
  #appView #fdSendDialog .fd-check small { font-size: 12px; }
  #appView #fdSendDialog .field { gap: 2px; }
  #appView #fdSendDialog .field label { font-size: 12px; }
  #appView #fdSendDialog .fd-note { font-size: 12px; line-height: 1.35; }

  /* Thêm bộ hồ sơ */
  #appView #bundleWizard .bw-body { padding: 12px; }
  #appView #bundleWizard .bw-drop { gap: 4px; min-height: 0; padding: 14px 12px; }
  #appView #bundleWizard .bw-drop-ic { width: 36px; height: 36px; box-shadow: none; }
  #appView #bundleWizard .bw-drop b { font-size: 14px; }
  #appView #bundleWizard .bw-drop span:not(.bw-drop-ic) { font-size: 12px; line-height: 1.35; text-wrap: balance; }
  #appView #bundleWizard .bw-recs { gap: 8px; }
  #appView #bundleWizard .bw-rec { padding: 10px 12px; }
  #appView #bundleWizard .bw-rec-head b { font-size: 15px; line-height: 1.25; }
  #appView #bundleWizard .bw-rec-head small { font-size: 13px; line-height: 1.35; }
  #appView #bundleWizard .bw-concl { margin: 6px 0 0; font-size: 13px; line-height: 1.35; }
  #appView #bundleWizard .bw-warn { margin-top: 6px; font-size: 12px; }
  #appView #bundleWizard .bw-rec footer { gap: 6px; margin-top: 8px; }
  #appView #bundleWizard .bw-rec footer button:not([data-file]) { min-height: 32px; height: 32px; border-radius: 10px; font-size: 13px; }
  #appView #bundleWizard .bw-rec footer [data-file] { min-height: 28px; font-size: 12px; }
}
