/* SAM v1.3.10 — Bill / PO mobile layout authority.
   Presentation only. No accounting, totals, stock, payment or document business logic. */

@media screen and (max-width:760px){
  /* Keep the Client/Supplier create workspace inside the viewport. */
  body.brv-ui-frontend .ipl-front-app.ipl-active-clients #tab-new-invoice,
  body.brv-ui-frontend .ipl-front-app.ipl-active-suppliers #tab-new-po{
    width:100%!important;
    max-width:100%!important;
    min-width:0!important;
    overflow:visible!important;
  }
  body.brv-ui-frontend .ipl-front-app.ipl-active-clients #tab-new-invoice .ipl-form-box,
  body.brv-ui-frontend .ipl-front-app.ipl-active-suppliers #tab-new-po .ipl-form-box{
    width:100%!important;
    max-width:100%!important;
    min-width:0!important;
    overflow:visible!important;
    padding:12px!important;
    margin-left:0!important;
    margin-right:0!important;
  }
  body.brv-ui-frontend .ipl-front-app.ipl-active-clients #tab-new-invoice .ipl-create-grid-3,
  body.brv-ui-frontend .ipl-front-app.ipl-active-clients #tab-new-invoice .ipl-financial-form > div[style*="display:grid"],
  body.brv-ui-frontend .ipl-front-app.ipl-active-suppliers #tab-new-po .ipl-form-box > div[style*="display:grid"],
  body.brv-ui-frontend .ipl-front-app.ipl-active-suppliers #tab-new-po .ipl-financial-form > div[style*="display:grid"]{
    grid-template-columns:1fr!important;
    width:100%!important;
    min-width:0!important;
    gap:10px!important;
  }

  /* Financial item/expense tables become readable field cards; never a clipped desktop table. */
  body.brv-ui-frontend .ipl-front-app.ipl-active-clients #tab-new-invoice .ipl-items-tbl,
  body.brv-ui-frontend .ipl-front-app.ipl-active-suppliers #tab-new-po .ipl-items-tbl,
  body.brv-ui-frontend .ipl-front-app.ipl-active-clients #tab-new-invoice .ipl-items-tbl thead,
  body.brv-ui-frontend .ipl-front-app.ipl-active-suppliers #tab-new-po .ipl-items-tbl thead,
  body.brv-ui-frontend .ipl-front-app.ipl-active-clients #tab-new-invoice .ipl-items-tbl tbody,
  body.brv-ui-frontend .ipl-front-app.ipl-active-suppliers #tab-new-po .ipl-items-tbl tbody,
  body.brv-ui-frontend .ipl-front-app.ipl-active-clients #tab-new-invoice .ipl-items-tbl tr,
  body.brv-ui-frontend .ipl-front-app.ipl-active-suppliers #tab-new-po .ipl-items-tbl tr,
  body.brv-ui-frontend .ipl-front-app.ipl-active-clients #tab-new-invoice .ipl-items-tbl th,
  body.brv-ui-frontend .ipl-front-app.ipl-active-suppliers #tab-new-po .ipl-items-tbl th,
  body.brv-ui-frontend .ipl-front-app.ipl-active-clients #tab-new-invoice .ipl-items-tbl td,
  body.brv-ui-frontend .ipl-front-app.ipl-active-suppliers #tab-new-po .ipl-items-tbl td{
    display:block!important;
    width:100%!important;
    min-width:0!important;
    max-width:100%!important;
    white-space:normal!important;
    box-sizing:border-box!important;
  }
  body.brv-ui-frontend .ipl-front-app.ipl-active-clients #tab-new-invoice .ipl-items-tbl,
  body.brv-ui-frontend .ipl-front-app.ipl-active-suppliers #tab-new-po .ipl-items-tbl{
    min-width:0!important;
    table-layout:auto!important;
    overflow:visible!important;
    border:0!important;
    margin:0 0 12px!important;
  }
  body.brv-ui-frontend .ipl-front-app.ipl-active-clients #tab-new-invoice .ipl-items-tbl thead,
  body.brv-ui-frontend .ipl-front-app.ipl-active-suppliers #tab-new-po .ipl-items-tbl thead{display:none!important;}
  body.brv-ui-frontend .ipl-front-app.ipl-active-clients #tab-new-invoice .ipl-items-tbl tr,
  body.brv-ui-frontend .ipl-front-app.ipl-active-suppliers #tab-new-po .ipl-items-tbl tr{
    background:var(--panel,#fff)!important;
    border:1px solid var(--input-border,#d9dee8)!important;
    border-radius:12px!important;
    padding:10px!important;
    margin:0 0 11px!important;
    box-shadow:0 4px 14px rgba(15,23,42,.05)!important;
  }
  body.brv-ui-frontend .ipl-front-app.ipl-active-clients #tab-new-invoice .ipl-items-tbl td,
  body.brv-ui-frontend .ipl-front-app.ipl-active-suppliers #tab-new-po .ipl-items-tbl td{
    border:0!important;
    border-bottom:1px dashed rgba(100,116,139,.20)!important;
    padding:7px 0!important;
    text-align:left!important;
    display:grid!important;
    grid-template-columns:104px minmax(0,1fr)!important;
    gap:9px!important;
    align-items:center!important;
  }
  body.brv-ui-frontend .ipl-front-app.ipl-active-clients #tab-new-invoice .ipl-items-tbl td:last-child,
  body.brv-ui-frontend .ipl-front-app.ipl-active-suppliers #tab-new-po .ipl-items-tbl td:last-child{border-bottom:0!important;}
  body.brv-ui-frontend .ipl-front-app.ipl-active-clients #tab-new-invoice .ipl-items-tbl td::before,
  body.brv-ui-frontend .ipl-front-app.ipl-active-suppliers #tab-new-po .ipl-items-tbl td::before{
    font-weight:900!important;
    font-size:10px!important;
    line-height:1.2!important;
    color:var(--muted,#64748b)!important;
    text-transform:uppercase!important;
    letter-spacing:.02em!important;
  }

  /* Bill has 7 columns: Product, Challan, Type/Unit, Qty/Weight, Rate, Amount, Action. */
  body.brv-ui-frontend .ipl-front-app.ipl-active-clients #tab-new-invoice .ipl-bill-items-tbl td:nth-child(1)::before{content:'Product'!important;}
  body.brv-ui-frontend .ipl-front-app.ipl-active-clients #tab-new-invoice .ipl-bill-items-tbl td:nth-child(2)::before{content:'Challan'!important;}
  body.brv-ui-frontend .ipl-front-app.ipl-active-clients #tab-new-invoice .ipl-bill-items-tbl td:nth-child(3)::before{content:'Type / Unit'!important;}
  body.brv-ui-frontend .ipl-front-app.ipl-active-clients #tab-new-invoice .ipl-bill-items-tbl td:nth-child(4)::before{content:'Qty / Weight'!important;}
  body.brv-ui-frontend .ipl-front-app.ipl-active-clients #tab-new-invoice .ipl-bill-items-tbl td:nth-child(5)::before{content:'Rate'!important;}
  body.brv-ui-frontend .ipl-front-app.ipl-active-clients #tab-new-invoice .ipl-bill-items-tbl td:nth-child(6)::before{content:'Amount'!important;}
  body.brv-ui-frontend .ipl-front-app.ipl-active-clients #tab-new-invoice .ipl-bill-items-tbl td:nth-child(7)::before{content:'Action'!important;}

  /* PO has 6 columns. */
  body.brv-ui-frontend .ipl-front-app.ipl-active-suppliers #tab-new-po .ipl-po-items-tbl td:nth-child(1)::before{content:'Product'!important;}
  body.brv-ui-frontend .ipl-front-app.ipl-active-suppliers #tab-new-po .ipl-po-items-tbl td:nth-child(2)::before{content:'Type / Unit'!important;}
  body.brv-ui-frontend .ipl-front-app.ipl-active-suppliers #tab-new-po .ipl-po-items-tbl td:nth-child(3)::before{content:'Qty / Weight'!important;}
  body.brv-ui-frontend .ipl-front-app.ipl-active-suppliers #tab-new-po .ipl-po-items-tbl td:nth-child(4)::before{content:'Purchase Rate'!important;}
  body.brv-ui-frontend .ipl-front-app.ipl-active-suppliers #tab-new-po .ipl-po-items-tbl td:nth-child(5)::before{content:'Amount'!important;}
  body.brv-ui-frontend .ipl-front-app.ipl-active-suppliers #tab-new-po .ipl-po-items-tbl td:nth-child(6)::before{content:'Action'!important;}

  /* Bill expense table has 4 columns. */
  body.brv-ui-frontend .ipl-front-app.ipl-active-clients #tab-new-invoice .ipl-expenses-tbl td:nth-child(1)::before{content:'Category'!important;}
  body.brv-ui-frontend .ipl-front-app.ipl-active-clients #tab-new-invoice .ipl-expenses-tbl td:nth-child(2)::before{content:'Amount'!important;}
  body.brv-ui-frontend .ipl-front-app.ipl-active-clients #tab-new-invoice .ipl-expenses-tbl td:nth-child(3)::before{content:'Description'!important;}
  body.brv-ui-frontend .ipl-front-app.ipl-active-clients #tab-new-invoice .ipl-expenses-tbl td:nth-child(4)::before{content:'Action'!important;}

  /* PO expense table has 5 columns, including Treatment. */
  body.brv-ui-frontend .ipl-front-app.ipl-active-suppliers #tab-new-po .ipl-expenses-tbl td:nth-child(1)::before{content:'Category'!important;}
  body.brv-ui-frontend .ipl-front-app.ipl-active-suppliers #tab-new-po .ipl-expenses-tbl td:nth-child(2)::before{content:'Amount'!important;}
  body.brv-ui-frontend .ipl-front-app.ipl-active-suppliers #tab-new-po .ipl-expenses-tbl td:nth-child(3)::before{content:'Treatment'!important;}
  body.brv-ui-frontend .ipl-front-app.ipl-active-suppliers #tab-new-po .ipl-expenses-tbl td:nth-child(4)::before{content:'Description'!important;}
  body.brv-ui-frontend .ipl-front-app.ipl-active-suppliers #tab-new-po .ipl-expenses-tbl td:nth-child(5)::before{content:'Action'!important;}

  body.brv-ui-frontend .ipl-front-app.ipl-active-clients #tab-new-invoice .ipl-items-tbl input,
  body.brv-ui-frontend .ipl-front-app.ipl-active-clients #tab-new-invoice .ipl-items-tbl select,
  body.brv-ui-frontend .ipl-front-app.ipl-active-suppliers #tab-new-po .ipl-items-tbl input,
  body.brv-ui-frontend .ipl-front-app.ipl-active-suppliers #tab-new-po .ipl-items-tbl select{
    width:100%!important;
    max-width:100%!important;
    min-width:0!important;
    min-height:40px!important;
    height:auto!important;
    margin:0!important;
    font-size:13px!important;
    grid-column:2!important;
  }
  body.brv-ui-frontend .ipl-front-app.ipl-active-clients #tab-new-invoice .ipl-items-tbl input[id^="product_name_"],
  body.brv-ui-frontend .ipl-front-app.ipl-active-suppliers #tab-new-po .ipl-items-tbl input[id^="product_name_"]{margin-top:6px!important;}
  body.brv-ui-frontend .ipl-front-app.ipl-active-clients #tab-new-invoice .ipl-items-tbl .item-total,
  body.brv-ui-frontend .ipl-front-app.ipl-active-suppliers #tab-new-po .ipl-items-tbl .item-total{
    grid-column:2!important;
    display:block!important;
    min-height:22px!important;
    line-height:22px!important;
    text-align:left!important;
    font-size:14px!important;
    font-weight:900!important;
  }
  body.brv-ui-frontend .ipl-front-app.ipl-active-clients #tab-new-invoice .ipl-items-tbl .remove-btn,
  body.brv-ui-frontend .ipl-front-app.ipl-active-suppliers #tab-new-po .ipl-items-tbl .remove-btn{
    grid-column:2!important;
    justify-self:start!important;
    width:42px!important;
    max-width:42px!important;
    min-width:42px!important;
    height:36px!important;
    min-height:36px!important;
    padding:0!important;
    border-radius:9px!important;
  }

  /* Totals stay two-sided without pushing the viewport. */
  body.brv-ui-frontend .ipl-front-app.ipl-active-clients #tab-new-invoice .ipl-total-row,
  body.brv-ui-frontend .ipl-front-app.ipl-active-suppliers #tab-new-po .ipl-total-row{
    display:grid!important;
    grid-template-columns:minmax(0,1fr) auto!important;
    align-items:center!important;
    gap:10px!important;
    width:100%!important;
  }
  body.brv-ui-frontend .ipl-front-app.ipl-active-clients #tab-new-invoice .ipl-total-row > span:first-child,
  body.brv-ui-frontend .ipl-front-app.ipl-active-suppliers #tab-new-po .ipl-total-row > span:first-child{min-width:0!important;white-space:normal!important;}
  body.brv-ui-frontend .ipl-front-app.ipl-active-clients #tab-new-invoice .ipl-total-row > span:last-child,
  body.brv-ui-frontend .ipl-front-app.ipl-active-suppliers #tab-new-po .ipl-total-row > span:last-child{white-space:nowrap!important;text-align:right!important;}

  /* Document cards/list actions. */
  body.brv-ui-frontend .ipl-front-app.ipl-active-clients .invoice-card-header,
  body.brv-ui-frontend .ipl-front-app.ipl-active-suppliers .invoice-card-header{display:block!important;padding-right:42px!important;}
  body.brv-ui-frontend .ipl-front-app.ipl-active-clients .invoice-card-header .inv-date,
  body.brv-ui-frontend .ipl-front-app.ipl-active-suppliers .invoice-card-header .inv-date{display:block!important;margin-top:4px!important;white-space:normal!important;}
  body.brv-ui-frontend .ipl-front-app.ipl-active-clients .invoice-card-footer,
  body.brv-ui-frontend .ipl-front-app.ipl-active-suppliers .invoice-card-footer{display:block!important;}
  body.brv-ui-frontend .ipl-front-app.ipl-active-clients .invoice-card-amounts,
  body.brv-ui-frontend .ipl-front-app.ipl-active-suppliers .invoice-card-amounts{display:grid!important;grid-template-columns:repeat(2,minmax(0,1fr))!important;width:100%!important;gap:8px!important;margin-top:9px!important;}
  body.brv-ui-frontend .ipl-front-app.ipl-active-clients .invoice-card-actions,
  body.brv-ui-frontend .ipl-front-app.ipl-active-suppliers .po-card-actions{display:grid!important;grid-template-columns:repeat(2,minmax(0,1fr))!important;gap:7px!important;width:100%!important;}
  body.brv-ui-frontend .ipl-front-app.ipl-active-clients .invoice-card-actions a,
  body.brv-ui-frontend .ipl-front-app.ipl-active-clients .invoice-card-actions button,
  body.brv-ui-frontend .ipl-front-app.ipl-active-suppliers .po-card-actions a,
  body.brv-ui-frontend .ipl-front-app.ipl-active-suppliers .po-card-actions button{width:100%!important;max-width:none!important;}

  /* Standalone Bills and Individual Bill also remain usable on phones. */
  body.brv-ui-frontend .ipl-front-app.ipl-active-invoices .ipl-doc-head{display:grid!important;grid-template-columns:1fr!important;align-items:stretch!important;}
  body.brv-ui-frontend .ipl-front-app.ipl-active-invoices .ipl-doc-head > div{display:grid!important;grid-template-columns:1fr 1fr!important;gap:7px!important;}
  body.brv-ui-frontend .ipl-front-app.ipl-active-invoices .ipl-doc-head .button{width:100%!important;margin:0!important;}
  body.brv-ui-frontend .ipl-front-app.ipl-active-invoices .ipl-doc-select{display:grid!important;grid-template-columns:1fr!important;align-items:stretch!important;}
  body.brv-ui-frontend .ipl-front-app.ipl-active-invoices .ipl-doc-table-wrap{width:100%!important;max-width:100%!important;overflow-x:auto!important;-webkit-overflow-scrolling:touch!important;}
  body.brv-ui-frontend .ipl-front-app.ipl-active-invoices .ipl-individual-bill{padding:10px!important;max-width:100%!important;}
  body.brv-ui-frontend .ipl-front-app.ipl-active-invoices .ipl-bill-detail-head{display:grid!important;grid-template-columns:1fr!important;}
  body.brv-ui-frontend .ipl-front-app.ipl-active-invoices .ipl-bill-detail-actions{display:grid!important;grid-template-columns:repeat(2,minmax(0,1fr))!important;width:100%!important;}
  body.brv-ui-frontend .ipl-front-app.ipl-active-invoices .ipl-bill-detail-actions .button{width:100%!important;}
  body.brv-ui-frontend .ipl-front-app.ipl-active-invoices .ipl-bill-summary{grid-template-columns:repeat(2,minmax(0,1fr))!important;gap:8px!important;}
  body.brv-ui-frontend .ipl-front-app.ipl-active-invoices .ipl-bill-pay-grid{grid-template-columns:1fr!important;}
  body.brv-ui-frontend .ipl-front-app.ipl-active-invoices .ipl-bill-panel{min-width:0!important;overflow-x:auto!important;}
}

