/* Agri CareTrade CRM - phone layout (v9.3)
   Loaded last. Everything here is inside a phone-width media query except the
   small Show Capture toolbar fix at the top, so the desktop layout is unchanged. */

/* Show Capture list toolbar: style the plain controls (all screen sizes) */
.be-actions input[data-search],.be-actions select,.be-actions button:not(.btn){
  min-height:40px;padding:8px 12px;border:1px solid #d3dfd1;border-radius:8px;background:#fff;color:#233d35;font:inherit;font-size:14px}
.be-actions button:not(.btn){font-weight:700;cursor:pointer}
.be-actions button:not(.btn):hover{background:#f2f6ef}
.be-actions input[data-search]{min-width:240px;flex:1 1 240px}
.m-menu-btn,.m-backdrop{display:none}

@media (max-width:760px){
  /* ---------- page ---------- */
  html body{padding-bottom:calc(84px + env(safe-area-inset-bottom))!important;overflow-x:hidden}
  html body .main{margin-left:0!important;width:100%!important;padding:0 12px 24px!important}
  input:not([type=checkbox]):not([type=radio]),select,textarea{font-size:16px!important}  /* stops iPhone zooming in */

  /* ---------- slide-out menu (replaces the squashed bottom bar) ---------- */
  html body .sidebar{position:fixed!important;inset:0 auto 0 0!important;width:min(86vw,320px)!important;height:100%!important;
    padding:calc(16px + env(safe-area-inset-top)) 14px calc(16px + env(safe-area-inset-bottom))!important;
    display:flex!important;flex-direction:column!important;gap:0!important;overflow-y:auto!important;overflow-x:hidden!important;
    transform:translateX(-105%);transition:transform .22s ease;z-index:1300!important;box-shadow:none!important;
    background:linear-gradient(180deg,var(--navy,#0b2d5c) 0%,#062b59 100%)}
  html body.m-nav-open .sidebar{transform:none;box-shadow:12px 0 40px rgba(0,0,0,.35)!important}
  html body .sidebar .brand{display:block!important;margin-bottom:16px!important;padding:10px!important}
  html body .sidebar .brand img{width:100%!important;max-width:220px}
  html body .sidebar .sidebar-bottom,html body .sidebar .nav-section-label{display:block!important}
  html body .sidebar nav{overflow:visible!important;width:auto!important;height:auto!important}
  html body .sidebar .hub-nav.active{width:auto!important}
  html body .sidebar #businessHubMenu{flex:none!important;overflow:visible!important}
  html body .sidebar #businessHubMenu button{min-height:44px;font-size:15px!important;text-align:left}
  html body .sidebar .business-hub-switcher{margin:0 0 12px!important}
  html body .sidebar .hub-tab{padding:9px 4px!important;font-size:11px!important}
  html body .sidebar .nav-item{width:100%!important;min-width:0!important;height:auto!important;min-height:46px;padding:11px 12px!important;
    flex-direction:row!important;justify-content:flex-start!important;align-items:center!important;gap:11px!important;
    font-size:15px!important;text-align:left!important;border-radius:10px!important}
  html body .sidebar .nav-item span{font-size:17px!important;width:22px!important}
  html body .sidebar .nav-item *{display:initial!important}
  html body .sidebar .user-card div:not(.avatar){display:block!important}
  html body .sidebar .sidebar-bottom{margin-top:18px!important}
  .m-backdrop{position:fixed;inset:0;background:rgba(3,24,49,.5);z-index:1250}
  body.m-nav-open .m-backdrop{display:block}
  body.m-nav-open{overflow:hidden}

  /* ---------- top bar ---------- */
  .m-menu-btn{display:inline-flex;align-items:center;justify-content:center;gap:6px;flex:none;min-width:44px;height:40px;padding:0 12px;
    border:0;border-radius:10px;background:#0b2d5c;color:#fff;font:700 14px Arial,sans-serif;cursor:pointer}
  .m-menu-btn:focus-visible{outline:3px solid #3AA142;outline-offset:2px}
  html body .pc47-utility{gap:8px!important;padding:8px 12px!important;left:0!important;right:0!important;width:100%!important;margin:0!important;box-sizing:border-box}
  html body .pc47-utility .pc47-date,html body .pc47-util-right>div:not(.pc47-avatar):not(.pc47-bell){display:none!important}
  html body .pc47-search{flex:1 1 auto!important;min-width:0!important;width:auto!important;max-width:none!important}
  html body .pc47-util-right{gap:8px!important;flex:none}
  html body .topbar{display:block!important;padding:12px 0 10px!important;position:static!important}
  html body .topbar h1{font-size:22px!important;line-height:1.2}
  html body .top-actions{display:flex!important;flex-wrap:nowrap!important;justify-content:flex-start!important;gap:6px!important;
    overflow-x:auto;-webkit-overflow-scrolling:touch;margin-top:8px;padding-bottom:4px;scrollbar-width:none}
  html body .top-actions::-webkit-scrollbar{display:none}
  html body .top-actions .btn{flex:none;white-space:nowrap;padding:9px 12px!important;font-size:13px!important;min-height:38px}
  html body .top-actions .btn-primary{display:inline-flex!important}

  /* ---------- rows of tabs / buttons that don't fit: swipe sideways ---------- */
  .m-scrollrow{flex-wrap:nowrap!important;overflow-x:auto!important;-webkit-overflow-scrolling:touch;scrollbar-width:none;justify-content:flex-start!important}
  .m-scrollrow::-webkit-scrollbar{display:none}
  .m-scrollrow>*{flex:none!important;white-space:nowrap}

  /* ---------- tables ---------- */
  .m-tablescroll{overflow-x:auto;-webkit-overflow-scrolling:touch;max-width:100%}
  table.m-cards{display:block!important;width:100%!important;min-width:0!important;border:0!important;background:transparent!important}
  table.m-cards thead{display:none!important}
  table.m-cards tbody,table.m-cards tfoot{display:block!important;width:100%!important}
  table.m-cards tr{display:block!important;background:#fff;border:1px solid #dde6ef!important;border-radius:12px;margin:0 0 10px;padding:8px 12px;box-shadow:0 2px 8px rgba(11,45,92,.05)}
  table.m-cards td{display:flex!important;justify-content:space-between;align-items:flex-start;gap:12px;width:auto!important;min-width:0!important;max-width:none!important;
    padding:6px 0!important;border:0!important;border-top:1px solid #eef2f6!important;text-align:right!important;white-space:normal!important;position:static!important;overflow-wrap:anywhere}
  table.m-cards td:first-child{border-top:0!important}
  table.m-cards td::before{content:attr(data-label);flex:0 0 38%;text-align:left;font-size:12px;font-weight:700;color:#5b6b7d;text-transform:none;letter-spacing:0}
  table.m-cards td[data-label=""]::before{display:none}
  table.m-cards td.m-title{display:block!important;text-align:left!important;font-size:16px;font-weight:700;padding-top:4px!important}
  table.m-cards td.m-title::before{display:none}
  table.m-cards td.m-empty{display:block!important;text-align:center!important}
  table.m-cards td.m-empty::before{display:none}
  table.m-cards td>*{max-width:100%}
  table.m-cards td .btn,table.m-cards td button{white-space:nowrap}

  /* ---------- task list: wrap instead of squeezing (and show the buttons) ---------- */
  html body .task-row{display:flex!important;flex-wrap:wrap!important;align-items:center;gap:6px 8px!important;grid-template-columns:none!important;padding:12px!important}
  html body .task-row>*{display:inline-flex!important;width:auto!important;min-width:0!important;max-width:100%}
  html body .task-row>input[type=checkbox]{flex:none;width:22px!important;height:22px}
  html body .task-row .task-title{display:block!important;flex:1 1 calc(100% - 40px)!important}
  html body .task-row .task-title small{display:block}
  html body .task-row>span{font-size:12px}
  html body .task-row .small-btn{min-height:36px;padding:6px 10px}

  /* ---------- pop-up forms: full screen ---------- */
  html body .modal-backdrop{padding:0!important;align-items:stretch!important}
  html body .modal{width:100%!important;max-width:100%!important;max-height:100%!important;height:100%!important;border-radius:0!important}
  html body .modal-head{position:sticky;top:0;background:#fff;z-index:2;padding:14px 16px!important}
  html body .form-grid,html body .be-grid{grid-template-columns:1fr!important}
  html body .field.full,html body .be-wide{grid-column:auto!important}

  /* ---------- Show Capture ---------- */
  .be-card{padding:14px!important}
  .be-actions input[data-search],.be-actions select{flex:1 1 100%!important;min-width:0!important;width:100%}
  .be-actions button:not(.btn){flex:1 1 auto}

  /* ---------- Business Home button: keep clear of content ---------- */
  html body #businessHubHomeButton{bottom:calc(12px + env(safe-area-inset-bottom))!important;right:12px!important;padding:11px 15px!important;font-size:14px!important}

  /* hide the floating Business Home button while a form or the menu is open */
  body:has(.modal-backdrop.open) #businessHubHomeButton,body.m-nav-open #businessHubHomeButton{display:none!important}
  html body .modal-backdrop.open{z-index:1400!important}

  /* buttons and links easy to tap */
  html body .main .btn{min-height:40px}
}
