body { background: #f4f6f9; font-size: .925rem; }
.bg-primary-subtle-dark { background: #0d4e8a; }
.card { border: 0; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.stat .num { font-size: 1.7rem; font-weight: 600; line-height: 1.1; }
.stat .lbl { color: #6c757d; font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; }
.table th { white-space: nowrap; font-weight: 600; background: #eef2f7 !important; }
.table td { vertical-align: middle; }
.form-label { font-weight: 500; margin-bottom: .2rem; font-size: .85rem; }
.section-title { font-weight: 600; color: #0d4e8a; border-bottom: 2px solid #dce6f1; padding-bottom: .3rem; margin: 1rem 0 .8rem; }
dl.info dt { color: #6c757d; font-weight: 500; font-size: .82rem; }
dl.info dd { margin-bottom: .6rem; }
.label-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4mm; }
.label { border: 1px dashed #999; padding: 3mm; display: flex; gap: 3mm; align-items: center; page-break-inside: avoid; background: #fff; }
.label svg { width: 26mm; height: 26mm; flex: none; }
.label .t { font-size: 9pt; line-height: 1.25; }
@media print {
  body { background: #fff; }
  .card { box-shadow: none; }
  main { padding: 0 !important; }
}

/* ===================== GIAO DIỆN ĐIỆN THOẠI ===================== */
.bottom-nav { display: none; }
@media (max-width: 991.98px) {
  body { padding-bottom: calc(64px + env(safe-area-inset-bottom)); font-size: .95rem; }
  .bottom-nav {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 1030;
    background: #fff; border-top: 1px solid #dee2e6; box-shadow: 0 -2px 8px rgba(0,0,0,.06);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .bottom-nav a {
    flex: 1; text-align: center; color: #6c757d; text-decoration: none; font-size: .7rem;
    padding: 6px 0 4px; line-height: 1.1;
  }
  .bottom-nav a i { font-size: 1.35rem; display: block; }
  .bottom-nav a.active { color: #0d4e8a; font-weight: 600; }
  .bottom-nav a.scan i {
    background: #0d4e8a; color: #fff; width: 48px; height: 48px; line-height: 48px; border-radius: 50%;
    margin: -20px auto 2px; box-shadow: 0 2px 6px rgba(13,78,138,.4); font-size: 1.5rem;
  }
  .navbar .navbar-collapse { max-height: 75vh; overflow-y: auto; }
  main.container-fluid { padding-left: .75rem; padding-right: .75rem; }
  h4 { font-size: 1.2rem; }
  .stat .num { font-size: 1.35rem; }
  .stat .card-body { padding: .75rem; }
  .card-body { padding: .85rem; }
  .btn { min-height: 38px; }
  .form-control, .form-select { font-size: 16px; } /* tránh iPhone tự phóng to khi nhập */
  .nav-tabs { flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
  .nav-tabs .nav-link { white-space: nowrap; }
  .nav-tabs::-webkit-scrollbar { display: none; }
  .hscroll { display: flex; flex-wrap: nowrap !important; overflow-x: auto; gap: .4rem; padding-bottom: 2px; scrollbar-width: none; }
  .hscroll > * { flex: 0 0 auto; }
}

/* Bảng tự chuyển thành dạng khối trên màn hình hẹp */
@media (max-width: 767.98px) {
  table.table-stack thead { display: none; }
  table.table-stack, table.table-stack tbody, table.table-stack tfoot { display: block; width: 100%; }
  table.table-stack tr { display: block; border-bottom: 1px solid #dee2e6; padding: .5rem .25rem; }
  table.table-stack td { display: flex; gap: .75rem; justify-content: space-between; align-items: flex-start;
                         border: 0 !important; padding: .15rem .25rem !important; text-align: right !important; }
  table.table-stack td::before { content: attr(data-label); color: #6c757d; font-weight: 500; text-align: left;
                                 flex: 0 0 40%; font-size: .85em; }
  table.table-stack td[data-label=""]::before, table.table-stack td:not([data-label])::before { display: none; }
  table.table-stack td[data-label=""] , table.table-stack td:not([data-label]) { justify-content: flex-end; }
  table.table-stack td.stack-title { display: block; text-align: left !important; font-weight: 600; font-size: 1rem; }
  table.table-stack td.stack-title::before { display: none; }
  .table-responsive:has(> table.table-stack) { overflow-x: visible; }
}

/* Thẻ thiết bị (danh sách trên điện thoại) */
.eq-card { display: flex; gap: .75rem; padding: .7rem .75rem; border-bottom: 1px solid #eef0f3; color: inherit; text-decoration: none; }
.eq-card:active { background: #f1f5fb; }
.eq-card .thumb { width: 64px; height: 64px; flex: none; border-radius: .5rem; object-fit: cover; background: #eef2f7;
                  display: flex; align-items: center; justify-content: center; color: #9aa5b1; font-size: 1.6rem; }
.eq-card .title { font-weight: 600; line-height: 1.25; }
.eq-card .meta { font-size: .8rem; color: #6c757d; }

@media (min-width: 768px) { .filters-more { display: contents !important; } }

/* Tile menu */
.tile { display: block; text-align: center; padding: 1rem .5rem; border-radius: .75rem; background: #fff; color: #212529;
        text-decoration: none; box-shadow: 0 1px 3px rgba(0,0,0,.08); height: 100%; }
.tile i { font-size: 1.8rem; color: #0d4e8a; display: block; margin-bottom: .25rem; }
.tile span { font-size: .85rem; }
.tile:active { background: #f1f5fb; }

/* Quét mã */
#scanBox { position: relative; background: #000; border-radius: .75rem; overflow: hidden; aspect-ratio: 3/4; max-height: 65vh; margin: 0 auto; }
#scanBox video { width: 100%; height: 100%; object-fit: cover; }
#scanBox .frame { position: absolute; inset: 18%; border: 3px solid rgba(255,255,255,.85); border-radius: 1rem;
                  box-shadow: 0 0 0 9999px rgba(0,0,0,.35); }
@media (max-width: 767.98px) { .filters-more > div { margin-top: .5rem; } }
.hscroll { max-width: 100%; }

/* Biểu tượng tự tải lên: kích thước theo cỡ chữ như biểu tượng thường */
.ci { display: inline-block; width: 1em; height: 1em; vertical-align: -.125em; object-fit: contain; }
.ci-mono { background-color: currentColor; -webkit-mask: var(--ci) center / contain no-repeat; mask: var(--ci) center / contain no-repeat; }
.tile .ci { width: 1.8rem; height: 1.8rem; display: block; margin: 0 auto .25rem; color: var(--qltb-heading, #0d4e8a); }
@media (max-width: 991.98px) {
  .bottom-nav a .ci { width: 1.35rem; height: 1.35rem; display: block; margin: 0 auto; }
  .bottom-nav a.scan .ci { width: 48px; height: 48px; margin: -20px auto 2px; border-radius: 50%; background-color: var(--qltb-nav, #0d4e8a);
                           box-shadow: 0 2px 6px rgba(0,0,0,.25); padding: 11px; object-fit: contain; }
  .bottom-nav a.scan .ci-mono { -webkit-mask: none; mask: none; background-image: none; position: relative; }
  .bottom-nav a.scan .ci-mono::after { content: ""; position: absolute; inset: 11px; background: var(--qltb-nav-fg, #fff);
                                        -webkit-mask: var(--ci) center / contain no-repeat; mask: var(--ci) center / contain no-repeat; }
}
