/* Loaded after module styles to keep every dialog inside its iframe viewport. */
@media(max-width:768px){
 .pm-ov,.iv-ov,.overlay,.modal-overlay,.modal-wrap{padding:10px!important;align-items:center!important;overflow:hidden!important}
 .pm-m,.iv-m,.modal{box-sizing:border-box;display:flex!important;flex-direction:column;align-self:auto!important;width:100%!important;max-width:640px!important;height:calc(100vh - 20px)!important;height:calc(100dvh - 20px)!important;max-height:calc(100dvh - 20px)!important;min-height:0;overflow:hidden!important;border-radius:12px!important}
 .pm-mb,.iv-mb,.modal-body,.modal-scroll,.mbody,.mbd{flex:1 1 auto!important;min-height:0;max-height:none!important;overflow:auto!important;overscroll-behavior:contain;-webkit-overflow-scrolling:touch}
 .pm-mh,.iv-mh,.modal-header,.modal-head,.mhd,.pm-mf,.iv-mf,.modal-footer,.modal-foot,.mft{flex-shrink:0!important}
 .pm-mc,.iv-mc,.modal-close,.drawer-close,.modal-header>button,.mhd>button{min-width:44px;min-height:44px}
 .pm-mf,.iv-mf,.modal-footer,.modal-foot,.mft{flex-wrap:wrap}
 input,select,textarea{font-size:16px!important}
}

