/* ═══════════════════════════════════════════════════════════════
   VERSÃO PARA CELULAR (até 768px)
   Elementos criados pelo mobile.js ficam escondidos no desktop.
═══════════════════════════════════════════════════════════════ */
#mHome,
#mBar,
#mVazio,
#mBottom,
.btn-share {
  display: none;
}

@media (max-width: 768px) {

  body {
    font-size: 14px;
    padding-bottom: 76px;
  }

  /* ── Cabeçalho: indicadores sempre visíveis ── */
  .app-navbar {
    padding: 8px 12px;
    gap: 8px;
  }

  .navbar-actions {
    order: 2;
    margin-left: auto;
  }

  .btn-atualizar {
    min-height: 40px;
    padding: 8px 16px;
    font-size: 0.82rem;
  }

  .navbar-stats {
    order: 3;
    display: flex !important;
    width: 100%;
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 6px;
    scrollbar-width: none;
  }

  .navbar-stats::-webkit-scrollbar {
    display: none;
  }

  .stat-pill {
    flex-shrink: 0;
    padding: 4px 10px;
    font-size: 0.78rem;
  }

  .fab {
    display: none !important;
  }

  .main-content {
    padding: 12px 12px 16px;
  }

  /* ── Tela inicial x categoria aberta ── */
  #mHome {
    display: block;
  }

  body.m-detalhe #mHome {
    display: none;
  }

  body:not(.m-detalhe) .tabs-wrapper {
    display: none;
  }

  .tabs-nav-container,
  .tab-header {
    display: none !important;
  }

  .m-home-titulo {
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--text-muted);
    margin: 4px 2px 10px;
  }

  .m-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .m-cat {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
    min-height: 88px;
    padding: 12px;
    text-align: left;
    font: inherit;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    transition: transform .1s;
  }

  .m-cat:active {
    transform: scale(.97);
  }

  .m-cat-topo {
    display: flex;
    align-items: flex-start;
    gap: 7px;
    min-width: 0;
  }

  .m-cat-topo i {
    color: var(--blue);
    font-size: 0.9rem;
    margin-top: 2px;
  }

  .m-cat-nome {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-muted);
    line-height: 1.25;
  }

  .m-cat-qtd {
    font-size: 1.6rem;
    font-weight: 700;
    line-height: 1;
  }

  .m-cat-qtd i {
    font-size: 1rem;
    color: var(--text-muted);
  }

  .m-cat.m-perigo .m-cat-qtd {
    color: var(--danger);
  }

  .m-cat.m-alerta .m-cat-qtd {
    color: #d97706;
  }

  .m-cat.m-zero {
    opacity: .55;
  }

  /* Regional em destaque, ocupando a linha inteira */
  .m-cat.m-destaque {
    grid-column: 1 / -1;
    flex-direction: row;
    align-items: center;
    min-height: 76px;
    background: linear-gradient(135deg, var(--navy-mid) 0%, var(--blue) 100%);
    border-color: transparent;
    opacity: 1;
  }

  .m-cat.m-destaque .m-cat-topo i,
  .m-cat.m-destaque .m-cat-nome,
  .m-cat.m-destaque .m-cat-qtd {
    color: #fff;
  }

  .m-cat.m-destaque .m-cat-nome {
    font-size: 1rem;
  }

  .m-cat.m-destaque .m-cat-qtd {
    font-size: 2rem;
  }

  .m-cat-info {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
  }

  .m-cat-detalhe {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
  }

  .m-cat.m-destaque .m-cat-detalhe {
    color: rgba(255, 255, 255, .85);
  }

  .m-cat.m-destaque .m-cat-detalhe b {
    color: #fff;
    font-size: 1rem;
  }

  /* Contagem MT/MS dos cartões */
  .m-uf {
    display: flex;
    flex-direction: column;
    gap: 2px;
    color: var(--text);
  }

  .m-uf b {
    font-size: 1.25rem;
    font-weight: 700;
    line-height: 1.1;
  }

  .m-cat.m-perigo .m-uf b {
    color: var(--danger);
  }

  .m-cat.m-alerta .m-uf b {
    color: #d97706;
  }

  /* Regional: MT/MS com ativos e parados */
  .m-reg {
    display: flex;
    flex-direction: column;
    gap: 5px;
  }

  .m-reg-linha {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
  }

  .m-reg-uf {
    min-width: 82px;
  }

  .m-st {
    padding: 1px 8px;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 700;
  }

  .m-st.m-st-ativo {
    background: #d1fae5;
    color: #065f46;
  }

  .m-st.m-st-parado {
    background: #fee2e2;
    color: #991b1b;
  }


  /* ── Barra da categoria aberta ── */
  .tabs-wrapper {
    background: transparent;
    box-shadow: none;
    overflow: visible;
  }

  .app-tab-content {
    padding: 12px 0 !important;
    background: transparent;
  }

  #mBar {
    display: block;
    position: sticky;
    top: var(--m-nav-h, 0px);
    z-index: 150;
    margin: -12px -12px 0;
    padding: 10px 12px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 2px 8px rgba(13, 27, 46, .06);
  }

  #mBar [hidden],
  #mVazio[hidden] {
    display: none !important;
  }

  .m-bar-topo {
    display: flex;
    align-items: center;
    gap: 10px;
  }

  .m-voltar {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 10px;
    background: #eef1f8;
    color: var(--text);
  }

  .m-bar-titulo {
    flex: 1;
    min-width: 0;
    font-size: 1rem;
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .m-bar-qtd {
    flex-shrink: 0;
    padding: 3px 10px;
    border-radius: 12px;
    background: var(--navy-mid);
    color: #fff;
    font-weight: 700;
    font-size: 0.85rem;
  }

  .m-busca {
    width: 100%;
    height: 40px;
    margin-top: 10px;
    padding: 0 12px;
    font-size: 16px;
    /* evita zoom automático no iPhone */
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #f7f9fc;
  }

  .m-busca:focus {
    outline: 2px solid var(--blue-lite);
    background: #fff;
  }

  .m-seg {
    display: flex;
    gap: 6px;
    margin-top: 10px;
  }

  .m-seg button {
    flex: 1;
    min-height: 36px;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: #fff;
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 600;
  }

  .m-seg button.ativo {
    background: var(--blue);
    border-color: var(--blue);
    color: #fff;
  }

  #mVazio {
    display: block;
    margin: 16px 2px 0;
  }

  /* ── Tabelas viram cartões (cabeçalho roxo, ícone em cada campo) ── */
  #myTabContent table,
  #myTabContent tbody,
  #myTabContent tr,
  #myTabContent td {
    display: block;
    width: 100%;
  }

  #myTabContent thead {
    display: none;
  }

  #myTabContent table {
    margin: 0;
    font-size: 14px;
    background: transparent;
    box-shadow: none;
    border-radius: 0;
    overflow: visible;
  }

  #myTabContent .table-container,
  #myTabContent .table-responsive {
    overflow: visible;
    background: transparent;
    box-shadow: none;
  }

  #myTabContent tbody tr {
    margin-bottom: 10px;
    padding: 0 12px 8px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow);
    overflow: hidden;
  }

  #myTabContent td {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 6px 0 !important;
    font-size: 0.82rem;
    text-align: right !important;
  }

  /* Anula zebra, hover e listras do Bootstrap (sem mexer no display) */
  #myTabContent tr td,
  #myTabContent tr:hover td,
  #myTabContent tr:nth-child(even) td {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
  }

  /* Divisória entre os campos */
  #myTabContent tbody tr>td:not(.m-titulo)+td {
    border-top: 1px solid #eef1f6 !important;
  }

  /* Ícone (::before) e rótulo (::after) à esquerda, valor à direita */
  #myTabContent td::before {
    content: '\f05a';
    order: -2;
    flex: 0 0 20px;
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    font-size: 0.95rem;
    text-align: center;
    color: var(--blue);
  }

  #myTabContent td::after {
    content: attr(data-label);
    order: -1;
    flex-shrink: 0;
    margin-right: auto;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: .4px;
    text-transform: uppercase;
    color: var(--text-muted);
  }

  #myTabContent td[data-k="CLIENTE"]::before {
    content: '\f1ad';
    font-weight: 400;
  }

  #myTabContent td[data-k="CIDADES"]::before {
    content: '\f3c5';
  }

  #myTabContent td[data-k="STATUS"]::before {
    content: '\f011';
  }

  #myTabContent td[data-k="TEMPO"]::before {
    content: '\f017';
    font-weight: 400;
  }

  #myTabContent td[data-k="UF"]::before {
    content: '\f279';
    font-weight: 400;
  }

  #myTabContent td[data-k="GRUPO"]::before {
    content: '\f0c0';
  }

  #myTabContent td[data-k="SERVICO"]::before {
    content: '\f233';
  }

  #myTabContent td[data-k="PROCEDENCIA"]::before {
    content: '\f024';
    font-weight: 400;
  }

  #myTabContent td[data-k="TIPO ABERTO"]::before {
    content: '\f07c';
    font-weight: 400;
  }

  #myTabContent td[data-k="TA RE"]::before {
    content: '\f0ad';
  }

  #myTabContent td[data-k="TIQ RAIZ"]::before {
    content: '\f0c1';
  }

  #myTabContent .m-val {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 700;
    color: var(--text);
  }

  /* Cabeçalho roxo: ícone | número do BD | selo do status */
  #myTabContent tbody tr td.m-titulo {
    position: relative;
    width: calc(100% + 24px);
    margin: 0 -12px 2px;
    padding: 8px 110px 8px 12px !important;
    justify-content: flex-start;
    text-align: left !important;
    background: linear-gradient(135deg, var(--navy-mid) 0%, var(--blue) 100%) !important;
  }

  #myTabContent td.m-titulo::before {
    content: '\f007';
    flex: 0 0 auto;
    padding-right: 10px;
    font-weight: 400;
    font-size: 1.1rem;
    color: #fff;
    border-right: 1px solid rgba(255, 255, 255, .25);
  }

  #myTabContent td.m-titulo::after {
    content: attr(data-status-txt);
    position: absolute;
    top: 50%;
    right: 14px;
    transform: translateY(-50%);
    margin: 0;
    padding: 3px 10px 3px 22px;
    border-radius: 999px;
    background: radial-gradient(circle at 11px 50%, #fca5a5 0 5px, transparent 6px), rgba(255, 255, 255, .14);
    font-size: 0.75rem;
    letter-spacing: 0;
    text-transform: none;
    color: #fff;
  }

  #myTabContent td.m-titulo:not([data-status-txt])::after {
    content: none;
  }

  #myTabContent tr[data-status="ATIVO"] td.m-titulo::after {
    background: radial-gradient(circle at 11px 50%, #86efac 0 5px, transparent 6px), rgba(255, 255, 255, .14);
  }

  #myTabContent td.m-titulo a {
    padding: 0;
    font-size: 1.15rem;
    font-weight: 800;
    letter-spacing: .5px;
    color: #fff !important;
  }

  /* Status como selo com bolinha */
  #myTabContent td.m-st-ativo .m-val,
  #myTabContent td.m-st-parado .m-val {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 2px 10px;
    border-radius: 999px;
    font-weight: 600;
  }

  #myTabContent td.m-st-ativo .m-val::before,
  #myTabContent td.m-st-parado .m-val::before {
    content: '';
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: currentColor;
  }

  #myTabContent td.m-st-ativo .m-val {
    background: #dcfce7;
    color: #15803d;
  }

  #myTabContent td.m-st-parado .m-val {
    background: #fde4e6;
    color: #e11d48;
  }

  #myTabContent td.m-tempo .m-val {
    font-size: 0.92rem;
    font-weight: 800;
    color: #e11d48;
  }

  #myTabContent td.m-extra {
    display: none;
  }

  #myTabContent tr.m-aberto td.m-extra {
    display: flex;
  }

  /* Botão "mais detalhes" */
  #myTabContent tr.m-tem-extra::after {
    content: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='13' height='13' viewBox='0 0 24 24' fill='none' stroke='%231e6fdb' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E") "  mais detalhes";
    display: block;
    margin-top: 4px;
    padding: 6px;
    border-radius: 12px;
    background: #eef4fd;
    text-align: center;
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--blue);
  }

  #myTabContent tr.m-aberto::after {
    content: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='13' height='13' viewBox='0 0 24 24' fill='none' stroke='%231e6fdb' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 15 12 9 18 15'/%3E%3C/svg%3E") "  menos detalhes";
  }

  #myTabContent .m-oculta {
    display: none !important;
  }

  /* Blocos MT/MS e faixa de horário */
  .pulse-box {
    margin-top: 12px;
    padding-left: 0;
    border-left: none;
    animation: none;
  }

  .pulse-box h6,
  #faixa_horario h6 {
    font-size: 0.9rem;
    margin-bottom: 8px;
  }

  #faixa_horario .card-body {
    padding: 10px !important;
    background: #f7f9fc !important;
  }

  .sub-tabs .nav-link {
    min-height: 40px;
  }

  /* ── Avisos ── */
  .sucesso-banner {
    bottom: 84px;
    width: calc(100% - 24px);
    white-space: normal;
    border-radius: 14px;
  }

  /* ── Barra inferior ── */
  #mBottom {
    display: flex;
    gap: 8px;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 400;
    padding: 8px 12px;
    background: var(--surface);
    border-top: 1px solid var(--border);
    box-shadow: 0 -2px 12px rgba(13, 27, 46, .08);
  }

  #mBottom button {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    min-height: 52px;
    border: none;
    border-radius: 12px;
    background: #eef1f8;
    color: var(--text);
    font-size: 0.75rem;
    font-weight: 600;
  }

  #mBottom button i {
    font-size: 1.05rem;
  }

  #mBottom .m-share {
    background: #1b8a4e;
    color: #fff;
  }

  /* ── Modal Resumo TXT ── */
  .btn-share {
    display: inline-flex;
    margin-right: 6px;
  }

  .bloco-card .btn {
    min-width: 40px;
    min-height: 40px;
    align-items: center;
    justify-content: center;
  }
}