/* HQMS luoi - lưới nhập dòng chứng từ */
.hqms-grids { margin: 14px 0; clear: both; }
.hqms-grid { background: #fff; border: 1px solid #dfe5ec; border-radius: 6px; margin-bottom: 14px; }
.hqms-grid.hqms-grid-haschanges { border-color: #f0b35a; box-shadow: 0 0 0 2px rgba(240, 179, 90, .15); }
.hqms-grid-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 10px; border-bottom: 1px solid #eef1f5; background: #f7f9fc; border-radius: 6px 6px 0 0; }
.hqms-grid-head h4 { flex: 1; margin: 0; font-size: 15px; font-weight: 600; }
.hqms-grid-head h4 small { font-weight: normal; margin-left: 6px; }
.hqms-grid-tools { display: flex; gap: 6px; align-items: center; }
.hqms-grid-colmenu { max-height: 360px; overflow-y: auto; padding: 6px 10px; min-width: 220px; }
.hqms-grid-colmenu label { font-weight: normal; display: block; margin: 2px 0; white-space: nowrap; }
.hqms-grid-wrap { overflow: auto; max-height: 70vh; }
.hqms-grid-table { margin: 0; min-width: 100%; }
.hqms-grid-table > thead > tr > th { position: sticky; top: 0; z-index: 2; background: #f3f6fa; font-size: 12px; white-space: nowrap; border-bottom: 1px solid #dfe5ec; }
.hqms-grid-table > tbody > tr > td { padding: 2px 3px; vertical-align: middle; }
.hqms-grid-table td .form-control { height: 28px; padding: 3px 6px; border-color: transparent; background: transparent; box-shadow: none; border-radius: 3px; min-width: 70px; }
.hqms-grid-table td .form-control:hover { border-color: #d6dde6; }
.hqms-grid-table td .form-control:focus { border-color: var(--hqms-theme-primary, #1d4f91); background: #fff; box-shadow: 0 0 0 2px rgba(29, 79, 145, .15); }
.hqms-grid-table td select.form-control { padding: 2px; min-width: 110px; }
.hqms-grid-c-lookup { min-width: 220px; }
.hqms-grid-c-text { min-width: 160px; }
.hqms-grid-c-num, .hqms-grid-c-int, .hqms-grid-c-calc { min-width: 100px; text-align: right; }
.hqms-grid-c-date { min-width: 110px; } .hqms-grid-c-datetime { min-width: 140px; }
.hqms-grid-c-check { text-align: center; width: 50px; }
.hqms-grid-ro { display: block; padding: 4px 6px; color: #374151; }
.hqms-grid-c-calc .hqms-grid-ro { font-weight: 600; }
.hqms-grid-no { width: 34px; text-align: right; color: #9ca3af; font-size: 12px; }
.hqms-grid-act { width: 64px; white-space: nowrap; }
.hqms-grid-dirty > td:first-child { box-shadow: inset 3px 0 0 #f0b35a; }
.hqms-grid-new > td:first-child { box-shadow: inset 3px 0 0 #4caf50; }
.hqms-grid-del > td { opacity: .45; text-decoration: line-through; }
.hqms-grid-err > td { background: #fdecec !important; }
.hqms-grid-errmsg { color: #b42318; font-size: 12px; white-space: normal; }
.hqms-grid-errrow > td { background: #fdecec !important; padding: 4px 10px 6px 34px !important; border-top: 0 !important; }
.hqms-grid-bad { border-color: #d92d20 !important; background: #fff5f5 !important; }
.hqms-grid-msg { color: #6b7280; padding: 14px !important; text-align: center; }
.hqms-grid-table tfoot td { border-top: 2px solid #dfe5ec; background: #f7f9fc; }
.hqms-grid-hint { padding: 5px 10px; font-size: 11.5px; color: #6b7280; border-top: 1px solid #eef1f5; }
.hqms-grid-lk { position: relative; }
.hqms-grid-lkmenu { display: none; position: absolute; z-index: 1050; left: 0; top: 100%; min-width: 320px; max-height: 260px; overflow-y: auto; margin: 2px 0 0; padding: 4px 0;
	list-style: none; background: #fff; border: 1px solid #d6dde6; border-radius: 4px; box-shadow: 0 8px 24px rgba(0,0,0,.12); }
.hqms-grid-lkmenu li { padding: 5px 10px; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hqms-grid-lkmenu li.active, .hqms-grid-lkmenu li[data-k]:hover { background: var(--hqms-theme-primary, #1d4f91); color: #fff; }
.hqms-grid-lkmsg { color: #6b7280; cursor: default !important; }
.hqms-grid-new-msg { margin: 10px 0; }

/* khối tổng cộng dưới lưới (trường tính của chứng từ - đã chuyển khỏi form) */
.detail_view .form-group.hqms-grid-moved { display: none !important; }
.hqms-grid-totals { display: flex; justify-content: flex-end; align-items: flex-end; gap: 40px; flex-wrap: wrap; padding: 8px 12px 10px; border-top: 1px solid #e3e8ef; background: #fafbfd; }
.hqms-grid-total { display: flex; justify-content: space-between; gap: 24px; min-width: 320px; font-size: 13px; }
.hqms-grid-total-l { color: #4b5563; }
.hqms-grid-total-v { font-variant-numeric: tabular-nums; font-weight: 600; text-align: right; }
.hqms-grid-total.is-main { margin-top: 4px; padding-top: 5px; border-top: 1px solid #d6dde6; font-size: 15px; }
.hqms-grid-total.is-main .hqms-grid-total-l { color: #111827; font-weight: 600; }
.hqms-grid-total.is-main .hqms-grid-total-v { color: var(--hqms-theme-primary, #1d4f91); }
@media (max-width: 767px) { .hqms-grid-total { min-width: 0; width: 100%; } }
.hqms-grid-totals-main, .hqms-grid-totals-side { display: flex; flex-direction: column; gap: 2px; }
.hqms-grid-totals-side { margin-right: auto; color: #6b7280; }
.hqms-grid-totals-side .hqms-grid-total { min-width: 260px; font-size: 12px; }

/* nút mở hộp chọn trong ô lookup: hiện khi ô đang được chọn (focus) */
.hqms-grid-lk { position: relative; }
.hqms-grid-lkbtn { display: none; position: absolute; top: 50%; right: 3px; transform: translateY(-50%); z-index: 2;
	width: 24px; height: 22px; padding: 0; border: 1px solid #c9d1db; border-radius: 3px; background: #f5f7fa; color: #4b5563; font-size: 11px; line-height: 20px; }
.hqms-grid-lkbtn:hover { background: var(--hqms-theme-primary, #1d4f91); border-color: var(--hqms-theme-primary, #1d4f91); color: #fff; }
.hqms-grid-lk:focus-within .hqms-grid-lkbtn { display: block; }
.hqms-grid-lk:focus-within input { padding-right: 30px; }
/* ô ngày / ngày giờ: lịch chọn mở khi ô nhận focus (luoi.js openDatePicker) */
#hqms-grid-dtp { position: fixed; top: 0; left: 0; width: 0; height: 0; z-index: 2050; }
#hqms-grid-dtp > .bootstrap-datetimepicker-widget.dropdown-menu { display: block; margin: 0; }

/* hộp chọn nhiều */
.hqms-grid-picker .modal-dialog { width: min(1000px, 96vw); }
.hqms-pk-tools { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.hqms-pk-tools [data-pk-q] { flex: 1 1 260px; }
.hqms-pk-filters { display: contents; }
.hqms-pk-filters select { flex: 0 1 200px; width: auto; }
.hqms-pk-wrap { max-height: 55vh; overflow: auto; border: 1px solid #e3e8ef; border-radius: 3px; }
.hqms-pk-table { margin: 0; font-size: 12px; }
.hqms-pk-table thead th { position: sticky; top: 0; background: #f5f7fa; z-index: 1; white-space: nowrap; }
.hqms-pk-table tbody tr { cursor: pointer; }
.hqms-pk-ck { width: 28px; text-align: center; }
.hqms-pk-pager { margin-top: 6px; font-size: 12px; }
.hqms-grid-picker .modal-footer { display: flex; align-items: center; gap: 6px; }
.hqms-pk-sel { flex: 1 1 auto; text-align: left; display: flex; flex-wrap: wrap; gap: 4px; max-height: 60px; overflow: auto; }
.hqms-pk-sel .label { font-weight: normal; font-size: 11px; }
.hqms-pk-sel .label a { color: #fff; margin-left: 3px; text-decoration: none; }

/* kẻ dọc phân cột (lưới dòng + hộp chọn); cột đầu / cuối không kẻ sát viền khung */
.hqms-grid-table > thead > tr > th, .hqms-grid-table > tbody > tr > td, .hqms-grid-table > tfoot > tr > td,
.hqms-pk-table > thead > tr > th, .hqms-pk-table > tbody > tr > td { border-right: 1px solid #e3e8ef; }
.hqms-grid-table > thead > tr > th:last-child, .hqms-grid-table > tbody > tr > td:last-child, .hqms-grid-table > tfoot > tr > td:last-child,
.hqms-pk-table > thead > tr > th:last-child, .hqms-pk-table > tbody > tr > td:last-child { border-right: 0; }
.hqms-grid-table > thead > tr > th { border-right-color: #dfe5ec; }
.hqms-grid-table > tbody > tr > td { border-top-color: #edf0f4; }

/* ===== ITL: cố định cột "#" (trái) và cột nút thao tác (phải) khi lưới rộng hơn màn hình - không phải kéo thanh cuộn ngang tới cuối dòng ===== */
.hqms-grid-table > thead > tr > th.hqms-grid-act, .hqms-grid-table > tbody > tr > td.hqms-grid-act, .hqms-grid-table > tfoot > tr > td:last-child {
	position: sticky; right: 0; z-index: 1; background: #e8eff8; box-shadow: -6px 0 6px -6px rgba(15, 23, 42, .25); border-left: 1px solid #d5deea; }
.hqms-grid-table > thead > tr > th.hqms-grid-no, .hqms-grid-table > tbody > tr > td.hqms-grid-no, .hqms-grid-table > tfoot > tr > td:first-child {
	position: sticky; left: 0; z-index: 1; background: #fff; box-shadow: 6px 0 6px -6px rgba(15, 23, 42, .25); }
.hqms-grid-table > thead > tr > th.hqms-grid-act, .hqms-grid-table > thead > tr > th.hqms-grid-no { z-index: 3; background: #f3f6fa; }
.hqms-grid-table > tfoot > tr > td:first-child, .hqms-grid-table > tfoot > tr > td:last-child { background: #f8fafc; }
/* nền ô cố định theo trạng thái dòng (mới / đã sửa / xóa / lỗi) */
.hqms-grid-table > tbody > tr.hqms-grid-new > td.hqms-grid-act, .hqms-grid-table > tbody > tr.hqms-grid-new > td.hqms-grid-no { background: #f0f9f1; }
.hqms-grid-table > tbody > tr.hqms-grid-dirty > td.hqms-grid-act, .hqms-grid-table > tbody > tr.hqms-grid-dirty > td.hqms-grid-no { background: #fffbea; }
.hqms-grid-table > tbody > tr.hqms-grid-del > td.hqms-grid-act, .hqms-grid-table > tbody > tr.hqms-grid-del > td.hqms-grid-no { background: #fdf0f0; }
.hqms-grid-table > tbody > tr.hqms-grid-err > td.hqms-grid-act, .hqms-grid-table > tbody > tr.hqms-grid-err > td.hqms-grid-no { background: #fdecea; }
.hqms-grid-table > tbody > tr:hover > td.hqms-grid-no { background: #f5f8fc; }
/* cột nút thao tác: nền xanh xám nhạt để tách khỏi vùng nhập liệu (dòng mới / sửa / xóa / lỗi vẫn theo màu trạng thái ở trên) */
body .hqms-grid-table > thead > tr > th.hqms-grid-act, body.hqms-theme .hqms-grid-table > thead > tr > th.hqms-grid-act { background: #dbe4f0; }
.hqms-grid-table > tfoot > tr > td:last-child { background: #e3eaf4; }
.hqms-grid-table > tbody > tr:hover > td.hqms-grid-act { background: #dde6f2; }
.hqms-grid-table > tbody > tr.hqms-grid-dirty > td.hqms-grid-no { box-shadow: inset 3px 0 0 #f0b35a, 6px 0 6px -6px rgba(15, 23, 42, .25); }
.hqms-grid-table > tbody > tr.hqms-grid-new > td.hqms-grid-no { box-shadow: inset 3px 0 0 #4caf50, 6px 0 6px -6px rgba(15, 23, 42, .25); }
.hqms-grid-table > tbody > tr.hqms-grid-del > td.hqms-grid-act { opacity: 1; text-decoration: none; }   /* nút "Bỏ xóa" vẫn rõ */