/* Phone UI: comfortable touch targets, readable cards and vertically stacked forms. */
.mobile-action-text,.mobile-field-label{display:none}
.mobile-line-field{display:contents}
@media(max-width:768px){
 html{scroll-padding:16px}
 body{font-size:15px;line-height:1.5;-webkit-text-size-adjust:100%}
 button,[role="button"],input,select,textarea{touch-action:manipulation}
 button{min-height:44px;max-width:100%}
 input:not([type="checkbox"]):not([type="radio"]):not([type="file"]),select{min-height:46px;min-width:0;max-width:100%;border-radius:12px!important}
 textarea{min-height:90px;max-width:100%}
 input[type="checkbox"],input[type="radio"]{width:20px!important;height:20px!important}
 button:focus-visible,[role="button"]:focus-visible,input:focus-visible{outline:2px solid var(--accent);outline-offset:2px}
 button:active{filter:brightness(.94)}
 .pm,.iv,.orders-page,.page:not(:has(>.page-hdr)){padding:20px 16px 28px!important;min-height:100%}
 .page-hdr{padding:20px 16px 0!important}
 .wrap{padding:16px 16px 28px}
 .pm-hdr,.iv-hdr,.mod-hdr{gap:10px;margin-bottom:18px}
 .pm-hdr h2,.iv-hdr h2,.mod-hdr h2{font-size:22px;font-weight:650;letter-spacing:-.4px}
 .pm-logo,.iv-logo,.mod-logo{display:none}
 .mobile-page-heading,.page-hdr,.page-header{gap:12px;flex-wrap:wrap;align-items:center}
 .btn-create{min-height:46px;padding:10px 16px!important;font-size:14px!important;border-radius:14px!important;justify-content:center}
 .pm-tb,.iv-tb{gap:10px}
 .pm-search,.iv-search{flex-basis:100%;background:var(--surface);min-height:48px;border-radius:14px}
 .pm-tb>.btn-create,.pm-tb>.pm-btn:not(:only-child),.iv-tb>.iv-btn:not(:only-child){flex:1;justify-content:center}
 .pm-tb .pm-search input,.iv-tb .iv-search input{min-height:44px;padding:10px 0}
 .pm-btn,.iv-btn,.btn-ghost,.ab,.abtn,.ibtn,.btn-sm,.btn-primary,.sb,.btn-add-line,.add-row-btn{min-height:44px;justify-content:center;border-radius:12px;font-size:14px}
 .pm-sec-hdr .icon-btn,.cs-opt-del,.cs-opt-edit,.ch-edit-btn{min-width:44px;min-height:44px;justify-content:center}
 .pm-sec-hdr{gap:6px;margin-top:24px;margin-bottom:12px}
 .pm-sec-hdr .sec-title{flex:1;min-width:0;overflow-wrap:anywhere;font-size:16px}
 .pm-sec-hdr.cat .sec-title{font-size:14px}
 .pm-sec-hdr .sec-edit input{width:0;flex:1;min-width:0}
 .pm-grid,.iv-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px}
 .pm-card,.iv-card{border-radius:16px;display:flex;flex-direction:column;min-width:0}
 .pm-card .pimg,.iv-card .cimg{height:120px;flex-shrink:0}
 .pm-card .pinfo,.iv-card .cinfo{padding:12px}
 .pm-card .pname,.iv-card .cname{font-size:15px;overflow-wrap:anywhere}
 .pm-card .acts{position:static;order:3;opacity:1;padding:8px;gap:6px;border-top:1px solid var(--border)}
 .pm-card .acts button{flex:1;width:auto;height:44px;font-size:14px;border:0;background:var(--surface-2);gap:4px}
 .pm-pv .acts{opacity:1;top:10px;right:10px}
 .pm-pv .acts button{width:44px;height:44px}
 .pm-pv{padding:16px;gap:12px;border-radius:16px}
 .pm-pv-name{padding-right:34px;font-size:17px}
 .pm-pv-img{width:64px;height:64px}
 .pm-pv-stats,.iv-pv-stats2{gap:12px}
 .pm-pv-info,.iv-pv-info2{min-width:0}
 .mobile-action-text{display:inline;font-size:13px;white-space:nowrap}
 .pm-pv .mobile-action-text{display:none}
 .iv-warn-entry{border-radius:14px;margin:16px 0;min-height:52px}
 .iv-tabs,.flow-tabs{width:100%;border:0;background:var(--surface-2);padding:4px;border-radius:14px;gap:4px;box-sizing:border-box}
 .iv-tab,.ftab{flex:1;min-width:0;min-height:44px;justify-content:center;display:flex;align-items:center;font-size:13px;padding:8px 4px;border:0;border-radius:11px;text-align:center}
 .iv-tab.act,.ftab.active{background:var(--surface);color:var(--accent-strong);box-shadow:0 2px 5px rgba(30,20,60,.06)}
 .iv-tab i{display:none}
 .iv-layout{display:block;border:0;overflow:visible;min-height:0}
 .iv-side{width:100%;max-height:180px;border:1px solid var(--border);border-radius:14px;margin-bottom:14px;overflow-y:auto}
 .iv-si,.iv-s1,.iv-s2,.iv-s3{min-height:44px;font-size:14px}
 .iv-main{overflow:visible}
 .iv-tw2,.pm-tw{border:0;overflow:visible}
 .note-text{white-space:normal;max-width:none}
 /* Rows become self-labelled records; original controls and values are retained. */
 .mobile-records{display:block;width:100%;min-width:0!important;border:0;font-size:14px}
 .mobile-records thead,.mobile-record-head{display:none!important}
 .mobile-records tbody{display:block}
 .mobile-records .mobile-record{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:0 14px;margin-bottom:12px;padding:14px;background:var(--surface);border:1px solid var(--border);border-radius:16px;overflow:hidden}
 .mobile-records td{display:flex;flex-direction:column;gap:4px;padding:8px 0!important;border:0!important;white-space:normal!important;text-align:left!important;min-width:0;overflow-wrap:anywhere;font-size:15px!important}
 .mobile-records td::before,.mobile-grid-record>[data-mobile-label]::before{content:attr(data-mobile-label);display:block;font-size:12px;font-weight:400;color:var(--ink-2);margin-bottom:3px}
 .mobile-records td:first-child{grid-column:1/-1;font-size:16px!important;font-weight:600}
 .mobile-records .mobile-actions-cell,.mobile-records .mobile-full-cell{grid-column:1/-1}
 .mobile-records .mobile-actions-cell{border-top:1px solid var(--border)!important;margin-top:8px;padding-top:12px!important}
 .mobile-actions-cell:before{display:none!important}
 .mobile-actions-cell>div{justify-content:flex-end;gap:10px!important}
 .mobile-actions-cell button{padding:8px 14px!important}
 .sum-row,.stat-row,.met-grid,.kpi-row{grid-template-columns:repeat(2,minmax(0,1fr))!important;gap:10px!important;margin-bottom:20px}
 .sum-row .sc:first-child{grid-column:auto}.sum-row .sc:last-child{grid-column:1/-1}
 .sc,.stat-card,.met,.kpi-card{min-width:0;padding:16px;border:1px solid var(--border);border-radius:16px}
 .sl,.sc-label,.kpi-label{font-size:13px}.sv,.sc-val,.kpi-val{font-size:25px;overflow-wrap:anywhere;font-variant-numeric:tabular-nums}
 .mobile-filters{display:grid!important;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px!important}
 .mobile-filters>div{display:block!important;min-width:0}.mobile-filters>div>div{width:100%!important}.mobile-filters>div>span{display:block;margin:0 0 5px}
 .cs-wrap{min-width:0}.cs-trigger{min-height:46px;padding:10px 12px!important;border-radius:12px;font-size:15px;box-sizing:border-box}
 .cs-opt{min-height:48px;display:flex;align-items:center;font-size:15px;padding:12px;box-sizing:border-box;white-space:normal}
 .cs-opt[hidden]{display:none!important}
 .cs-opt-manage .cs-opt-del{opacity:1}
 .poc,.card,.shop-card,.flow-wrap,.rank-card{border-radius:16px}
 .pr1,.pr1-left,.pr1-right,.chd,.cft{flex-wrap:wrap;row-gap:8px}
 .pr1{padding:16px 16px 4px}.pr2{padding:10px 16px 16px;gap:10px}
 .pr1-right{margin-left:0}.pid{white-space:normal;overflow-wrap:anywhere}
 .pbtns{width:100%;gap:8px}.pbtns button{flex:1}
 .shop-card-head{gap:12px;flex-wrap:wrap}.shop-card-foot{gap:12px;padding:14px}
 .ch-stat-grid,.grid2{grid-template-columns:1fr}
 .ch-stat-item{padding:18px;border-radius:16px}
 .ch-stat-top{gap:8px;flex-wrap:wrap}.ch-stat-row{font-size:14px;gap:10px}
 .month-tbl,.month-tbl-scroll{overflow:visible;background:transparent;border:0}
 .trow.head,.rank-row.head{display:none}
 .mobile-grid-record{display:grid;min-width:0!important;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px;padding:16px;margin-bottom:12px;border:1px solid var(--border);border-radius:16px;background:var(--surface);font-size:15px}
 .mobile-grid-record>span:first-child{grid-column:1/-1;font-size:17px}
 .mobile-grid-record>*{min-width:0;overflow-wrap:anywhere}
 .fsum{gap:12px;padding:16px}.fsum-item{font-size:13px}
 /* Full-height editing view; compact confirmation dialogs stay compact. */
 html.mobile-modal-open,html.mobile-modal-open body{overflow:hidden}
 .pm-ov,.iv-ov,.overlay,.modal-overlay,.modal-wrap{padding:0!important}
 .pm-m,.iv-m,.modal{max-width:none!important;height:100vh!important;height:var(--mobile-vh,100dvh)!important;max-height:var(--mobile-vh,100dvh)!important;border-radius:0!important;border:0!important}
 .pm-mh,.iv-mh,.modal-header,.modal-head,.mhd{padding:calc(10px + env(safe-area-inset-top,0px)) 16px 10px!important;min-height:64px;gap:12px}
 .pm-mh h3,.iv-mh h3,.modal-head-title,.modal-htitle,.mhd h3{font-size:18px;font-weight:600}
 .pm-mb,.iv-mb,.modal-body,.modal-scroll,.mbody,.mbd{padding:20px 16px!important}
 .pm-mf,.iv-mf,.modal-footer,.modal-foot,.mft,.abar{flex-shrink:0!important;padding:12px 16px calc(12px + env(safe-area-inset-bottom,0px))!important;gap:10px;flex-wrap:wrap;background:var(--surface)}
 .pm-mf>button,.iv-mf>button,.modal-footer>button,.modal-foot>button,.mft>button,.abar>button{flex:1;min-height:48px;justify-content:center;font-size:15px}
 .pm-m:not(:has(.pm-mh)),.iv-m:not(:has(.iv-mh)),.modal:not(:has(.mhd,.modal-head,.modal-header)){height:auto!important;max-height:calc(var(--mobile-vh,100dvh) - 32px)!important;max-width:calc(100% - 32px)!important;border-radius:20px!important;margin:auto}
 .pm-fg,.iv-fg,.fgrp,.fg{margin-bottom:16px}
 .pm-fg label,.iv-fg label,.fgrp label,.fl,.lbl{font-size:14px!important;line-height:1.5;margin-bottom:7px}
 .pm-fr,.form-row.c2,.form-row.c3,.g2,.g3,.r2{display:grid;grid-template-columns:1fr;gap:12px}
 .pm-fr>*{min-width:0}
 .npi-hdr,.sale-line-hd,.restock-line-hd{display:none}
 .npi-scroll{overflow:visible}
 .npi-scroll .npi-row,.sale-line,.restock-line{min-width:0;display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px;padding:16px;margin-bottom:16px;border:1px solid var(--border);border-radius:16px;background:var(--surface-2)}
 .mobile-line-field{display:flex;flex-direction:column;gap:6px;min-width:0}
 .mobile-field-label{display:block;font-size:13px;color:var(--ink-2)}
 .npi-row>.mobile-line-field:nth-child(3),.npi-row>.mobile-line-field:nth-child(4),.sale-line>.mobile-line-field:first-child,.restock-line>.mobile-line-field:first-child{grid-column:1/-1}
 .npi-row>button,.sale-line>button,.restock-line>button{min-width:44px;justify-self:end}
 .total-row{flex-wrap:wrap;justify-content:space-between;gap:10px;padding:12px 0}
 .mobile-picker{position:fixed;inset:auto 0 0;width:100%;max-width:none;max-height:calc(var(--mobile-vh,100dvh) - 16px);margin:0;border:0;border-radius:24px 24px 0 0;background:var(--surface);color:var(--ink);padding:16px 16px calc(16px + env(safe-area-inset-bottom,0px));box-sizing:border-box;overflow:hidden}
 .mobile-picker[open]{display:flex;flex-direction:column;gap:12px}
 .mobile-picker::backdrop{background:rgba(20,15,40,.48)}
 .mobile-picker-head{display:flex;align-items:center;justify-content:space-between;flex-shrink:0}
 .mobile-picker-head button{border:0;background:var(--accent-tint);color:var(--accent-strong);padding:8px 16px;border-radius:12px;font:inherit}
 .mobile-picker-search{width:100%;padding:10px 12px;border:1px solid var(--border);background:var(--canvas);color:var(--ink);flex-shrink:0}
 .mobile-picker>.cs-panel{position:static;display:block;max-height:55dvh;min-height:0;overflow-y:auto;overscroll-behavior:contain;border:0;box-shadow:none;padding:0;flex:1}
 .mobile-picker .cs-opt{border-radius:10px;margin-bottom:3px}.mobile-picker .cs-opt-active{background:var(--accent-tint)}
 .login-page{padding:24px!important;min-height:100dvh;box-sizing:border-box}
 .login-page .card{width:100%;max-width:420px;padding:28px 22px;border-radius:24px}
 .login-page .tab{min-height:48px;display:flex;align-items:center;justify-content:center}
 .login-page .btn{min-height:50px;font-size:16px}.login-page .forgot-link{padding:12px 0;min-height:44px;font-size:14px;box-sizing:border-box}
}
@media(max-width:360px){.pm-grid,.iv-grid{grid-template-columns:1fr}.pm-card .pimg,.iv-card .cimg{height:130px}}

