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; flex-wrap: wrap; gap: .25rem .5rem; justify-content: flex-end; align-items: flex-start;
                         border: 0 !important; padding: .15rem .25rem !important; text-align: right !important;
                         min-width: 0; overflow-wrap: anywhere; }
  table.table-stack td > * { min-width: 0; max-width: 100%; }
  table.table-stack td .badge { white-space: normal; text-align: left; }
  table.table-stack td::before { content: attr(data-label); color: #6c757d; font-weight: 500; text-align: left;
                                 flex: 0 0 40%; font-size: .85em; margin-right: auto; }
  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-photo { border-radius: 50%; object-fit: cover; }
.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; }
}

/* Thiết bị theo khoa/phòng (trang chủ): danh sách xếp hạng thay cho biểu đồ cột */
.dept-list { max-height: 460px; overflow-y: auto; }
.dept-row { display: block; padding: .35rem .25rem; color: inherit; text-decoration: none; border-bottom: 1px solid rgba(0,0,0,.05); }
.dept-row:hover { background: rgba(0,0,0,.03); }
.dept-bar { display: flex; height: 8px; border-radius: 4px; overflow: hidden; margin-top: 3px; background: #e9ecef; min-width: 6px; }
.dept-bar span { display: block; height: 100%; }
.dept-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 3px; vertical-align: middle; }
[data-bs-theme="dark"] .dept-row { border-bottom-color: rgba(255,255,255,.08); }

/* Thông tin phần mềm cuối trang chủ: tối giản */
.about-foot { border-top: 1px solid rgba(0,0,0,.08); padding: .9rem 0 1rem; margin-top: .5rem; line-height: 1.7; font-size: .8rem; }
.about-foot .ai-row { display: flex; flex-wrap: wrap; justify-content: center; }
.about-foot .ai + .ai::before { content: "|"; margin: 0 .55rem; opacity: .4; }
@media (max-width: 575.98px) {
  .about-foot .ai-row { flex-direction: column; }
  .about-foot .ai + .ai::before { content: none; }
}
[data-bs-theme="dark"] .about-foot { border-top-color: rgba(255,255,255,.1); }
/* Thanh menu: logo về trang chọn phân hệ; chữ tiêu đề / lời chào tự cắt "…" khi hẹp */
.navbar .brand-text { min-width: 0; }
.navbar .brand-home:hover { opacity: .85; }
@media (max-width: 991.98px) {
  .navbar > .container-fluid > .navbar-brand { flex: 1 1 0; min-width: 0; margin-right: .25rem; }
  .navbar .brand-text { font-size: 1.05rem; }
}
