/* === Frota Mineração: adaptação REAL para notebooks, tablets e celulares ===
   Desktop largo usa tabelas. Até 1600px os registros viram cartões compactos,
   sem remover inputs, funções, histórico, filtros ou botões. */
@media (max-width:1600px){
  .content{padding:clamp(12px,1.7vw,24px)!important;max-width:none}
  .section{min-width:0}
  .section .table-head{gap:10px;padding:13px 16px;flex-wrap:wrap}
  .section .table-head>h2{font-size:14px}
  .section .table-head .table-tools{align-items:center;gap:7px;flex-wrap:wrap;min-width:0}
  .section .table-head .table-tools>*{max-width:100%;min-width:0}
  .section .table-card{min-width:0}
  .section .row-actions{display:flex;flex-wrap:wrap;gap:6px;min-width:0!important;max-width:100%}
  .section .row-actions button,.section .row-actions .btn{font-size:11px;padding:7px 10px;min-height:33px;white-space:normal;line-height:1.25}
  .section .cmoc-fluid-wrap{overflow:visible!important;max-width:100%;width:100%;}
  .section .cmoc-fluid-table{display:block;width:100%;min-width:0!important;white-space:normal!important;border-collapse:separate!important;table-layout:auto!important}
  .section .cmoc-fluid-table thead{display:none!important}
  .section .cmoc-fluid-table tbody{display:grid;grid-template-columns:minmax(0,1fr);gap:8px;padding:10px;background:#f8f9fd;width:100%;}
  .section .cmoc-fluid-table tbody tr{
    display:grid;grid-template-columns:repeat(4,minmax(0,1fr));align-items:start;
    gap:8px 12px;min-width:0;width:100%;padding:12px 14px;
    background:#fff;border:1px solid #e7e3ef;border-radius:12px;
    box-shadow:0 2px 7px rgba(28,17,65,.035);
  }
  .section .cmoc-fluid-table tbody tr:hover{background:#fff;border-color:#d8caec}
  .section .cmoc-fluid-table tbody td{
    box-sizing:border-box;display:block;position:static!important;z-index:auto!important;
    padding:0!important;min-width:0!important;max-width:100%!important;width:auto!important;
    border:0!important;box-shadow:none!important;background:transparent!important;
    line-height:1.45;font-size:12px;white-space:normal;overflow-wrap:anywhere;
  }
  .section .cmoc-fluid-table tbody td::before{
    content:attr(data-cmoc-label);display:block;margin:0 0 5px;
    font-size:9px;font-weight:800;letter-spacing:.35px;text-transform:uppercase;
    color:#81768e;white-space:normal;line-height:1.25;
  }
  .section .cmoc-fluid-table tbody td.cmoc-fluid-actions{grid-column:1/-1;border-top:1px solid #f0edf5!important;padding-top:8px!important}
  .section .cmoc-fluid-table tbody td.cmoc-fluid-actions::before{display:none}
  .section .cmoc-fluid-table tbody td .tag,
  .section .cmoc-fluid-table tbody td.tag{font-weight:800;color:#27144f}
  .section .cmoc-fluid-table tbody td .status{font-size:10px;max-width:100%;display:inline-flex;white-space:normal}
  .section .cmoc-fluid-table tbody td select,
  .section .cmoc-fluid-table tbody td input,
  .section .cmoc-fluid-table tbody td textarea{
    box-sizing:border-box;display:block;width:100%!important;max-width:100%!important;min-width:0!important;
    min-height:36px;padding:7px 9px;font-size:12px
  }
  .section .cmoc-fluid-table tbody tr.cmoc-fluid-empty{display:block;padding:16px}
  .section .cmoc-fluid-table tbody tr.cmoc-fluid-empty td{display:block;max-width:100%!important;text-align:center}
  .section .cmoc-fluid-table tbody tr.cmoc-fluid-empty td::before{display:none}
  /* ITF: ações não ocupam uma coluna enorme; ficam na base do cartão. */
  #page-itfs .cmoc-fluid-table tbody tr{grid-template-columns:1.2fr .8fr 1fr 1fr}
  #page-itfs .cmoc-fluid-table td:last-child{grid-column:1/-1;padding-top:9px!important;border-top:1px solid #ede8f4!important}
  #page-itfs .cmoc-fluid-table td:last-child::before{display:none}
  #page-itfs .cmoc-fluid-table td:last-child .row-actions{max-width:none;display:flex;flex-wrap:wrap;justify-content:flex-start;gap:6px}
  #page-itfs .cmoc-fluid-table td:last-child .btn{min-width:0!important;max-width:none;padding:8px 11px;border-radius:8px}
  /* Veículos: TAG e ações visíveis, sem tabelão horizontal. */
  #page-vehicles .cmoc-fluid-table tbody tr{grid-template-columns:repeat(5,minmax(0,1fr))}
  #page-vehicles .cmoc-fluid-table tbody td:last-child{grid-column:1/-1;border-top:1px solid #f1edf7!important;padding-top:8px!important}
  #page-vehicles .cmoc-fluid-table tbody td:last-child::before{display:none}
  #page-vehicles .cmoc-fluid-table tbody td .row-actions{justify-content:flex-start}
  /* Controle diário: preservar todos os inputs e o salvar por TAG. */
  #page-daily .cmoc-fluid-table:has(#dailyRows) tbody tr{grid-template-columns:repeat(4,minmax(0,1fr));align-items:end}
  #page-daily .cmoc-fluid-table:has(#dailyRows) tbody td:nth-child(7){grid-column:span 2}
  #page-daily .cmoc-fluid-table:has(#dailyRows) tbody td:last-child{grid-column:span 2}
  #page-daily .cmoc-fluid-table:has(#dailyRows) tbody td:last-child::before{display:block}
  #page-daily .cmoc-fluid-table:has(#dailyRows) tbody td input,
  #page-daily .cmoc-fluid-table:has(#dailyRows) tbody td select{min-width:0!important}
  /* Verificação/reprogramação: observações e botões sem cortes. */
  #page-calendar .cmoc-fluid-table:has(#adherenceRows) tbody td:nth-child(5){grid-column:span 2}
  #page-calendar .cmoc-fluid-table:has(#adherenceRows) tbody td:nth-child(6){grid-column:span 2}
  /* Histórico de pneus: cartões em duas colunas e documentos legíveis. */
  #page-tires .cmoc-fluid-table:has(#tireHistoryRows) tbody{grid-template-columns:minmax(0,1fr)}
  #page-tires .cmoc-fluid-table:has(#tireHistoryRows) tbody tr{grid-template-columns:repeat(3,minmax(0,1fr))}
  #page-tires .cmoc-fluid-table:has(#tireHistoryRows) tbody td:nth-child(6){grid-column:span 2}
  #page-tires .cmoc-fluid-table:has(#tireHistoryRows) tbody td:last-child{grid-column:1/-1;border-top:1px solid #f0edf5!important;padding-top:8px!important}
  #page-tires .cmoc-fluid-table:has(#tireHistoryRows) tbody td:last-child::before{display:none}
  #page-tires .cmoc-fluid-table:has(#tireHistoryRows) tbody td .btn{white-space:normal}
  /* Historico KM: densidade sem coluna de usuário cortada. */
  #page-tires .cmoc-fluid-table:has(#kmHistoryRows) tbody tr{grid-template-columns:repeat(5,minmax(0,1fr))}
  #page-tires .cmoc-fluid-table:has(#kmHistoryRows) tbody td:last-child{grid-column:auto;border:0!important;padding:0!important}
  #page-tires .cmoc-fluid-table:has(#kmHistoryRows) tbody td:last-child::before{display:block}
}
@media (max-width:1050px){
  .content{padding:12px!important}
  .section .cmoc-fluid-table tbody tr{grid-template-columns:repeat(3,minmax(0,1fr))}
  #page-itfs .cmoc-fluid-table tbody tr{grid-template-columns:repeat(3,minmax(0,1fr))}
  #page-vehicles .cmoc-fluid-table tbody tr{grid-template-columns:repeat(3,minmax(0,1fr))}
  #page-daily .cmoc-fluid-table:has(#dailyRows) tbody tr{grid-template-columns:repeat(2,minmax(0,1fr))}
  #page-daily .cmoc-fluid-table:has(#dailyRows) tbody td:nth-child(7){grid-column:1/-1}
  #page-daily .cmoc-fluid-table:has(#dailyRows) tbody td:last-child{grid-column:1/-1}
  #page-calendar .cmoc-fluid-table:has(#adherenceRows) tbody td:nth-child(5),
  #page-calendar .cmoc-fluid-table:has(#adherenceRows) tbody td:nth-child(6){grid-column:auto}
  #page-tires .cmoc-fluid-table:has(#tireHistoryRows) tbody{grid-template-columns:minmax(0,1fr)}
  #page-tires .cmoc-fluid-table:has(#kmHistoryRows) tbody tr{grid-template-columns:repeat(3,minmax(0,1fr))}
}
@media (max-width:700px){
  .section .cmoc-fluid-table tbody{gap:8px;padding:8px}
  .section .cmoc-fluid-table tbody tr{grid-template-columns:repeat(2,minmax(0,1fr));padding:11px;gap:11px 9px}
  #page-itfs .cmoc-fluid-table tbody tr,
  #page-vehicles .cmoc-fluid-table tbody tr,
  #page-tires .cmoc-fluid-table:has(#tireHistoryRows) tbody tr,
  #page-tires .cmoc-fluid-table:has(#kmHistoryRows) tbody tr{grid-template-columns:repeat(2,minmax(0,1fr))}
  #page-itfs .cmoc-fluid-table tbody td:last-child .row-actions{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));width:100%}
  #page-itfs .cmoc-fluid-table tbody td:last-child .btn{width:100%;justify-content:center;margin:0}
  #page-vehicles .cmoc-fluid-table tbody td:last-child,
  #page-itfs .cmoc-fluid-table tbody td:last-child,
  #page-tires .cmoc-fluid-table:has(#tireHistoryRows) tbody td:last-child{grid-column:1/-1}
  #page-calendar .cmoc-fluid-table tbody td:last-child{grid-column:1/-1}
  #page-daily .cmoc-fluid-table:has(#dailyRows) tbody td:nth-child(7),
  #page-daily .cmoc-fluid-table:has(#dailyRows) tbody td:last-child{grid-column:1/-1}
  .section .table-head{align-items:flex-start;flex-direction:column}
  .section .table-head .table-tools{width:100%;min-width:0}
  .section .table-head .table-tools .search{flex:1 1 170px}
  .section .row-actions button,.section .row-actions .btn{font-size:11px}
  .section .cmoc-fluid-table tbody td{font-size:11px}
  .section .cmoc-fluid-table tbody td::before{font-size:9px}
  #page-tires .tire-cards-grid{grid-template-columns:1fr}
}

/* Ordenação também acessível quando os cabeçalhos das tabelas viram cartões. */
.cmoc-mobile-sort{display:none}
@media(max-width:1600px){#page-vehicles .cmoc-mobile-sort{display:block;min-width:148px;font-size:11px}}
@media(max-width:700px){#page-vehicles .cmoc-mobile-sort{flex:1 1 140px}}