.mobile-inventory-filter{display:contents}.mobile-inventory-filter>summary{display:none}
@media(max-width:768px){
 .mobile-inventory-filter{display:block;margin-bottom:14px;border:1px solid var(--border);border-radius:14px;background:var(--surface)}
 .mobile-inventory-filter>summary{display:flex;align-items:center;gap:12px;min-height:48px;padding:10px 14px;cursor:pointer;list-style:none;font-size:14px}
 .mobile-inventory-filter>summary::-webkit-details-marker{display:none}
 .mobile-inventory-filter>summary>span{margin-left:auto;font-size:13px;color:var(--accent-strong);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:45%}
 .mobile-inventory-filter>summary:after{content:'⌄';color:var(--ink-2)}
 .mobile-inventory-filter[open]>summary:after{content:'⌃'}
 .mobile-inventory-filter .iv-side{border:0;border-top:1px solid var(--border);border-radius:0 0 14px 14px;margin:0}
 .pm-grid:has(>.pm-card:only-child){grid-template-columns:1fr}
 .pm-card:only-child{display:grid;grid-template-columns:88px minmax(0,1fr);padding:12px;gap:4px 12px}
 .pm-card:only-child .pimg{grid-row:1/3;width:88px;height:100%;min-height:92px;border-radius:10px}
 .pm-card:only-child .pinfo{padding:0 0 4px}
 .pm-card:only-child .acts{grid-column:2;padding:0;border:0}
}
