/* Ordens de Serviço: a tabela original se transforma em cartões em telas pequenas.
   Reaproveita as mesmas células, filtros, ações, paginação e contadores em tempo real. */
@media (max-width:760px){
  .cadastro-card:has(.os-grid){overflow:visible!important}
  .cadastro-card:has(.os-grid) > .cadastro-toolbar{
    display:flex!important;flex-direction:column!important;align-items:stretch!important;
    flex-wrap:nowrap!important;gap:10px!important;padding:12px!important;
  }
  .cadastro-card:has(.os-grid) > .cadastro-toolbar .left.cadastro-filters{
    display:grid!important;grid-template-columns:repeat(2,minmax(0,1fr));
    align-items:stretch;gap:8px;width:100%!important;min-width:0!important;
  }
  .cadastro-card:has(.os-grid) #osBusca{
    grid-column:1/-1;min-width:0!important;max-width:none!important;width:100%!important;
  }
  .cadastro-card:has(.os-grid) #osPri,
  .cadastro-card:has(.os-grid) #osStatus{
    min-width:0!important;max-width:none!important;width:100%!important;
    font-size:12px!important;padding:10px 6px!important;
  }
  .cadastro-card:has(.os-grid) > .cadastro-toolbar .right{
    display:grid!important;grid-template-columns:repeat(2,minmax(0,1fr));
    gap:8px!important;width:100%!important;min-width:0!important;
  }
  .cadastro-card:has(.os-grid) > .cadastro-toolbar .right .btn{
    width:100%!important;min-width:0!important;
    padding:10px 7px!important;font-size:12px!important;
    white-space:normal!important;line-height:1.3!important;
  }
  .cadastro-card:has(.os-grid) > .cadastro-toolbar .right .btn:last-child{
    grid-column:1/-1;
  }

  .os-grid-wrap{
    overflow:visible!important;max-width:100%!important;
    padding:10px!important;background:#f7f9fc!important;
    border-top:1px solid #edf1f5!important;
  }
  .os-grid{
    display:block!important;width:100%!important;min-width:0!important;
    table-layout:auto!important;border-collapse:separate!important;
    font-size:12px!important;
  }
  .os-grid thead{display:none!important}
  .os-grid tbody{
    display:grid!important;grid-template-columns:minmax(0,1fr);gap:10px!important;
  }
  .os-grid tbody tr.os-placeholder{display:none!important}
  .os-grid tbody tr:not(.os-placeholder){
    display:grid!important;
    grid-template-columns:repeat(2,minmax(0,1fr));
    grid-template-areas:
      "codigo acoes"
      "escopo escopo"
      "prioridade status"
      "tecnico tecnico"
      "abertura conclusao"
      "prazoat prazocon"
      "controleat controlecon";
    gap:10px 12px!important;
    position:relative!important;z-index:1;
    width:100%!important;height:auto!important;min-height:0!important;
    margin:0!important;padding:13px!important;background:#fff!important;
    border:1px solid #e2e7ed!important;border-radius:12px!important;
    box-shadow:0 3px 12px rgba(17,37,57,.06)!important;
    overflow:visible!important;
  }
  .os-grid tbody tr:has(.os-actionmenu.open){z-index:25!important}
  .os-grid tbody tr:not(.os-placeholder)>td{
    display:flex!important;flex-direction:column;align-items:flex-start;
    gap:4px!important;align-self:start;
    width:auto!important;min-width:0!important;max-width:100%!important;
    height:auto!important;min-height:0!important;
    padding:0!important;margin:0!important;
    border:0!important;background:transparent!important;
    color:#182431!important;
    white-space:normal!important;text-align:left!important;
    font-size:12px!important;line-height:1.35!important;
    overflow-wrap:anywhere;
  }
  .os-grid tbody td:nth-child(1){grid-area:codigo;justify-content:center;font-size:12px!important}
  .os-grid tbody td:nth-child(2){
    grid-area:escopo;
    border-top:1px solid #e7ecf1!important;
    padding-top:9px!important;overflow:visible!important;
  }
  .os-grid tbody td:nth-child(3){grid-area:prioridade}
  .os-grid tbody td:nth-child(4){grid-area:abertura}
  .os-grid tbody td:nth-child(5){grid-area:prazoat}
  .os-grid tbody td:nth-child(6){grid-area:controleat}
  .os-grid tbody td:nth-child(7){grid-area:prazocon}
  .os-grid tbody td:nth-child(8){grid-area:controlecon}
  .os-grid tbody td:nth-child(9){grid-area:tecnico}
  .os-grid tbody td:nth-child(10){grid-area:conclusao}
  .os-grid tbody td:nth-child(11){grid-area:status}
  .os-grid tbody td:nth-child(12){
    grid-area:acoes;align-items:flex-end!important;
    justify-self:end;align-self:center!important;
    white-space:nowrap!important;overflow:visible!important;
  }
  .os-grid tbody td:nth-child(n+3):nth-child(-n+11)::before{
    display:block;font-size:9px;font-weight:800;
    line-height:1.15;letter-spacing:.05em;
    text-transform:uppercase;color:#687c8e;
  }
  .os-grid tbody td:nth-child(3)::before{content:"Prioridade"}
  .os-grid tbody td:nth-child(4)::before{content:"Abertura"}
  .os-grid tbody td:nth-child(5)::before{content:"Prazo atendimento"}
  .os-grid tbody td:nth-child(6)::before{content:"Controle atendimento"}
  .os-grid tbody td:nth-child(7)::before{content:"Prazo conclusão"}
  .os-grid tbody td:nth-child(8)::before{content:"Controle conclusão"}
  .os-grid tbody td:nth-child(9)::before{content:"Técnico responsável"}
  .os-grid tbody td:nth-child(10)::before{content:"Conclusão"}
  .os-grid tbody td:nth-child(11)::before{content:"Status"}
  .os-grid .os-fixed{white-space:normal!important;overflow-wrap:anywhere!important}
  .os-grid .os-fixed b{font-size:12px!important;color:#062d55!important;line-height:1.3}
  .os-grid .os-desc b{
    display:block!important;font-size:13px!important;line-height:1.3!important;
    white-space:normal!important;overflow:visible!important;
    text-overflow:clip!important;text-align:left!important;
  }
  .os-grid .os-desc span{
    display:block!important;max-height:none!important;
    -webkit-line-clamp:unset!important;
    overflow:visible!important;font-size:11px!important;
    line-height:1.4!important;text-align:left!important;overflow-wrap:anywhere;
  }
  .os-grid td:nth-child(3) .badge,
  .os-grid td:nth-child(11) .badge{
    font-size:10px!important;padding:5px 8px!important;line-height:1.25!important;
    max-width:100%!important;white-space:normal!important;
  }
  .os-grid td:nth-child(11) > div{align-items:flex-start!important}
  /* Nos cartões de celular, data e horário permanecem na mesma linha. */
  .os-grid .os-date-stack{
    display:grid!important;grid-template-columns:max-content max-content;
    justify-content:start!important;align-items:baseline!important;
    text-align:left!important;column-gap:6px!important;row-gap:2px!important;
    max-width:100%!important;
  }
  .os-grid .os-date-stack>b{font-size:11px!important;white-space:nowrap!important}
  .os-grid .os-date-stack>span{font-size:10px!important;white-space:nowrap!important}
  .os-grid .os-date-stack>small{
    grid-column:1/-1!important;display:block!important;
    font-size:10px!important;line-height:1.3!important;text-align:left!important;
  }
  .os-grid .os-date-stack .os-elapsed{font-size:10px!important;line-height:1.3!important}
  /* Mesma margem para os dois prazos: valores alinhados com seus títulos. */
  .os-grid tbody td:nth-child(5),
  .os-grid tbody td:nth-child(7){align-items:flex-start!important;justify-self:stretch!important}
  .os-grid .os-deadline{
    margin:0!important;padding:0!important;max-width:100%!important;
    width:100%!important;box-sizing:border-box!important;
  }
  .os-grid .os-deadline.late{
    outline:1px solid #f3bbbb;outline-offset:2px;
    border-color:transparent!important;
  }
  .os-grid .os-live{
    align-items:flex-start!important;text-align:left!important;
    padding:6px!important;min-height:42px!important;
    max-width:100%!important;line-height:1.2!important;
  }
  .os-grid .os-live b{font-size:9px!important}
  .os-grid .os-live small{font-size:10px!important;line-height:1.3!important}
  .os-grid .os-actionmenu>button{
    width:36px!important;height:34px!important;
    font-size:22px!important;color:#062d55!important;
    display:flex!important;align-items:center;justify-content:center;
  }
  .os-grid .os-actionmenu.open .menu{
    position:fixed!important;
    left:calc(72px + 12px)!important;right:12px!important;
    top:auto!important;bottom:calc(14px + env(safe-area-inset-bottom,0px))!important;
    min-width:0!important;width:auto!important;max-width:none!important;
    max-height:min(70vh,600px)!important;overflow-y:auto!important;
    z-index:200!important;
    padding:8px!important;border-radius:14px!important;
    box-shadow:0 14px 45px rgba(0,0,0,.26)!important;
    -webkit-overflow-scrolling:touch;
  }
  .os-grid .os-actionmenu .menu button{
    font-size:13px!important;line-height:1.3!important;
    padding:11px 10px!important;
  }
  .os-grid tbody tr:has(td.empty){
    display:block!important;padding:12px!important;
  }
  .os-grid tbody tr:has(td.empty) td.empty{
    display:block!important;text-align:center!important;
    padding:16px!important;font-size:12px!important;color:#6c7785!important;
  }
  .os-pager{
    display:flex!important;flex-direction:column!important;align-items:stretch!important;
    gap:12px!important;padding:13px 11px!important;font-size:11px!important;
  }
  .os-pager .os-pager-summary{
    display:flex!important;justify-content:space-between!important;align-items:center!important;
    flex-wrap:wrap!important;gap:8px!important;width:100%!important;
  }
  .os-pager .os-page-size{
    display:inline-flex!important;align-items:center!important;gap:5px!important;
    font-size:11px!important;white-space:nowrap!important;
  }
  .os-pager .os-page-size select{
    width:61px!important;min-width:61px!important;
    padding:6px 18px 6px 7px!important;font-size:12px!important;
  }
  .os-pager .os-pager-controls{
    display:flex!important;flex-direction:column!important;align-items:center!important;
    gap:7px!important;width:100%!important;min-width:0!important;
  }
  .os-pager .os-pager-nav{
    display:flex!important;justify-content:center!important;align-items:center!important;
    flex-wrap:nowrap!important;gap:4px!important;width:100%!important;
  }
  .os-pager .os-page-buttons{display:flex!important;gap:4px!important;min-width:0!important}
  .os-pager .os-pager-nav .btn{
    min-width:30px!important;min-height:34px!important;padding:6px!important;
    font-size:12px!important;
  }
  .os-pager #osPg{white-space:nowrap!important;text-align:center!important;font-size:11px!important}
}

/* Ambiente completo no cartão, inclusive nomes extensos. */
@media(max-width:760px){
 .os-grid tbody td.os-desc>div[title]{
  display:block!important;width:100%!important;max-width:100%!important;min-width:0!important;
  box-sizing:border-box;white-space:normal!important;overflow:visible!important;
  text-overflow:clip!important;overflow-wrap:anywhere!important;word-break:normal!important;
  height:auto!important;max-height:none!important;-webkit-line-clamp:unset!important;line-height:1.4!important;
 }
}
