/* NAK CRM – giao diện điện thoại. Chỉ áp dụng khi màn hình rộng dưới 768px; máy tính giữ nguyên. */
.mtab,.m-only,.m-ftog{display:none}
@media (max-width:767px){
  html{-webkit-text-size-adjust:100%;text-size-adjust:100%}
  .pq,.pq *,.a4,.a4 *{-webkit-text-size-adjust:none;text-size-adjust:none}
  .pq *:not(img):not(svg),.a4 *:not(img):not(svg){max-height:1000000px}
  body{background:var(--bg)}
  input,select,textarea{font-size:16px;min-height:44px;border-radius:10px}   /* 16px: iPhone không tự phóng to khi gõ */
  .btn{min-height:44px;border-radius:10px;padding:8px 14px}
  .btn.sm{min-height:36px}
  .icon-btn{min-width:44px;min-height:44px;justify-content:center;align-items:center}

  /* khung chính */
  .side,.scrim,.menu-btn,.me,.dock-fab{display:none!important}
  .top{height:56px;padding:0 6px 0 14px;gap:4px;padding-top:env(safe-area-inset-top)}
  .top-title{display:block!important;flex:1;min-width:0;font-size:17px;font-weight:700;color:var(--ink);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
  .top-search{display:none;position:absolute;left:0;right:0;top:0;height:56px;max-width:none;margin:0;padding:6px 10px;background:#fff;z-index:30;box-sizing:border-box}
  .top.m-search .top-search{display:block}
  .top-search .dropdown{left:10px;right:10px}
  .m-only{display:inline-flex}
  .view{padding:12px 12px calc(86px + env(safe-area-inset-bottom))}

  /* thanh điều hướng dưới */
  .mtab{display:grid;grid-auto-flow:column;grid-auto-columns:minmax(0,1fr);position:fixed;left:0;right:0;bottom:0;z-index:40;background:#fff;border-top:1px solid var(--line);padding:6px 6px calc(6px + env(safe-area-inset-bottom))}
  body:has(#app.hidden) .mtab{display:none}
  .mtab-i{position:relative;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:2px;min-height:52px;border:0;background:none;border-radius:12px;color:#5b6577;font:600 11px/1.2 inherit;text-decoration:none;cursor:pointer}
  .mtab-i.on{color:var(--navy);background:var(--navy-3)}
  .mtab-i .dk-b{position:absolute;top:3px;left:calc(50% + 6px)}

  /* tiêu đề trang, thanh lọc */
  .page-head{gap:8px}
  .page-head h2{font-size:21px;flex:1 1 100%;margin:0}
  .page-head .btn,.page-head select{flex:1 1 auto;justify-content:center}
  .crumb{display:none}
  .toolbar{flex-wrap:wrap;gap:8px}
  .toolbar>*{flex:1 1 calc(50% - 4px);min-width:0!important;max-width:none}
  .toolbar.m-has .grow{flex:1 1 calc(100% - 96px);order:-2}
  .toolbar.m-has>:not(.grow):not(.m-ftog){display:none}
  .toolbar.m-has.m-open>:not(.grow):not(.m-ftog){display:flex}
  .toolbar.m-has.m-open>select,.toolbar.m-has.m-open>input{display:block}
  .m-ftog{flex:0 0 auto!important;order:-1;display:inline-flex!important}
  .m-ftog b{background:var(--red);color:#fff;border-radius:9px;font-size:11px;min-width:18px;padding:0 5px;line-height:18px;text-align:center}
  .toolbar input[type=date]{font-size:14px}
  .page-head [data-act=export]{display:none}
  .page-head.m-dup h2{display:none}
  .tabs{margin-left:-12px;margin-right:-12px;padding:0 6px}
  .tab{white-space:nowrap}

  /* biểu mẫu: 2 cột, ô dài chiếm cả hàng */
  .form:not([style*="grid-template-columns:1fr"]){grid-template-columns:repeat(2,minmax(0,1fr))!important;gap:10px}
  .form .wide,.form .span2,.form .span3,.form .span4,.form label:has(textarea),.form label:has(.pick),.form .check{grid-column:1/-1!important}
  table.m-cards tbody td:first-child:has(>input[type=checkbox]){display:flex;font-size:13px}
  /* số liệu */
  .stats{grid-template-columns:repeat(2,minmax(0,1fr));gap:10px}
  .stat{border-radius:14px;padding:12px}
  .stat .v{font-size:19px}
  .card{border-radius:14px}
  .kv{grid-template-columns:104px minmax(0,1fr)!important;gap:6px 10px}
  .kv dd{grid-column:auto!important}

  /* bảng → thẻ */
  .tbl-wrap{overflow:visible;border:0;background:none;box-shadow:none}
  table.m-cards{display:block;width:100%!important;min-width:0!important;table-layout:auto!important;border:0;background:none}
  table.m-cards colgroup,table.m-cards thead{display:none}
  table.m-cards tbody,table.m-cards tfoot{display:block}
  table.m-cards tr{display:block;background:#fff;border:1px solid var(--line);border-radius:14px;padding:10px 12px;margin-bottom:10px;box-shadow:0 1px 2px rgba(16,24,40,.04)}
  table.m-cards td{display:flex;justify-content:space-between;align-items:flex-start;gap:10px;border:0!important;padding:3px 0!important;text-align:right!important;min-height:0;font-size:13.5px;white-space:normal!important;max-width:none!important;width:auto!important}
  table.m-cards td::before{content:attr(data-label);flex:0 0 auto;max-width:46%;text-align:left;color:var(--mut);font-size:12.5px;font-weight:500}
  table.m-cards td[data-label=""]::before{display:none}
  table.m-cards td:empty{display:none}
  table.m-cards tbody td:first-child{display:block;text-align:left!important;font-size:15px;font-weight:700;color:var(--navy);padding-bottom:5px!important}
  table.m-cards tbody td:first-child::before{display:none}
  table.m-cards tr.click{cursor:pointer}
  table.m-cards tr.click:active{background:var(--navy-3)}
  table.m-cards td.empty{display:block;text-align:center!important;color:var(--mut)}
  table.m-cards tfoot tr{background:var(--navy-3);font-weight:700}
  table.m-cards td>input,table.m-cards td>select,table.m-cards td>textarea{max-width:62%}
  .pager{justify-content:center;flex-wrap:wrap}

  /* bảng dòng hàng của báo giá: mỗi dòng là một thẻ, ô nhập to */
  table.q-items.m-cards td{align-items:center}
  table.q-items.m-cards td>input,table.q-items.m-cards td>select,table.q-items.m-cards td>.pick,table.q-items.m-cards td>div{flex:0 1 62%;max-width:62%;text-align:left}
  table.q-items.m-cards td textarea{flex:1 1 100%;max-width:none;min-height:64px}
  table.q-items.m-cards tbody td:first-child{display:flex;font-size:13px}
  .q-wrap{overflow:visible!important}

  /* hộp thoại: toàn màn hình */
  .modal-bg{padding:0;place-items:stretch}
  .modal,.modal.wide,.modal.narrow{width:100%;max-height:none;height:100%;border-radius:0}
  .modal-h{padding:12px 14px;padding-top:calc(12px + env(safe-area-inset-top));position:sticky;top:0;background:#fff;z-index:2}
  .modal-b{padding:14px;flex:1}
  .modal-f{padding:10px 14px calc(10px + env(safe-area-inset-bottom));gap:8px}
  .modal-f .btn{flex:1 1 0;justify-content:center}

  /* chat: toàn màn hình, nằm trên thanh dưới */
  .dock,.dock.min{width:100vw!important;z-index:70!important}
  .dock .dock-head{padding-top:env(safe-area-inset-top);height:auto;min-height:60px}
  .dock .chat-ft{padding-bottom:calc(8px + env(safe-area-inset-bottom))}

  /* trang Menu */
  .mm-head{display:flex;align-items:center;gap:12px;background:var(--navy);color:#fff;border-radius:16px;padding:14px;margin-bottom:14px}
  .mm-head .avatar{width:44px;height:44px;font-size:15px;background:#e9c46a;color:#14213d}
  .mm-head .small{color:#c9d3ea}
  .mm-sec{margin-bottom:14px}
  .mm-sec h3{margin:0 0 6px 4px;font-size:11px;letter-spacing:1px;text-transform:uppercase;color:var(--mut)}
  .mm-grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));background:#fff;border:1px solid var(--line);border-radius:16px;overflow:hidden}
  .mm-it{min-height:84px;padding:10px 6px;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:6px;text-align:center;text-decoration:none;color:var(--ink);font-size:12px;font-weight:600;line-height:1.25}
  .mm-it:active{background:var(--navy-3)}
  .mm-ic{width:42px;height:42px;border-radius:12px;background:var(--navy-3);color:var(--navy);display:flex;align-items:center;justify-content:center}
  .mm-ic svg{width:22px;height:22px}
  .mm-acc{display:grid;grid-template-columns:1fr 1fr;gap:8px}

  /* tổng quan */
  .ov-top,.ov-row2{grid-template-columns:1fr!important}
  .ov-range{overflow-x:auto;flex-wrap:nowrap;max-width:100%}

  /* toast trên thanh dưới */
  .toasts{bottom:calc(80px + env(safe-area-inset-bottom))!important;left:12px;right:12px}
}
