/* m1811 — TỐI ƯU ĐIỆN THOẠI (phản hồi ABC 18/11/2026). Nạp SAU mọi tệp CSS khác. Chỉ áp dụng ở màn hẹp; máy tính giữ nguyên.
   Đi cùng public/admin/mobile.js (gắn lớp .mc cho bảng → thẻ, dựng thanh điều hướng đáy #mtb). */

/* m1911: iPhone / Zalo tự phóng to chữ ở khối rộng hơn màn hình (text autosizing) → chữ to, lệch ô, bị cắt. Giữ đúng cỡ chữ đã định. */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
@media (max-width: 900px) { .card-b p, .finfo span, .ni p, .muted { overflow-wrap: break-word; } }

/* ---------- thanh điều hướng đáy ---------- */
.mtb { display: none; }
.mc-bl { display: none; }
@media (max-width: 900px) {
  .mtb { display: grid; position: fixed; left: 0; right: 0; bottom: 0; z-index: 80; background: #fff; border-top: 1px solid #dce6f5; box-shadow: 0 -6px 18px rgba(10, 40, 100, .09);
    padding: 2px 2px calc(2px + env(safe-area-inset-bottom)); font-family: inherit; }
  .mtb a, .mtb button { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 54px; padding: 4px 2px; border: 0; background: none;
    color: #475569; font-size: 11px; font-weight: 600; line-height: 1.15; text-align: center; text-decoration: none; cursor: pointer; -webkit-tap-highlight-color: transparent; border-radius: 10px; }
  .mtb a > span, .mtb button > span { max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .mtb .ico { width: 23px; height: 23px; stroke-width: 1.9; }
  .mtb .on { color: #1d63dc; }
  .mtb .on::before { content: ''; position: absolute; top: 0; left: 28%; right: 28%; height: 3px; border-radius: 0 0 3px 3px; background: #1d63dc; }
  .mtb a:active, .mtb button:active { background: #eef4ff; }
  .mtb em { position: absolute; top: 3px; left: calc(50% + 5px); min-width: 17px; padding: 0 5px; border-radius: 9px; background: #e11d2e; color: #fff; font-size: 10.5px; font-style: normal; font-weight: 700; line-height: 17px; box-shadow: 0 0 0 2px #fff; }
  body.has-mbar .content { padding-bottom: calc(84px + env(safe-area-inset-bottom)) !important; }
  /* tự cuộn tới ô / nút (Tab, lỗi nhập, “cuộn tới”) chừa chỗ cho thanh đáy — không để nút nằm khuất dưới thanh */
  html:has(body.has-mbar) { scroll-padding-bottom: calc(76px + env(safe-area-inset-bottom)); scroll-padding-top: 8px; }
  body.has-mbar #np-stack { bottom: calc(66px + env(safe-area-inset-bottom)); }
  body.has-mbar #toasts { bottom: calc(70px + env(safe-area-inset-bottom)); }
  body.mkb .mtb { display: none; }
  body.mkb.has-mbar .content { padding-bottom: 24px !important; }
  /* menu trái (ngăn kéo) che cả thanh đáy, đủ chiều cao */
  .shell.dw .side { z-index: 95; }
  .shell.dw .side.open + .main::before { z-index: 92; }
  /* ngăn kéo: bỏ hình tòa nhà + khẩu hiệu ở dock để menu có thêm chỗ */
  .shell.dw .dw-dock .cc-foot { display: none; }
  .shell.dw .side nav a, .shell.dw .cc-side a, .shell.dw .side nav .grp, .shell.dw .cc-side .cc-i { min-height: 42px; }
  /* đầu trang: không dính (thanh đáy đã có điều hướng) — nhường chỗ cho nội dung; tiêu đề tối đa 2 dòng */
  .shell.dw .topbar { position: relative; top: auto; }
  .shell.dw .topbar h1 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  #topbar-extra:empty { display: none; }
  /* ứng dụng đã cài (iPhone / Android): chừa tai thỏ / thanh trạng thái */
  html.m-standalone .shell.dw .topbar { padding-top: calc(6px + env(safe-area-inset-top)); }
  html.m-standalone .shell.dw .side { padding-top: env(safe-area-inset-top); }
}

/* ---------- ô nhập: cỡ chữ 16px để iPhone không tự phóng to khi chạm; nút đủ lớn để chạm ---------- */
@media (max-width: 900px) {
  input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=color]), select, textarea, .ql-editor { font-size: 16px !important; }
  .in, .sel { min-height: 40px; }
  .filters .in, .filters .sel { height: 40px; }
  .btn.sm { min-height: 34px; }
  .btn.icon { min-width: 38px; min-height: 38px; }
  .btn.icon.sm { min-width: 34px; min-height: 34px; }
}

/* ---------- tab, nhóm nút, bộ lọc: xuống dòng thay vì trốn ngoài mép ---------- */
@media (max-width: 760px) {
  .tabs { flex-wrap: wrap; overflow: visible; gap: 6px; border-bottom: 0; margin-bottom: 14px; }
  .tabs button { border: 1px solid var(--line); border-radius: 18px; padding: 7px 12px; margin: 0; background: #fff; white-space: normal; text-align: left; line-height: 1.25; }
  .tabs button.on { background: var(--ink, #13202e); color: #fff; border-color: var(--ink, #13202e); }
  .tabs button.on .tn { background: #fff; color: var(--ink, #13202e); }
  .seg { flex-wrap: wrap; max-width: 100%; }
  .seg button { flex: 1 1 auto; }
  .pg-fn, .zs-fn, .pf-tabs, .cc-tabs2, .cc-wtabs { flex-wrap: wrap !important; overflow: visible !important; max-width: 100%; }
  .filters { gap: 8px; }
  .filters .in, .filters .sel, .filters .grow { min-width: 0; flex: 1 1 140px; max-width: 100%; }
  .card-h { align-items: flex-start; }
  .card-h > .row, .card-h > div:last-child { flex-wrap: wrap; }
  .row > .btn { max-width: 100%; }
  #topbar-extra { flex-wrap: wrap; gap: 6px; }
  #topbar-extra > * { max-width: 100%; }
  .xhead { flex-wrap: wrap; gap: 6px; }
  /* nhãn mức độ / trạng thái: luôn gọn trong ô màu */
  .sev, .badge { white-space: nowrap; max-width: 100%; }
  .pill { max-width: 100%; white-space: normal; overflow-wrap: anywhere; text-align: left; }
  .finfo > span, .finfo > div, .finfo > p { min-width: 0; overflow-wrap: anywhere; }
  /* ô KPI: 2 cột thay vì 1 cột dài */
  .kgrid, .mtiles { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: 8px !important; }
  .kgrid > *, .mtiles > * { min-width: 0; }
  .kgrid .val, .mtiles .val, .kpi2 .val { font-size: 19px !important; overflow-wrap: anywhere; }
  .xtiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .xtile .val { font-size: 18px; overflow-wrap: anywhere; }
  .wtiles { gap: 8px; }
}

/* ---------- BẢNG → THẺ (mobile.js gắn .mc) ---------- */
@media (max-width: 760px) {
  .mc-wrap { overflow: visible !important; max-height: none !important; }
  table.mc { display: block; width: 100% !important; min-width: 0 !important; border: 0; zoom: 1 !important; font-size: 13.5px; background: transparent; }
  table.mc > thead { display: none; }
  table.mc > tbody, table.mc > tfoot { display: block; }
  table.mc > tbody > tr, table.mc > tfoot > tr { display: block; margin: 10px 10px 0; padding: 4px 12px; border: 1px solid var(--line, #dde3ea); border-radius: 12px; background: #fff; box-shadow: 0 1px 3px rgba(15, 35, 70, .06); }
  table.mc > tbody > tr:last-child, table.mc > tfoot > tr:last-child { margin-bottom: 10px; }
  table.mc > tfoot > tr { background: #f6f9fd; }
  table.mc > tbody > tr > td, table.mc > tbody > tr > th, table.mc > tfoot > tr > td, table.mc > tfoot > tr > th {
    /* nhãn cột ở bên trái (::before tuyệt đối), TOÀN BỘ nội dung ô ở cột phải — ô có nhiều dòng (mã + mô tả, người gửi…) không bị chia sang cột nhãn */
    /* flow-root: ô tự cao theo nhãn dài 2–3 dòng (nhãn trôi trái trong vùng đệm, không đè dòng dưới) */
    display: flow-root; position: relative; width: auto !important; min-width: 0 !important; max-width: none !important; height: auto !important;
    padding: 7px 0 7px 122px !important; border: 0; border-bottom: 1px dashed #e6ecf3; text-align: left !important; white-space: normal !important; overflow-wrap: anywhere; background: none; box-shadow: none; }
  table.mc > tbody > tr > *:last-child, table.mc > tfoot > tr > *:last-child { border-bottom: 0; }
  table.mc td::before, table.mc tbody th::before, table.mc tfoot th::before { content: attr(data-l); float: left; width: 112px; margin-left: -122px; padding-top: 1px; color: var(--muted, #5b6b7c); font-size: 12px; font-weight: 500; line-height: 1.35; overflow-wrap: anywhere; text-align: left; }
  table.mc td > *, table.mc th > * { min-width: 0; max-width: 100%; }
  table.mc td.mc-nol, table.mc td.mc-full, table.mc td.mc-act { display: block; padding-left: 0 !important; }
  table.mc td.mc-nol::before, table.mc td.mc-full::before, table.mc td.mc-act::before { display: none; }
  table.mc td.mc-empty { display: none; }
  table.mc td.mc-full { padding: 10px 0; }
  table.mc td.mc-full.empty, table.mc td.empty { text-align: center !important; color: var(--muted); }
  table.mc tr:has(> td.mc-full:only-child) { background: #f8fafc; }
  /* nút thao tác của dòng: hàng nút đầy đủ, dễ chạm, không trốn ngoài mép */
  table.mc td.mc-act { display: flex; flex-wrap: wrap; gap: 8px; padding: 10px 0 8px !important; }
  table.mc td.mc-act .mc-bl { display: inline; font-size: 13px; font-weight: 600; margin-left: 4px; }
  table.mc td.mc-act > .btn, table.mc td.mc-act > a.btn, table.mc td.mc-act > button { flex: 1 1 auto; justify-content: center; min-height: 38px; white-space: nowrap; }
  table.mc td.mc-act > .btn[title]:not(:has(span)) { flex: 0 0 auto; }
  table.mc td .btn { white-space: nowrap; }
  table.mc td .in, table.mc td .sel, table.mc td input, table.mc td select, table.mc td textarea { width: 100% !important; max-width: 100%; }
  table.mc td input[type=checkbox], table.mc td input[type=radio] { width: auto !important; }
  table.mc tr.on, table.mc tr.sel, table.mc tr.active { border-color: #2b7bf3; box-shadow: 0 0 0 1px #2b7bf3; }
  table.mc tr.alrow.od { box-shadow: inset 4px 0 0 var(--crit, #d03b3b); }
  table.mc tr.alrow.od td:first-child { box-shadow: none; }
  /* bảng rộng giữ cuộn ngang: viền mờ báo còn nội dung bên phải */
  .tbl-wrap:has(> table.mc-x) { -webkit-overflow-scrolling: touch; background: linear-gradient(90deg, #fff 30%, rgba(255, 255, 255, 0)) left / 24px 100% no-repeat local, linear-gradient(270deg, #fff 30%, rgba(255, 255, 255, 0)) right / 24px 100% no-repeat local, radial-gradient(farthest-side at 0 50%, rgba(10, 40, 90, .16), transparent) left / 10px 100% no-repeat scroll, radial-gradient(farthest-side at 100% 50%, rgba(10, 40, 90, .16), transparent) right / 10px 100% no-repeat scroll; }
}

/* ---------- hộp thoại: tấm trượt từ đáy, nút Lưu luôn thấy ---------- */
@media (max-width: 760px) {
  .overlay { padding: 0 !important; place-items: end stretch !important; align-items: end !important; }
  .overlay > .modal, .modal, .modal.lg, .modal.xl { width: 100% !important; max-width: 100vw !important; min-width: 0 !important; max-height: calc(100dvh - 12px) !important; border-radius: 16px 16px 0 0 !important; margin: 0 !important; }
  .modal.lg, .modal.xl { min-height: calc(100dvh - 12px); }
  .modal-h { padding: 12px 14px; }
  .modal-h h3, .modal-h b { font-size: 16px; }
  .modal-b, .modal .modal-b { padding: 14px !important; }
  .modal-f { flex-wrap: wrap; gap: 8px; padding: 10px 14px calc(10px + env(safe-area-inset-bottom)) !important; }
  .modal-f > .btn, .modal-f > button { flex: 1 1 auto; justify-content: center; min-height: 42px; }
  .modal .fgrid, .modal .grid.g2, .modal .grid.g3 { grid-template-columns: minmax(0, 1fr) !important; }
}

/* ---------- khung chung ---------- */
@media (max-width: 760px) {
  .content { padding-left: 10px !important; padding-right: 10px !important; }
  .card { border-radius: 12px; }
  .card-b { padding: 12px; }
  .card-h { padding: 12px; }
  .dl2 { grid-template-columns: minmax(88px, 36%) minmax(0, 1fr) !important; }
}
@media print { .mtb, #m-push { display: none !important; } }

/* n1911b (ABC 19/11: “Nút tắt khi mở màn hình xem riêng tệp đính kèm”): khung xem tệp trên điện thoại chiếm cả màn hình — tiêu đề (nút ×) và chân
   (Đóng / Mở tab mới / Tải về) luôn hiện, chỉ khung tệp ở giữa cuộn (trước đây cả khung cuộn nên nút × trôi mất khỏi màn hình) */
@media (max-width: 760px) {
  .modal.fview { height: 100dvh !important; max-height: 100dvh !important; min-height: 0 !important; border-radius: 0 !important; display: flex !important; flex-direction: column; overflow: hidden !important; }
  .modal.fview .modal-h { flex: none; display: flex; align-items: center; gap: 8px; padding-top: calc(env(safe-area-inset-top, 0px) + 10px); }
  .modal.fview .modal-h h3 { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .modal.fview .modal-h [data-x] { flex: none; }
  .modal.fview .modal-b { flex: 1 1 auto; min-height: 0; padding: 0 !important; overflow: hidden; }
  .modal.fview .fv-frame { height: 100% !important; }
  .modal.fview .modal-f { flex: none; }
}
