/* iPOS Phone & Tablet shell for Goods Transport (js/mshell.js). Scoped to body.ms-phone / body.ms-tab; the PC layout is untouched. */
#msNav, #msBack, #msPhoneBtn, #msSheet, .ms-toast { display: none; }
body.ms-on #msSheet { display: block; }

/* ============================ PHONE ============================ */
body.ms-phone { font-size: 16px; overscroll-behavior-y: none; }
body.ms-phone #side { display: none; }
body.ms-phone #main { margin-left: 0; }
body.ms-phone #top { position: sticky; top: 0; z-index: 40; flex-wrap: nowrap; gap: 6px; padding: calc(8px + env(safe-area-inset-top)) 10px 8px 12px; min-height: 54px; }
body.ms-phone #top h2 { font-size: 19px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: -.2px; }
body.ms-phone #menuBtn { display: none; }
body.ms-phone #msBack { display: none; width: 40px; height: 40px; margin-left: -6px; border: 0; border-radius: 12px; background: transparent; color: var(--txt); align-items: center; justify-content: center; flex: none; padding: 0; }
body.ms-phone.ms-detail #msBack { display: flex; }
body.ms-phone #msBack svg { width: 24px; height: 24px; }
body.ms-phone .top-right { flex-wrap: nowrap; flex: none; }
body.ms-phone .top-right .chip:not(#branchBox .chip), body.ms-phone #logoutBtn { display: none; }
body.ms-phone #branchBox select { max-width: 130px; min-height: 38px; padding: 4px 6px; font-size: 13px; }
body.ms-phone #branchBox .chip { display: inline-block; max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
body.ms-phone #page { padding: 12px 12px calc(96px + env(safe-area-inset-bottom)); }
body.ms-phone .card { padding: 14px; border-radius: 16px; }
body.ms-phone input, body.ms-phone select, body.ms-phone textarea { font-size: 16px; min-height: 46px; border-radius: 12px; }
body.ms-phone .btn { min-height: 44px; border-radius: 12px; font-weight: 700; }
body.ms-phone .btn.small { min-height: 38px; padding: 6px 12px; }
body.ms-phone .grid2 { grid-template-columns: minmax(0, 1fr); }
body.ms-phone .grid3 { grid-template-columns: minmax(0, 1fr); }
body.ms-phone .grid4, body.ms-phone .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
body.ms-phone .stat { padding: 12px 14px; border-radius: 16px; }
body.ms-phone .stat b { font-size: 21px; }
body.ms-phone .toolbar, body.ms-phone .quick { gap: 8px; }
body.ms-phone .toolbar .btn, body.ms-phone .quick .btn { flex: 1 1 auto; }
body.ms-phone .filters label { min-width: 0; flex: 1 1 130px; }
body.ms-phone .grid2 > [style*="span"], body.ms-phone .span2 { grid-column: 1 / -1 !important; }
body.ms-phone .keypad { display: none; }

/* bottom tabs */
body.ms-on #msNav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 45; display: flex; background: rgba(255,255,255,.97); backdrop-filter: blur(10px); border-top: 1px solid var(--line); padding: 4px 4px calc(4px + env(safe-area-inset-bottom)); }
body.ms-tab #msNav { display: none; }
#msNav a, #msNav button { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 7px 2px 5px; font-size: 11.5px; font-weight: 600; color: var(--mut); border: 0; background: transparent; border-radius: 14px; text-decoration: none; position: relative; font-family: inherit; }
#msNav i { font-style: normal; font-size: 21px; line-height: 1.15; }
#msNav span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#msNav a.on { color: var(--pri-2); }
#msNav a.on::before { content: ""; position: absolute; top: 0; left: 28%; right: 28%; height: 3px; border-radius: 0 0 4px 4px; background: var(--pri-2); }
#msNav a:active, #msNav button:active { background: #eef3f5; }

/* tables -> cards */
body.ms-phone table.ms-cards { display: block; }
body.ms-phone table.ms-cards thead { display: none; }
body.ms-phone table.ms-cards tbody, body.ms-phone table.ms-cards tfoot { display: block; }
body.ms-phone table.ms-cards tr { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 6px 14px; padding: 12px 4px; border-bottom: 1px solid var(--line); align-items: start; }
body.ms-phone table.ms-cards tr:last-child { border-bottom: 0; }
body.ms-phone table.ms-cards tr:active { background: #f1f5f7; }
body.ms-phone table.ms-cards td { display: block; padding: 0 !important; border: 0 !important; min-width: 0; word-break: break-word; text-align: left !important; font-size: 14.5px; }
body.ms-phone table.ms-cards td[data-label]:not(:empty)::before { content: attr(data-label); display: block; font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--mut); margin-bottom: 1px; }
body.ms-phone table.ms-cards td.ms-title { grid-column: 1 / -1; font-size: 16.5px; font-weight: 800; order: -1; }
body.ms-phone table.ms-cards td.ms-title::before, body.ms-phone table.ms-cards td.ms-act::before { display: none !important; }
body.ms-phone table.ms-cards td.ms-empty { display: none; }
body.ms-phone table.ms-cards td.ms-act { grid-column: 1 / -1; display: flex; gap: 8px; flex-wrap: wrap; }
body.ms-phone table.ms-cards td.ms-act .btn { flex: 1 1 auto; }
body.ms-phone table.ms-cards tr.ms-head { display: none; }
body.ms-phone table.ms-cards td[colspan] { grid-column: 1 / -1; }
body.ms-phone table.ms-cards td input, body.ms-phone table.ms-cards td select { width: 100%; min-width: 0; }
body.ms-phone table.ms-cards { min-width: 0 !important; width: 100% !important; }
body.ms-on .ms-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
body.ms-on table.ms-wide { min-width: 640px; }

/* forms and pop-ups: full screen, the buttons stay in reach */
body.ms-phone .modal-back { padding: 0; place-items: stretch; background: #fff; overflow: hidden; }
body.ms-phone .modal, body.ms-phone .modal.wide { max-width: none; width: 100%; height: 100dvh; max-height: none; border-radius: 0; box-shadow: none; display: flex; flex-direction: column; overflow: hidden; }
body.ms-phone .modal-head { flex: none; padding: calc(10px + env(safe-area-inset-top)) 14px 10px; min-height: 56px; }
body.ms-phone .modal-head h3 { font-size: 18px; }
body.ms-phone .modal-body { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 14px 14px calc(90px + env(safe-area-inset-bottom)); }
body.ms-phone .modal-body .actions { position: fixed; left: 0; right: 0; bottom: 0; margin: 0; padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); background: #fff; border-top: 1px solid var(--line); box-shadow: 0 -6px 18px rgba(0,0,0,.06); z-index: 5; flex-wrap: nowrap; }
body.ms-phone .modal-body .actions .btn { flex: 1 1 0; min-height: 50px; font-size: 16px; }
body.ms-phone .modal-body .actions .btn.primary { flex: 2 1 0; order: 9; }
body.ms-phone form .actions:not(.left) { position: sticky; bottom: calc(66px + env(safe-area-inset-bottom)); background: linear-gradient(transparent, var(--bg) 30%); padding: 14px 0 6px; z-index: 5; }
body.ms-phone form .actions .btn { flex: 1 1 auto; min-height: 48px; }
body.ms-phone.kb-open #msNav { display: none; }
body.ms-phone.kb-open .modal { height: var(--vvh, 100dvh); }
body.ms-phone.kb-open .modal-body { padding-bottom: 36vh; }
body.ms-phone.kb-open form .actions { position: static; }
body.ms-phone .toast { bottom: calc(80px + env(safe-area-inset-bottom)); }

/* demo pill */
body.ms-on #demoPill { left: 10px !important; right: auto !important; bottom: calc(76px + env(safe-area-inset-bottom)) !important; padding: 5px 10px !important; gap: 6px !important; border-radius: 999px !important; font-size: 11px !important; max-width: calc(100vw - 110px); }
body.ms-on #demoPill span { display: none !important; }
body.ms-on:has(.modal-back) #demoPill, body.ms-on:has(#msSheet) #demoPill { display: none !important; }
body.ms-tab #demoPill { bottom: 14px !important; }

/* bottom sheet (More menu) */
body.ms-on #msSheet { position: fixed; inset: 0; z-index: 90; }
.ms-sheet-bg { position: absolute; inset: 0; background: rgba(10,20,30,.45); }
.ms-sheet { position: absolute; left: 0; right: 0; bottom: 0; max-height: 84dvh; display: flex; flex-direction: column; background: #fff; border-radius: 22px 22px 0 0; padding: 8px 14px calc(14px + env(safe-area-inset-bottom)); max-width: 640px; margin: 0 auto; animation: msu .2s ease; }
.ms-grab { width: 42px; height: 5px; border-radius: 3px; background: var(--line); margin: 2px auto 10px; }
.ms-sheet h3 { margin: 2px 4px 10px; font-size: 17px; }
.ms-sheet-body { overflow-y: auto; }
.ms-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.ms-grid a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; min-height: 86px; padding: 10px 6px; border: 1px solid var(--line); border-radius: 16px; text-decoration: none; color: var(--txt); text-align: center; }
.ms-grid a i { font-style: normal; font-size: 24px; color: var(--pri-2); }
.ms-grid a b { font-size: 12.5px; line-height: 1.2; }
.ms-grid a:active { background: #eef3f5; }
@keyframes msu { from { transform: translateY(40px); opacity: .4; } to { transform: none; opacity: 1; } }
.ms-toast { position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom)); transform: translate(-50%, 10px); background: #111827; color: #fff; padding: 10px 18px; border-radius: 999px; font-weight: 700; z-index: 120; opacity: 0; transition: .25s; }
body.ms-on .ms-toast { display: block; } .ms-toast.on { opacity: 1; transform: translate(-50%, 0); }
#msPhoneBtn { display: block; position: fixed; right: 10px; top: 10px; z-index: 100; border: 0; border-radius: 999px; padding: 9px 16px; background: var(--pri-2); color: #fff; font-weight: 800; box-shadow: 0 4px 14px rgba(0,0,0,.3); }

/* ============================ TABLET ============================ */
body.ms-tab { --side: 86px; font-size: 16px; }
body.ms-tab #side { transform: none !important; box-shadow: none !important; }
body.ms-tab .brand { display: none; }
body.ms-tab .side-foot, body.ms-tab .nav-group { display: none; }
body.ms-tab nav { padding: 8px 6px; }
body.ms-tab nav a { flex-direction: column; justify-content: center; gap: 3px; text-align: center; padding: 10px 2px; margin-bottom: 2px; min-height: 62px; border-left: 0; border-radius: 14px; font-size: 10.5px; line-height: 1.15; }
body.ms-tab nav a .ni { font-size: 22px; width: auto; }
body.ms-tab nav a kbd { display: none; }
body.ms-tab #main { margin-left: var(--side); }
body.ms-tab #menuBtn { display: none; }
body.ms-tab #top { padding: 12px 22px; }
body.ms-tab #page { padding: 18px 22px 40px; }
body.ms-tab .grid4 { grid-template-columns: repeat(2, 1fr); }
body.ms-tab .btn { min-height: 44px; }
body.ms-tab .btn.small { min-height: 38px; }
body.ms-tab input, body.ms-tab select { min-height: 44px; font-size: 16px; }
body.ms-tab .tbl td, body.ms-tab .tbl th { padding-top: 12px; padding-bottom: 12px; }
body.ms-tab .modal { max-width: 680px; border-radius: 20px; }
body.ms-tab .modal.wide { max-width: 860px; }

/* ============ number pad + keyboard fit (touch screens) ============ */
#numpad { position: fixed; left: 0; right: 0; bottom: 0; z-index: 400; display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; padding: 9px 10px calc(10px + env(safe-area-inset-bottom)); background: #e9eef2; border-top: 1px solid #c9d3db; box-shadow: 0 -8px 24px rgba(0,0,0,.16); max-width: 640px; margin: 0 auto; touch-action: manipulation; user-select: none; -webkit-user-select: none; }
#numpad[hidden] { display: none; }
#numpad button { height: 52px; border: 0; border-radius: 12px; background: #fff; font-size: 24px; font-weight: 700; color: #1d2b36; box-shadow: 0 1px 0 #b9c4cc; cursor: pointer; -webkit-tap-highlight-color: transparent; }
#numpad button:active { background: #dbe5ec; }
#numpad button.fn { background: #d6dee5; font-size: 16px; font-weight: 700; }
#numpad button.kb { font-size: 13px; }
#numpad button.ok { background: var(--pri-2); color: #fff; font-size: 17px; box-shadow: none; }
#numpad.int .pt { visibility: hidden; }
body.np-open { padding-bottom: 292px !important; }
body.np-open .modal { height: calc(100dvh - 292px) !important; max-height: calc(100dvh - 292px) !important; }
body.np-open #msNav, body.np-open #demoPill { display: none !important; }
body.np-open input[data-np="1"]:focus { border-color: var(--pri-2); box-shadow: 0 0 0 3px rgba(22,105,122,.22); }
body.np-open .modal-body .actions { display: none; }
@media print { #msNav, #msBack, #msSheet, #numpad, #msPhoneBtn { display: none !important; } }