@media screen and (max-width:480px){
  body.brv-ui-frontend .ipl-front-app.ipl-active-clients #tab-new-invoice .ipl-items-tbl td,
  body.brv-ui-frontend .ipl-front-app.ipl-active-suppliers #tab-new-po .ipl-items-tbl td{grid-template-columns:88px minmax(0,1fr)!important;gap:8px!important;}
  body.brv-ui-frontend .ipl-front-app.ipl-active-clients .invoice-card-amounts,
  body.brv-ui-frontend .ipl-front-app.ipl-active-suppliers .invoice-card-amounts{grid-template-columns:1fr 1fr!important;}
  body.brv-ui-frontend .ipl-front-app.ipl-active-clients .invoice-card-actions,
  body.brv-ui-frontend .ipl-front-app.ipl-active-suppliers .po-card-actions,
  body.brv-ui-frontend .ipl-front-app.ipl-active-invoices .ipl-doc-head > div,
  body.brv-ui-frontend .ipl-front-app.ipl-active-invoices .ipl-bill-detail-actions{grid-template-columns:1fr!important;}
  body.brv-ui-frontend .ipl-front-app.ipl-active-clients #tab-new-invoice .ipl-financial-form > div:last-child,
  body.brv-ui-frontend .ipl-front-app.ipl-active-suppliers #tab-new-po .ipl-financial-form > div:last-child{display:grid!important;grid-template-columns:1fr!important;gap:8px!important;}
  body.brv-ui-frontend .ipl-front-app.ipl-active-clients #tab-new-invoice .ipl-financial-form > div:last-child .button,
  body.brv-ui-frontend .ipl-front-app.ipl-active-suppliers #tab-new-po .ipl-financial-form > div:last-child .button{width:100%!important;max-width:none!important;margin:0!important;}
  body.brv-ui-frontend .ipl-front-app.ipl-active-invoices .ipl-bill-summary{grid-template-columns:1fr!important;}
}
