/* Mobile layer: bottom tab bar, drawer, bottom-sheet bill, card-style tables, touch-friendly forms. Loaded after ui.css. */
.tabbar,.scrim{display:none}
.drawer{display:contents}
.grid2{display:grid;grid-template-columns:1fr 1fr;gap:8px;margin-top:10px}
details.gstin{margin:8px 0}details.gstin summary{cursor:pointer;color:var(--acc);font-size:13px}details.gstin input{width:100%;margin-top:6px}

@media (max-width:860px){
  body{-webkit-text-size-adjust:100%;padding-bottom:calc(58px + env(safe-area-inset-bottom))}
  main{padding:14px 14px 24px}
  h1{font-size:20px}

  /* header: brand only. Navigation lives in the bottom bar + drawer */
  .top{padding:8px 14px;gap:10px;padding-top:calc(8px + env(safe-area-inset-top))}
  .top .brand small{display:none}
  .menu{display:none!important}

  /* bottom tab bar */
  .tabbar{display:grid;grid-template-columns:repeat(5,1fr);position:fixed;left:0;right:0;bottom:0;z-index:30;background:var(--bg);border-top:1px solid var(--line);padding-bottom:env(safe-area-inset-bottom)}
  .tabbar a,.tabbar button{display:flex;flex-direction:column;align-items:center;gap:2px;padding:7px 0 6px;font:inherit;font-size:11px;color:var(--muted);background:none;border:0;cursor:pointer;min-height:56px;justify-content:center}
  .tabbar svg{width:22px;height:22px;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}
  .tabbar a.on,.tabbar button.on{color:var(--acc)}

  /* drawer = bottom sheet with all links, branch switch and logout */
  .scrim{display:block;position:fixed;inset:0;background:rgba(0,0,0,.4);z-index:35;opacity:0;pointer-events:none;transition:opacity .2s}
  .scrim.on{opacity:1;pointer-events:auto}
  .drawer{display:block;position:fixed;left:0;right:0;bottom:0;z-index:40;background:var(--bg);border-radius:16px 16px 0 0;padding:16px 14px calc(16px + env(safe-area-inset-bottom));box-shadow:0 -10px 30px rgba(0,0,0,.25);transform:translateY(105%);transition:transform .25s;max-height:80vh;overflow:auto}
  .top.open .drawer{transform:none}
  .drawer nav{display:grid!important;grid-template-columns:1fr 1fr;gap:8px;width:auto;order:0}
  .drawer nav a{padding:13px 10px;border:1px solid var(--line);border-radius:10px;text-align:center}
  .drawer nav a.on{border-color:var(--acc);color:var(--acc)}
  .drawer .who{display:flex!important;flex-wrap:wrap;gap:10px;align-items:center;justify-content:space-between;margin-top:14px;width:auto}
  .drawer .who select{flex:1;min-width:140px}

  /* touch-friendly controls (16px stops iOS zooming on focus) */
  input:not([type=checkbox]):not([type=radio]),select,textarea{font-size:16px;min-height:44px}
  .btn{min-height:44px;display:inline-flex;align-items:center;justify-content:center}
  .qty{width:72px}
  .grid{grid-template-columns:1fr}
  .bar{align-items:stretch}.bar>*{max-width:100%}
  .bar form{display:flex;flex-wrap:wrap;gap:8px;width:100%}.bar form input,.bar form select,.bar form label{flex:1 1 140px}
  .filters{align-items:stretch!important}
  .tiles{grid-template-columns:1fr 1fr;gap:10px}.tile{padding:12px}.tile b{font-size:20px}
  .tabs{overflow-x:auto;white-space:nowrap;padding-bottom:4px}
  .tfilter{width:100%}
  .login{margin:6vh auto}
  .actions{flex-wrap:wrap}
  .foot{padding:14px}
  #toasts{left:10px;right:10px;max-width:none;top:calc(10px + env(safe-area-inset-top))}
  dialog.modal{width:100%;max-width:none;margin:auto 0 0;border-radius:16px 16px 0 0;padding-bottom:calc(20px + env(safe-area-inset-bottom))}

  /* wide tables become stacked cards (mobile.js adds .cards and the data-labels) */
  table.cards{display:block}
  table.cards thead{display:none}
  table.cards tbody{display:block}
  table.cards tr{display:block;border:1px solid var(--line);border-radius:12px;padding:6px 12px;margin-bottom:10px;background:var(--bg)}
  table.cards td{display:flex;justify-content:space-between;align-items:center;gap:14px;border:0;border-bottom:1px solid var(--line);padding:7px 0;text-align:right}
  table.cards td:last-child{border-bottom:0}
  table.cards td::before{content:attr(data-label);color:var(--muted);font-size:12px;text-align:left;flex:none}
  table.cards td:not([data-label])::before{content:none}
  table.cards td:first-child{font-weight:600}
  table.cards td input,table.cards td select{max-width:58%}
  table.cards tr:hover td{background:none}
  td.empty{display:block!important;text-align:center!important}

  /* POS: search results as cards */
  #results,#results tbody{display:block}
  #results tr{display:flex;flex-wrap:wrap;align-items:center;gap:2px 12px;border:1px solid var(--line);border-radius:12px;padding:10px 12px;margin-bottom:8px}
  #results td{display:block;border:0;padding:0;font-size:13px}
  #results td:first-child{flex:1 1 100%}
  #results td:last-child{margin-left:auto}
  #results .btn{min-width:72px}

  /* POS: the bill is a bottom sheet above the tab bar */
  .pos{display:block;padding-bottom:140px}
  .pos aside{position:fixed;left:0;right:0;bottom:calc(58px + env(safe-area-inset-bottom));z-index:25;border-radius:16px 16px 0 0;border-bottom:0;padding:0 14px;max-height:56px;overflow:hidden;transition:max-height .25s;box-shadow:0 -6px 20px rgba(0,0,0,.18)}
  .pos aside.open{max-height:78vh;overflow:auto;padding-bottom:14px}
  .pos aside h2{display:none}
  .sheet-bar{display:flex;justify-content:space-between;align-items:center;width:100%;min-height:56px;border:0;color:var(--fg);font:inherit;font-weight:600;cursor:pointer;position:sticky;top:0;background:var(--bg);z-index:1}
  .sheet-bar .tot{color:var(--acc)}
  .upibox img{width:112px;height:112px}
  .invoice{border-radius:0;border-left:0;border-right:0;margin:0 -14px;max-width:none}
  .inv-meta{grid-template-columns:1fr 1fr}
}
@media (min-width:861px){.sheet-bar{display:none}}
