/* =============================================================================
   IA-Sourcing -- camada MOBILE

   Carregado com media="(max-width: 768px)": no computador o navegador nem
   aplica este arquivo. Tudo aqui vale so para celular.

   Referencias de uso ja testado por milhoes de pessoas:
     - barra de navegacao embaixo, alcancavel com o polegar;
     - vitrine em 2 colunas com o essencial abaixo do titulo e "ver mais" ao
       tocar (Mercado Livre);
     - chat em duas telas, lista -> conversa (WhatsApp);
     - listas em cartoes, sem rolagem lateral;
     - filtros recolhidos; numeros-resumo numa faixa que desliza.
   ========================================================================== */

body.m-ativo {
    --m-barra-h: 60px;
    --m-seguro: env(safe-area-inset-bottom, 0px);
    --m-fundo: rgba(15, 23, 42, 0.97);
    --m-cartao: rgba(30, 41, 59, 0.72);
    --m-borda: rgba(255, 255, 255, 0.08);
    overflow-x: hidden;
}

/* ------------------------------------------------------------------ topo */
body.m-ativo .sidebar-header {
    padding: 0.55rem 0.9rem;
    min-height: 52px;
}
body.m-ativo #sidebar-logo-icon { width: 30px; height: 30px; font-size: 0.95rem; }
body.m-ativo #sidebar-title { font-size: 0 !important; }
body.m-ativo #sidebar-title::after {
    content: attr(data-m-titulo);
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}

/* --------------------------------------------------------- barra inferior */
#m-barra {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 90;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    height: calc(var(--m-barra-h) + var(--m-seguro));
    padding-bottom: var(--m-seguro);
    background: var(--m-fundo);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border-top: 1px solid var(--m-borda);
}
body:not(.m-ativo) #m-barra { display: none; }
.m-barra-btn {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 2px; background: none; border: none; color: #94a3b8;
    font-size: 0.68rem; font-weight: 600; min-width: 0 !important; min-height: 0 !important;
    width: auto !important; margin: 0 !important; padding: 0 !important; cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.m-barra-ico { position: relative; font-size: 1.25rem; line-height: 1; filter: grayscale(0.6); opacity: 0.8; }
.m-barra-btn.ativo { color: #60a5fa; }
.m-barra-btn.ativo .m-barra-ico { filter: none; opacity: 1; }
.m-barra-btn.ativo::before {
    content: ''; position: absolute; top: 0; width: 28px; height: 3px; border-radius: 0 0 3px 3px; background: #3b82f6;
}
.m-barra-btn { position: relative; }
.m-barra-badge {
    position: absolute; top: -6px; right: -10px; min-width: 17px; height: 17px; padding: 0 4px;
    border-radius: 9px; background: #ef4444; color: #fff; font-size: 0.6rem; font-style: normal;
    font-weight: 800; align-items: center; justify-content: center; display: none;
}

/* O conteudo nao pode ficar escondido atras da barra. */
body.m-ativo .main-content {
    padding: 0.7rem 0.7rem calc(var(--m-barra-h) + var(--m-seguro) + 1rem) !important;
    gap: 0.7rem !important;
}
/* Menu lateral ("Mais") acima da barra. */
body.m-ativo .sidebar-content { z-index: 120; padding-bottom: calc(var(--m-barra-h) + 1rem); }
body.m-ativo #mobile-menu-overlay { z-index: 110 !important; }

/* ----------------------------------------------------- base das telas */
/* Botoes nao ocupam a largura toda por padrao: isso empilhava barras de
   acao inteiras. So o botao principal de cada tela e cheio. */
body.m-ativo .modern-btn { width: auto; margin-bottom: 0; }
body.m-ativo .modern-btn.full-width,
body.m-ativo .modern-btn.large,
body.m-ativo .sidebar-actions .modern-btn { width: 100%; }

/* Cabecalho de cada tela: titulo curto, descricao em 2 linhas no maximo. */
body.m-ativo .tab-content h1,
body.m-ativo .tab-content > .glass-panel:first-child h2,
body.m-ativo .tab-content > div:first-child h2 { font-size: 1.15rem !important; line-height: 1.25; }
body.m-ativo .tab-content > .glass-panel:first-child p,
body.m-ativo .tab-content > div:first-child > div > p {
    font-size: 0.78rem !important; display: -webkit-box; -webkit-line-clamp: 2;
    -webkit-box-orient: vertical; overflow: hidden;
}
body.m-ativo .tab-content > .glass-panel:first-child { padding: 0.85rem 1rem !important; }
body.m-ativo .glass-panel { border-radius: 14px; }

/* Numeros-resumo: uma faixa que desliza, em vez de 8 cartoes empilhados. */
body.m-ativo .dashboard-stats {
    display: flex !important; flex-wrap: nowrap; overflow-x: auto; gap: 0.5rem;
    scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch; padding-bottom: 2px;
    scrollbar-width: none; position: relative;
}
body.m-ativo .dashboard-stats::-webkit-scrollbar { display: none; }
body.m-ativo .dashboard-stats > * {
    flex: 0 0 auto; min-width: 128px; max-width: 150px; scroll-snap-align: start;
    padding: 0.6rem 0.75rem !important;
}
body.m-ativo .dashboard-stats .stat-title { font-size: 0.62rem !important; white-space: normal; line-height: 1.2; }
body.m-ativo .dashboard-stats .stat-value { font-size: 1.15rem !important; }
body.m-ativo .dashboard-stats button,
body.m-ativo .dashboard-stats [style*="position: absolute"] { position: static !important; transform: none !important; }

/* Abas internas / segmentos: uma linha que desliza. */
body.m-ativo .portal-tabs,
body.m-ativo [class*="portal-tabs"],
body.m-ativo #websites-tab .portal-tab-btn:first-child:not(:only-child) { }
body.m-ativo .portal-tab-btn {
    flex: 0 0 auto !important; padding: 0.55rem 0.9rem !important; font-size: 0.85rem !important;
    width: auto !important; min-height: 40px !important; white-space: nowrap;
}
body.m-ativo .portal-tab-btn:first-of-type { margin-left: 0; }
body.m-ativo .m-rolagem,
body.m-ativo #websites-tab .portal-tab-btn { scroll-snap-align: start; }

/* -------------------------------------------------- tabelas -> cartoes */
body.m-ativo .modern-table-container,
body.m-ativo .inner-table-container { overflow: visible !important; background: transparent !important; border: none !important; box-shadow: none !important; }
body.m-ativo table.m-cartoes { min-width: 0 !important; width: 100% !important; table-layout: auto !important; border: none; }
body.m-ativo table.m-cartoes thead { display: none; }
body.m-ativo table.m-cartoes tbody { display: flex; flex-direction: column; gap: 0.55rem; }
body.m-ativo table.m-cartoes tr {
    display: block; background: var(--m-cartao); border: 1px solid var(--m-borda);
    border-radius: 12px; padding: 0.55rem 0.8rem;
}
body.m-ativo table.m-cartoes td {
    display: flex; justify-content: space-between; align-items: center; gap: 0.75rem;
    padding: 0.28rem 0 !important; border: none !important; width: auto !important;
    max-width: none !important; text-align: right; white-space: normal !important;
    overflow: visible !important; font-size: 0.84rem; min-height: 0;
}
body.m-ativo table.m-cartoes td[data-label]::before {
    content: attr(data-label); flex: 0 0 auto; max-width: 45%; text-align: left;
    color: #94a3b8; font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.02em;
}
body.m-ativo table.m-cartoes td:not([data-label]):empty,
body.m-ativo table.m-cartoes td[data-label=""]:empty { display: none; }
body.m-ativo table.m-cartoes td.m-cheia { display: block; text-align: left; padding: 0 !important; }
body.m-ativo table.m-cartoes tr:has(> td.m-cheia:only-child) { padding: 0; background: transparent; border: none; }
body.m-ativo table.m-cartoes td > * { max-width: 100%; }
body.m-ativo table.m-cartoes input,
body.m-ativo table.m-cartoes select { max-width: 60%; }

/* ---------------------------------------- IA Sourcing: caixa de busca */
body.m-ativo .search-section.sticky-bottom {
    bottom: calc(var(--m-barra-h) + var(--m-seguro)) !important;
    padding: 0.55rem 0.7rem 0.6rem !important;
    border-radius: 16px 16px 0 0 !important;
    z-index: 80 !important;
}
body.m-ativo .search-section .search-box { display: grid !important; grid-template-columns: 1fr auto; gap: 0.45rem !important; align-items: end; }
body.m-ativo #aviation-search-inputs,
body.m-ativo #general-search-inputs { grid-column: 1; grid-row: 1; }
body.m-ativo #pn-input {
    min-height: 44px !important; height: 44px; max-height: 44px; padding: 0.6rem 0.75rem !important;
    font-size: 16px !important; resize: none; border-radius: 12px; transition: max-height 0.2s, height 0.2s;
}
body.m-ativo #pn-input:focus { height: 108px; max-height: 108px; }
body.m-ativo .search-section .search-actions {
    display: contents !important;
}
body.m-ativo .search-section .search-actions > div:first-child {
    grid-column: 1 / -1; grid-row: 2; display: flex !important; flex-wrap: nowrap !important;
    gap: 0.4rem !important; overflow-x: auto; scrollbar-width: none; align-items: center;
}
body.m-ativo .search-section .search-actions > div:first-child::-webkit-scrollbar { display: none; }
body.m-ativo .search-section .search-actions > div:first-child > * { flex: 0 0 auto; }
body.m-ativo #pn-counter { font-size: 0.72rem; }
body.m-ativo .search-section .ps-badge { min-height: 32px !important; padding: 0.2rem 0.6rem; font-size: 0.75rem; }
body.m-ativo .search-section .search-actions > div:first-child > div:last-child {
    padding: 0.2rem 0.5rem !important; gap: 0.35rem !important; min-height: 32px;
}
body.m-ativo .search-section .search-actions > div:first-child > div:last-child label { font-size: 0.72rem !important; white-space: nowrap; }
body.m-ativo #btn-select-rfq-vendors { min-height: 28px !important; padding: 0.15rem 0.45rem !important; font-size: 0.68rem !important; }
body.m-ativo #search-btn {
    grid-column: 2; grid-row: 1; width: 48px !important; height: 44px; min-height: 44px !important;
    padding: 0 !important; border-radius: 12px; justify-content: center;
}
body.m-ativo #search-btn .btn-text { display: none; }
body.m-ativo #search-btn .btn-icon { font-size: 1.15rem; margin: 0; }
/* Espaco para a caixa de busca nao cobrir o fim do historico. */
body.m-ativo[data-m-aba="sourcing"] .main-content { padding-bottom: calc(var(--m-barra-h) + var(--m-seguro) + 130px) !important; }

/* Historico de buscas: cada busca e um cartao. */
body.m-ativo #results-tbody > tr.main-row,
body.m-ativo #results-tbody > tr:not(.details-row):not(.expandable-content-row) { position: relative; }
body.m-ativo #results-tbody td[data-label=""]::before { display: none; }
body.m-ativo #results-tbody .expand-btn { min-width: 36px !important; min-height: 36px !important; }
body.m-ativo #results-tbody td.col-acoes { justify-content: flex-end; flex-wrap: wrap; gap: 0.35rem; }
body.m-ativo #results-tbody td.col-acoes::before { display: none; }
body.m-ativo #results-tbody td.col-acoes > * { flex: 0 0 auto; }
body.m-ativo #results-tbody tr.details-row,
body.m-ativo #results-tbody tr.expandable-content-row { margin-top: -0.35rem; }
body.m-ativo .expanded-inner-content { padding: 0.35rem !important; }
body.m-ativo .pn-group { padding: 0.6rem !important; }
body.m-ativo .pn-group > div:first-child { flex-direction: column; gap: 0.5rem; }
body.m-ativo .pn-group .modern-btn { width: 100% !important; font-size: 0.8rem !important; }
body.m-ativo .busca-export-barra { flex-direction: column; align-items: stretch; }
body.m-ativo .busca-export-acoes { justify-content: space-between; }

/* Barra da tabela de fornecedores: busca em cima, controles embaixo. */
body.m-ativo .vendor-barra { flex-direction: column; align-items: stretch; gap: 0.5rem; padding: 0.55rem !important; }
body.m-ativo .vendor-barra-dir { flex-wrap: wrap; justify-content: space-between; gap: 0.4rem; }
body.m-ativo .vendor-busca input { font-size: 16px !important; }

/* ------------------------------ Vitrine de fornecedores (2 por linha) */
body.m-ativo table.m-vitrine tbody {
    display: grid !important; grid-template-columns: 1fr 1fr; gap: 0.5rem; padding: 0.5rem;
}
body.m-ativo table.m-vitrine tbody tr {
    display: flex; flex-direction: column; gap: 0.15rem; padding: 0.6rem 0.6rem 0.55rem;
    min-width: 0; position: relative; cursor: pointer; border-radius: 12px;
    background: rgba(30, 41, 59, 0.85);
}
body.m-ativo table.m-vitrine tbody tr.inner-best-row { border-color: rgba(16, 185, 129, 0.55); box-shadow: 0 0 0 1px rgba(16, 185, 129, 0.25) inset; }
body.m-ativo table.m-vitrine tbody tr:has(td.m-cheia) { grid-column: 1 / -1; cursor: default; }
body.m-ativo table.m-vitrine td { display: block; text-align: left; padding: 0 !important; font-size: 0.78rem; }
body.m-ativo table.m-vitrine td::before { display: none !important; }
/* Ordem de leitura do cartao: fornecedor, preco, estoque/condicao, prazo. */
body.m-ativo table.m-vitrine td:nth-child(1) { order: 1; font-size: 0.8rem; padding-right: 1.4rem !important; }
body.m-ativo table.m-vitrine td:nth-child(1) strong { display: block; white-space: normal; line-height: 1.25; word-break: break-word; }
body.m-ativo table.m-vitrine td:nth-child(1) > div:first-child { white-space: normal !important; overflow: visible !important; }
body.m-ativo table.m-vitrine td:nth-child(1) .best-badge { display: inline-block; margin: 3px 0 0 0 !important; font-size: 0.55rem; }
body.m-ativo table.m-vitrine td:nth-child(3) { order: 2; font-size: 1.12rem; font-weight: 800; color: #f8fafc; margin-top: 0.2rem; }
body.m-ativo table.m-vitrine td:nth-child(3).best { color: #34d399; }
body.m-ativo table.m-vitrine td:nth-child(5) { order: 3; }
body.m-ativo table.m-vitrine td:nth-child(8) { order: 4; }
body.m-ativo table.m-vitrine td:nth-child(6) { order: 5; }
body.m-ativo table.m-vitrine td:nth-child(2) { order: 6; }
body.m-ativo table.m-vitrine td:nth-child(5) .meta-pill,
body.m-ativo table.m-vitrine td:nth-child(6) .meta-pill,
body.m-ativo table.m-vitrine td:nth-child(8) .meta-pill { font-size: 0.66rem; padding: 1px 6px; max-width: 100%; }
body.m-ativo table.m-vitrine td:nth-child(8) { display: flex; flex-wrap: wrap; gap: 3px; }
body.m-ativo table.m-vitrine td:nth-child(2) .meta-pill { font-size: 0.58rem !important; padding: 1px 5px !important; opacity: 0.85; }
/* "Ver mais": UOM, contato e link so com o cartao aberto. */
body.m-ativo table.m-vitrine td:nth-child(4),
body.m-ativo table.m-vitrine td:nth-child(7),
body.m-ativo table.m-vitrine td:nth-child(9) { display: none; }
body.m-ativo table.m-vitrine tr::after {
    content: 'ⓘ'; position: absolute; top: 0.45rem; right: 0.5rem; font-size: 0.95rem; color: #60a5fa; opacity: 0.85;
}
body.m-ativo table.m-vitrine tr:has(td.m-cheia)::after { display: none; }
body.m-ativo table.m-vitrine tr.m-aberto { grid-column: 1 / -1; background: rgba(30, 58, 95, 0.55); border-color: rgba(96, 165, 250, 0.45); }
body.m-ativo table.m-vitrine tr.m-aberto::after { content: '✕'; }
body.m-ativo table.m-vitrine tr.m-aberto td:nth-child(4),
body.m-ativo table.m-vitrine tr.m-aberto td:nth-child(7),
body.m-ativo table.m-vitrine tr.m-aberto td:nth-child(9) { display: block; order: 7; }
body.m-ativo table.m-vitrine tr.m-aberto td:nth-child(4)::before { content: 'UOM: '; display: inline !important; color: #94a3b8; }
body.m-ativo table.m-vitrine tr.m-aberto td:nth-child(7) { margin-top: 0.35rem; padding-top: 0.35rem !important; border-top: 1px solid var(--m-borda) !important; }
body.m-ativo table.m-vitrine tr.m-aberto td:nth-child(9) a,
body.m-ativo table.m-vitrine tr.m-aberto td:nth-child(9) button { margin-top: 0.4rem; width: 100%; justify-content: center; padding: 0.55rem !important; font-size: 0.82rem !important; }
body.m-ativo table.m-vitrine tr.m-aberto td:nth-child(1) strong,
body.m-ativo table.m-vitrine tr.m-aberto td:nth-child(1) div { white-space: normal !important; }

/* ------------------------------------------------ Chat (WhatsApp) */
body.m-ativo #chat-tab { height: auto !important; }
body.m-ativo #chat-tab > .glass-panel:first-child { display: none; }
body.m-ativo .m-chat {
    display: block !important; position: relative; min-height: calc(100dvh - 52px - var(--m-barra-h) - 2rem);
    border-radius: 14px; overflow: hidden;
}
body.m-ativo .m-chat > div:first-child { width: 100% !important; border-right: none !important; }
body.m-ativo .m-chat > div:last-child { display: none !important; }
body.m-ativo .m-chat.m-chat-aberto > div:first-child { display: none !important; }
/* A conversa ocupa a area util inteira (topo ate a barra). Sem position
   fixed: o painel de vidro (backdrop-filter) prende elementos fixos dentro
   dele, e a conversa sumia. */
body.m-ativo .m-chat.m-chat-aberto {
    /* flex:1 (inline) zeraria a altura numa coluna sem altura definida */
    flex: none !important;
    height: calc(100dvh - 52px - var(--m-barra-h) - var(--m-seguro) - 1.4rem); min-height: 0 !important;
}
body.m-ativo .m-chat.m-chat-aberto { display: flex !important; flex-direction: column; }
body.m-ativo .m-chat.m-chat-aberto > div:last-child {
    display: flex !important; flex: 1 1 auto !important; min-height: 0; background: #0b1220; flex-direction: column;
}
body.m-ativo .m-chat.m-chat-aberto #chat-thread-messages { flex: 1 1 auto; min-height: 0; }
body.m-ativo .m-chat .chat-subtab { min-height: 38px !important; font-size: 0.8rem !important; }
body.m-ativo #chat-thread-list { padding: 0 !important; }
body.m-ativo .m-chat-item {
    display: grid !important; grid-template-columns: 44px 1fr; column-gap: 0.7rem; align-items: center;
    padding: 0.65rem 0.85rem !important; margin: 0 !important; border-radius: 0 !important;
    border: none !important; border-bottom: 1px solid var(--m-borda) !important;
}
body.m-ativo .m-chat-item > :not(.m-avatar) { grid-column: 2; }
body.m-ativo .m-avatar {
    grid-row: 1 / span 3; width: 44px; height: 44px; border-radius: 50%; display: flex;
    align-items: center; justify-content: center; font-weight: 800; font-size: 0.9rem; color: #fff;
    background: linear-gradient(135deg, #0f766e, #3b82f6);
}
body.m-ativo .m-chat-item span { font-size: 0.95rem !important; }
body.m-ativo .m-chat-item > div:last-child { font-size: 0.82rem !important; }
body.m-ativo #m-chat-voltar {
    position: absolute; top: 0; left: 0; z-index: 2; width: 48px; height: 50px; border: none;
    background: transparent; color: #e2e8f0; font-size: 2rem; line-height: 1; min-width: 0 !important;
}
body.m-ativo .m-chat:not(.m-chat-aberto) #m-chat-voltar { display: none; }
body.m-ativo .m-chat.m-chat-aberto #chat-thread-header {
    padding: 0.75rem 0.9rem 0.75rem 3rem !important; background: rgba(30, 41, 59, 0.95);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-height: 50px;
}
body.m-ativo #chat-thread-messages {
    background: #0b1220 radial-gradient(rgba(255,255,255,0.025) 1px, transparent 1px) 0 0 / 18px 18px;
    padding: 0.8rem !important;
}
body.m-ativo #chat-thread-messages > div > div { max-width: 85% !important; font-size: 0.9rem !important; }
body.m-ativo #chat-composer {
    padding: 0.5rem !important; background: rgba(15, 23, 42, 0.98); gap: 0.45rem !important;
}
body.m-ativo #chat-message-input { border-radius: 22px !important; padding: 0.6rem 1rem !important; }
body.m-ativo #chat-send-btn {
    width: 46px !important; min-width: 46px !important; height: 46px; border-radius: 50% !important;
    padding: 0 !important; font-size: 0 !important; position: relative;
}
body.m-ativo #chat-send-btn::after { content: '➤'; font-size: 1.1rem; }

/* --------------------------------------------------------- Filtros */
.m-filtros-btn { display: none; }
body.m-ativo .m-filtros-btn {
    display: flex; justify-content: space-between; align-items: center; width: 100%;
    padding: 0.7rem 0.95rem; border-radius: 12px; border: 1px solid var(--m-borda);
    background: var(--m-cartao); color: var(--text-primary); font-weight: 600; font-size: 0.88rem;
    margin-bottom: 0.6rem;
}
body.m-ativo .m-filtros-btn .m-filtros-seta { transition: transform 0.2s; }
body.m-ativo .m-filtros-btn.aberto .m-filtros-seta { transform: rotate(180deg); }
body.m-ativo .m-filtros { display: none !important; }
body.m-ativo .m-filtros.m-filtros-aberto {
    display: grid !important; grid-template-columns: 1fr 1fr !important; gap: 0.6rem !important;
    padding: 0.8rem !important; margin-bottom: 0.8rem !important;
}
body.m-ativo .m-filtros .input-group label { font-size: 0.72rem !important; }

/* ----------------------------------------------------------- Modais */
body.m-ativo .modal-content {
    width: 100% !important; max-width: 100% !important; height: 100dvh !important; max-height: 100dvh !important;
    border-radius: 0 !important; padding: 1rem 0.9rem !important;
}
body.m-ativo .modal-overlay { padding: 0 !important; }

/* Ajustes da primeira rodada de testes */
#version-tag { display: none !important; }
body.m-ativo .dashboard-section { gap: 0.6rem !important; }
body.m-ativo .dashboard-stats { align-items: flex-start; }
body.m-ativo .dashboard-stats > * { height: auto !important; min-height: 0 !important; }
/* Linha de detalhe fechada continua fechada (o "block" dos cartoes a abria). */
body.m-ativo table.m-cartoes tr.expandable-content-row:not(.open),
body.m-ativo table.m-cartoes tr[style*="display: none"],
body.m-ativo table.m-cartoes tr.hidden { display: none !important; }
/* Cartao de logs de sincronizacao: detalhe tecnico, fora da faixa no celular. */
body.m-ativo .dashboard-stats > .stat-card:has(button),
body.m-ativo .dashboard-stats > .stat-card:has([onclick]) { display: none !important; }
body.m-ativo .vendor-busca { flex: none !important; height: auto !important; min-height: 0 !important; padding: 0 0.6rem !important; }
body.m-ativo .vendor-busca input { height: 40px !important; min-height: 40px !important; padding: 0 !important; }

/* ------------- Cartoes com o essencial e "Ver mais" (Database, listas) */
body.m-ativo table.m-cartoes td.m-oculta { display: none !important; }
body.m-ativo table.m-cartoes td.m-titulo {
    display: block; text-align: left; font-size: 1rem; font-weight: 800; padding: 0.1rem 0 0.35rem !important;
    border-bottom: 1px solid var(--m-borda) !important; margin-bottom: 0.25rem; word-break: break-word;
}
body.m-ativo table.m-cartoes td.m-titulo::before { display: none !important; }
body.m-ativo table.m-cartoes tr.m-expansivel { cursor: pointer; }
body.m-ativo table.m-cartoes tr.m-expansivel td.m-sec { display: none; }
body.m-ativo table.m-cartoes tr.m-expansivel.m-aberto td.m-sec { display: flex; }
body.m-ativo table.m-cartoes tr.m-expansivel::after {
    content: 'Ver mais ▾'; display: block; text-align: center; font-size: 0.74rem; font-weight: 700;
    color: #60a5fa; padding-top: 0.35rem; margin-top: 0.2rem; border-top: 1px dashed var(--m-borda);
}
body.m-ativo table.m-cartoes tr.m-expansivel.m-aberto::after { content: 'Ver menos ▴'; }
/* Checkbox de selecao no canto do cartao, sem rotulo. */
body.m-ativo #db-quotes-body td:first-child:not(.m-titulo) { position: absolute; right: 0.8rem; top: 0.55rem; padding: 0 !important; }
body.m-ativo #db-quotes-body tr { position: relative; }
body.m-ativo #db-quotes-body td.m-titulo { padding-right: 2rem !important; font-family: var(--font-mono); color: #60a5fa; }

/* Barras de acao com varios botoes: uma linha que desliza. */
body.m-ativo #database-tab > .glass-panel > div:has(> .modern-btn + .modern-btn),
body.m-ativo #database-tab div:has(> #db-import-btn) {
    flex-wrap: nowrap !important; overflow-x: auto; scrollbar-width: none; gap: 0.45rem !important;
}
body.m-ativo #database-tab div:has(> .modern-btn + .modern-btn) > .modern-btn { flex: 0 0 auto; padding: 0.5rem 0.8rem !important; font-size: 0.8rem !important; }

/* Cartao: titulo primeiro, e largura total. */
body.m-ativo table.m-cartoes { border-spacing: 0 !important; border-collapse: collapse !important; }
body.m-ativo table.m-cartoes tbody { width: 100%; }
body.m-ativo table.m-cartoes tr:has(> td.m-titulo) { display: flex; flex-direction: column; }
body.m-ativo table.m-cartoes td.m-titulo { order: -1; }
body.m-ativo #vendas-tabela-wrap { width: 100% !important; max-width: 100% !important; box-sizing: border-box; padding: 0.7rem !important; }

/* Vendas: botoes de visao numa linha que desliza; filtros da lista em grade. */
body.m-ativo #vendas-tab div:has(> .vendas-chip) { flex-wrap: nowrap !important; overflow-x: auto; scrollbar-width: none; }
body.m-ativo #vendas-tab .vendas-chip { flex: 0 0 auto; }
body.m-ativo #vendas-tabela-wrap div:has(> #vendas-data-de) {
    display: grid !important; grid-template-columns: 1fr 1fr auto auto; gap: 0.4rem !important; align-items: center;
}
body.m-ativo #vendas-data-de, body.m-ativo #vendas-data-ate { width: 100% !important; min-width: 0; }
body.m-ativo #vendas-busca { grid-column: 1 / -1; order: 5; width: 100% !important; }
body.m-ativo .vendas-card { padding: 0.65rem 0.75rem !important; }

/* ------------------------------------------------------------ Dashboard */
body.m-ativo #dashboard-tab div:has(> .glass-panel > #dash-kpi-total),
body.m-ativo #dashboard-tab div:has(> .glass-panel [id^="dash-kpi-"]) {
    grid-template-columns: 1fr 1fr !important; gap: 0.5rem !important;
}
body.m-ativo #dashboard-tab div:has(> .glass-panel [id^="dash-kpi-"]) > .glass-panel { padding: 0.7rem 0.75rem !important; min-height: 0 !important; }
body.m-ativo #dashboard-tab [id^="dash-kpi-"]:not([id$="-sub"]) { font-size: 1.35rem !important; word-break: break-word; }
body.m-ativo #dashboard-tab [id$="-sub"] { font-size: 0.68rem !important; }
/* Filtros do dashboard: recolhidos; tocar no titulo abre. */
body.m-ativo .dash-filter-bar { flex-direction: column !important; align-items: stretch !important; padding: 0.7rem 0.85rem !important; gap: 0.6rem !important; }
body.m-ativo .dash-filter-bar .dash-filter-title-block { cursor: pointer; }
body.m-ativo .dash-filter-bar .dash-filter-title-block::after { content: '⚙️ Filtros ▾'; margin-left: auto; font-size: 0.75rem; font-weight: 700; color: #60a5fa; white-space: nowrap; }
body.m-ativo .dash-filter-bar.m-aberto .dash-filter-title-block::after { content: 'Fechar ▴'; }
body.m-ativo .dash-filter-bar:not(.m-aberto) .dash-filter-fields,
body.m-ativo .dash-filter-bar:not(.m-aberto) .dash-filter-actions { display: none !important; }
body.m-ativo .dash-filter-bar.m-aberto .dash-filter-fields { display: grid !important; grid-template-columns: 1fr 1fr; gap: 0.5rem; width: 100% !important; }
body.m-ativo .dash-filter-bar .dash-filter-field { width: auto !important; min-width: 0 !important; }
body.m-ativo .dash-filter-bar .dash-filter-field input,
body.m-ativo .dash-filter-bar .dash-filter-field select { width: 100% !important; min-width: 0 !important; }
body.m-ativo .dash-subtab { flex: 1 1 0; font-size: 0.85rem !important; }
body.m-ativo #dashboard-tab canvas { max-width: 100% !important; }

/* ------------------------------------------------------------ Cadastros */
body.m-ativo #cadastros-tab div:has(> .cad-subtab) { flex-wrap: nowrap !important; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
body.m-ativo #cadastros-tab .cad-subtab { flex: 0 0 auto; }
body.m-ativo #cad-busca { flex: 0 0 100% !important; order: 10; width: 100% !important; }
body.m-ativo #cadastros-tab div:has(> #cad-busca) { flex-wrap: wrap !important; }
body.m-ativo #cadastros-tab div:has(> .cad-subtab):has(> #cad-busca) { flex-wrap: wrap !important; overflow: visible; }
body.m-ativo .dash-filter-bar .dash-filter-title-block { flex-wrap: wrap; width: 100% !important; }
body.m-ativo .dash-filter-bar .dash-filter-title-text { min-width: 0; flex: 1 1 auto; }
body.m-ativo table.m-cartoes td.m-cheia { width: 100% !important; max-width: 100% !important; box-sizing: border-box; }
body.m-ativo table.m-cartoes tr:has(> td.m-cheia:only-child) > td.m-cheia { text-align: center; }

/* =============================================================================
   v2 -- nada cortado, nada rolando para o lado.
   Padrao iOS/WhatsApp/Mercado Livre: margens de 12px, titulo grande, grades
   que quebram linha, alvos de toque de 40-44px, uma coisa por linha.
   ========================================================================== */
body.m-ativo .main-content { padding-left: 12px !important; padding-right: 12px !important; }
body.m-ativo .tab-content { padding: 0 !important; overflow-x: hidden !important; max-width: 100%; }
body.m-ativo .tab-content * { max-width: 100%; box-sizing: border-box; }
body.m-ativo .glass-panel { padding: 0.85rem !important; }

/* Titulo grande (iOS), sem gradiente; a descricao longa sai no celular. */
body.m-ativo .tab-content h1,
body.m-ativo .tab-content > .glass-panel:first-child h2,
body.m-ativo .tab-content .glass-panel:first-child > div:first-child h2 {
    font-size: 1.4rem !important; font-weight: 800 !important; letter-spacing: -0.02em;
    background: none !important; -webkit-text-fill-color: #f1f5f9 !important; color: #f1f5f9 !important;
    margin: 0 0 0.15rem !important;
}
body.m-ativo #database-tab h2 + p.text-muted,
body.m-ativo #chat-tab > .glass-panel:first-child p,
body.m-ativo #websites-tab .glass-panel:first-child p { display: none !important; }

/* ---- Numeros-resumo: grade 2x2 com os 4 principais (sem faixa lateral) */
body.m-ativo .dashboard-stats {
    display: grid !important; grid-template-columns: 1fr 1fr; overflow: visible !important; gap: 0.5rem !important;
}
body.m-ativo .dashboard-stats > * { min-width: 0 !important; max-width: none !important; }
body.m-ativo .dashboard-stats > .stat-card:nth-child(n+5) { display: none !important; }

/* ---- IA Sourcing: cabecalho do historico numa linha so */
body.m-ativo #sourcing-tab .glass-panel:has(#pagination-container) { position: static !important; padding: 0.6rem 0.75rem !important; }
body.m-ativo #sourcing-tab .section-header { flex-wrap: nowrap !important; gap: 0.5rem !important; }
body.m-ativo #sourcing-tab .section-header h3 { font-size: 1.05rem !important; font-weight: 800 !important; white-space: nowrap; flex: 1 1 auto; min-width: 0; }
body.m-ativo #sourcing-tab .section-header h3 .icon { display: none; }
body.m-ativo #sourcing-tab .section-header > div { flex-wrap: nowrap !important; gap: 0.4rem !important; flex: 0 0 auto; }
body.m-ativo #pagination-container { padding: 0.15rem !important; gap: 0.15rem !important; border-radius: 10px !important; }
body.m-ativo #pagination-container button,
body.m-ativo #pagination-container span { min-width: 32px !important; min-height: 32px !important; height: 32px; padding: 0 0.4rem !important; font-size: 0.8rem !important; }
body.m-ativo #btn-toggle-filters { font-size: 0 !important; width: 40px !important; height: 40px; min-height: 40px !important; padding: 0 !important; justify-content: center; }
body.m-ativo #btn-toggle-filters span { font-size: 1rem; }

/* Historico: cartao com a busca num relance (ID + status, PNs, data + acoes). */
body.m-ativo #results-tbody > tr:not(.expandable-content-row):has(> td.col-acoes) {
    display: grid !important; grid-template-columns: 36px minmax(0, 1fr) auto; column-gap: 0.5rem; row-gap: 0.3rem;
    align-items: center; padding: 0.7rem 0.75rem !important;
}
body.m-ativo #results-tbody > tr:has(> td.col-acoes) > td { padding: 0 !important; display: block !important; text-align: left; }
body.m-ativo #results-tbody > tr:has(> td.col-acoes) > td::before { display: none !important; }
body.m-ativo #results-tbody > tr:has(> td.col-acoes) > td:nth-child(1) { grid-column: 1; grid-row: 1; }
body.m-ativo #results-tbody > tr:has(> td.col-acoes) > td:nth-child(2) { grid-column: 2; grid-row: 1; font-weight: 800; font-size: 0.95rem; }
body.m-ativo #results-tbody > tr:has(> td.col-acoes) > td:nth-child(6) { grid-column: 3; grid-row: 1; }
body.m-ativo #results-tbody > tr:has(> td.col-acoes) > td:nth-child(3) { grid-column: 1 / -1; grid-row: 2; font-family: var(--font-mono); font-size: 0.8rem; color: #cbd5e1; overflow-wrap: anywhere; }
body.m-ativo #results-tbody > tr:has(> td.col-acoes) > td:nth-child(4) { grid-column: 1 / 3; grid-row: 3; font-size: 0.75rem; color: #94a3b8; }
body.m-ativo #results-tbody > tr:has(> td.col-acoes) > td:nth-child(5) { display: none !important; }
body.m-ativo #results-tbody > tr:has(> td.col-acoes) > td.col-acoes { grid-column: 3; grid-row: 3; display: flex !important; justify-content: flex-end; }
body.m-ativo #results-tbody > tr:has(> td.col-acoes) > td.col-acoes button { min-width: 36px !important; min-height: 36px !important; }

/* ---- Caixa de busca: campo + botao; opcoes em chips que quebram linha */
body.m-ativo .search-section .search-actions > div:first-child {
    flex-wrap: wrap !important; overflow: visible !important; row-gap: 0.35rem !important; column-gap: 0.35rem !important;
}
body.m-ativo .search-section .search-actions > div:first-child > div:last-child { flex-wrap: nowrap; }
body.m-ativo #pn-input::placeholder { font-size: 0.9rem; color: #64748b; }
body.m-ativo #pn-input { line-height: 1.35; }
body.m-ativo[data-m-aba="sourcing"] .main-content { padding-bottom: calc(var(--m-barra-h) + var(--m-seguro) + 150px) !important; }

/* ---- Database: acoes em grade 2 colunas (nada fora da tela) */
body.m-ativo #database-tab > .glass-panel { padding: 0.85rem !important; }
body.m-ativo #database-tab > .glass-panel > div:first-child { flex-direction: column !important; align-items: stretch !important; gap: 0.6rem !important; margin-bottom: 0.8rem !important; }
body.m-ativo #database-tab div:has(> #import-db-btn) {
    display: grid !important; grid-template-columns: 1fr 1fr; gap: 0.45rem !important; overflow: visible !important; width: 100%;
}
body.m-ativo #database-tab div:has(> #import-db-btn) > .modern-btn {
    width: 100% !important; min-height: 42px !important; padding: 0.45rem 0.5rem !important; font-size: 0.78rem !important;
    justify-content: center; white-space: normal; line-height: 1.15; box-shadow: none !important;
}
body.m-ativo #database-tab div:has(> #import-db-btn) > .modern-btn:last-child:nth-child(odd) { grid-column: 1 / -1; }

/* ---- Cartoes genericos: valor nunca passa da borda */
body.m-ativo table.m-cartoes td { flex-wrap: wrap; }
body.m-ativo table.m-cartoes td[data-label] > * { max-width: 62%; overflow-wrap: anywhere; white-space: normal !important; }
body.m-ativo table.m-cartoes td[data-label] { overflow-wrap: anywhere; }
body.m-ativo table.m-cartoes td[data-label]::before { max-width: 38%; }

/* ---- Vendas */
body.m-ativo #vendas-tab > div:first-child { flex-direction: row !important; align-items: center !important; flex-wrap: nowrap !important; }
body.m-ativo #vendas-tab > div:first-child h1 { font-size: 1.3rem !important; white-space: nowrap; }
body.m-ativo #vendas-tab > div:first-child > div:last-child { flex: 0 0 auto; gap: 0.35rem !important; }
body.m-ativo #vendas-new-deal-btn { padding: 0.45rem 0.7rem !important; font-size: 0.8rem !important; }
body.m-ativo #vendas-refresh-btn, body.m-ativo #vendas-dev-btn { width: 40px !important; padding: 0 !important; justify-content: center; }
body.m-ativo #vendas-chips { display: grid !important; grid-template-columns: 1fr 1fr; gap: 0.45rem; overflow: visible !important; }
body.m-ativo #vendas-chips .vendas-chip { width: 100%; justify-content: center; min-height: 40px; }
body.m-ativo .vendas-cards-grid { grid-template-columns: 1fr 1fr !important; gap: 0.5rem !important; }
body.m-ativo .vendas-card { padding: 0.6rem 0.7rem !important; min-width: 0; }
body.m-ativo .vendas-card-titulo { font-size: 0.66rem !important; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
body.m-ativo .vendas-card-valor { font-size: 1.5rem !important; }
body.m-ativo #vendas-tabela-wrap .glass-panel:first-child { padding: 0.7rem !important; }
body.m-ativo #vendas-tabela-body td:first-child { flex-wrap: wrap; gap: 0.25rem; justify-content: flex-start; }
body.m-ativo #vendas-tabela-body td:first-child > * { flex: 0 0 auto; }
body.m-ativo #vendas-tabela-body td[data-label="Status"] > div { flex-wrap: wrap !important; gap: 6px !important; justify-content: flex-end; }

/* ---- Abas internas (Portais, Cadastros): segmentos que quebram linha */
body.m-ativo #websites-tab .portal-tab-btn { flex: 1 1 calc(33% - 0.4rem) !important; min-width: 0 !important; overflow: hidden; text-overflow: ellipsis; padding: 0.5rem 0.4rem !important; font-size: 0.78rem !important; justify-content: center; }
body.m-ativo #websites-tab div:has(> .portal-tab-btn) { flex-wrap: wrap !important; overflow: visible !important; gap: 0.35rem !important; }
body.m-ativo #cadastros-tab div:has(> .cad-subtab) { overflow: visible !important; flex-wrap: wrap !important; }
body.m-ativo #cadastros-tab .cad-subtab { flex: 1 1 calc(50% - 0.5rem) !important; justify-content: center; }
body.m-ativo #cadastros-tab > div:first-child { flex-direction: row !important; align-items: center !important; }

/* ---- v3: acabamento da busca --------------------------------------------- */
/* Selos (status) nunca quebram no meio da palavra. */
body.m-ativo .meta-pill,
body.m-ativo #results-tbody td:nth-child(6) span { white-space: nowrap !important; word-break: keep-all; }
/* Titulo curto, controles na mesma linha. */
body.m-ativo #sourcing-tab .section-header h3 { font-size: 0 !important; }
body.m-ativo #sourcing-tab .section-header h3::after { content: 'Histórico'; font-size: 1.15rem; font-weight: 800; }
/* Contador dentro do campo (canto), como o limite de caracteres do iOS. */
body.m-ativo .search-section { position: fixed; }
body.m-ativo #pn-counter {
    position: absolute; top: 0.95rem; right: 4.3rem; z-index: 2; font-size: 0.62rem !important;
    color: #64748b; pointer-events: none; background: rgba(15, 23, 42, 0.85); padding: 0 4px; border-radius: 4px;
}
body.m-ativo #pn-input { padding-right: 3.2rem !important; }
/* Opcoes numa linha: Portais | [x] Enviar RFQ | Fornecedores (n) */
body.m-ativo .search-section .search-actions > div:first-child { flex-wrap: nowrap !important; }
body.m-ativo .search-section .search-actions > div:first-child > div:last-child { flex: 1 1 auto; min-width: 0; justify-content: space-between; }
body.m-ativo .search-section .search-actions > div:first-child > div:last-child label { font-size: 0 !important; gap: 0.35rem !important; }
body.m-ativo .search-section .search-actions > div:first-child > div:last-child label::after { content: 'Enviar RFQ'; font-size: 0.74rem; color: #cbd5e1; }
body.m-ativo .search-section .search-actions > div:first-child > div:last-child label input { width: 18px !important; height: 18px !important; }
body.m-ativo #btn-select-rfq-vendors { white-space: nowrap; }
body.m-ativo .search-section .ps-badge-texto { font-size: 0.74rem; }

body.m-ativo #sourcing-tab .section-header { flex-direction: row !important; align-items: center !important; }
body.m-ativo #sourcing-tab .section-header > div { width: auto !important; }
body.m-ativo #sourcing-tab .section-header h3 { width: auto !important; }
/* Lista (tabela) sem a moldura de vidro em volta: os cartoes ja sao a moldura. */
body.m-ativo .modern-table-container.glass-panel { padding: 0 !important; background: transparent !important; border: none !important; box-shadow: none !important; backdrop-filter: none !important; }

/* ---- v4: vitrine com largura cheia e texto que quebra entre palavras ------ */
/* Molduras aninhadas (linha aberta > PN > caixa da tabela > grade) somavam
   ~60px de margem e deixavam o cartao com 120px. Fica so uma margem. */
body.m-ativo #results-tbody > tr.expandable-content-row { padding: 0 !important; background: transparent !important; border: none !important; }
body.m-ativo #results-tbody > tr.expandable-content-row > td { padding: 0 !important; background: transparent !important; }
body.m-ativo .expanded-inner-content { padding: 0 !important; background: transparent !important; gap: 0.6rem !important; }
body.m-ativo .pn-group { padding: 0.6rem 0 !important; border: none !important; background: transparent !important; }
body.m-ativo .pn-group .sourcing-container { margin-top: 0.5rem !important; }
body.m-ativo .sourcing-container > div { border: none !important; background: transparent !important; border-radius: 0 !important; }
body.m-ativo table.m-vitrine tbody { padding: 0.45rem 0 0 !important; gap: 0.45rem !important; }
body.m-ativo .vendor-barra { padding: 0 !important; background: transparent !important; border: none !important; }
body.m-ativo .pn-title { font-size: 1.05rem !important; font-weight: 800; padding: 0 0.1rem; }
body.m-ativo .busca-export-barra { border-radius: 12px; border: 1px solid var(--m-borda) !important; }

/* Celulas da linha do historico sem fundo proprio (o cartao ja tem). */
body.m-ativo #results-tbody > tr > td { background: transparent !important; box-shadow: none !important; border: none !important; }

/* Nome do fornecedor: quebra entre palavras, nunca no meio ("Propone nt"). */
body.m-ativo table.m-vitrine td,
body.m-ativo table.m-vitrine td * { overflow-wrap: break-word !important; word-break: normal !important; hyphens: auto; }
body.m-ativo table.m-vitrine td:nth-child(1) strong { font-size: 0.8rem; }
body.m-ativo table.m-vitrine td:nth-child(1) > div:not(:first-child) {
    white-space: nowrap !important; overflow: hidden !important; text-overflow: ellipsis !important; font-size: 0.66rem !important;
}
body.m-ativo table.m-vitrine td:nth-child(2) .meta-pill { white-space: nowrap !important; }

body.m-ativo table.m-vitrine td:nth-child(1) { font-family: var(--font-main, Inter, system-ui, sans-serif) !important; letter-spacing: -0.01em; }

/* ---- v5: Vendas sem nada fora da tela */
body.m-ativo #vendas-tab > div:first-child { flex-direction: column !important; align-items: stretch !important; gap: 0.6rem !important; }
body.m-ativo #vendas-tab > div:first-child h1 { white-space: normal; }
body.m-ativo #vendas-tab > div:first-child > div:last-child { display: grid !important; grid-template-columns: 1fr 44px 44px; gap: 0.45rem !important; width: 100%; }
body.m-ativo #vendas-new-deal-btn { width: 100% !important; justify-content: center; min-height: 44px !important; font-size: 0.9rem !important; }
body.m-ativo #vendas-refresh-btn, body.m-ativo #vendas-dev-btn { width: 44px !important; min-height: 44px !important; }
body.m-ativo #vendas-tabela-wrap div:has(> #vendas-data-de) { grid-template-columns: 1fr 1fr auto !important; }
body.m-ativo #vendas-data-de { grid-column: 1; grid-row: 1; }
body.m-ativo #vendas-data-ate { grid-column: 2; grid-row: 1; }
body.m-ativo #vendas-fechar-tabela-btn { grid-column: 3; grid-row: 1; width: 44px !important; }
body.m-ativo #vendas-busca { grid-column: 1 / 3 !important; grid-row: 2; order: 0 !important; }
body.m-ativo #vendas-limpar-btn { grid-column: 3; grid-row: 2; padding: 0 0.6rem !important; }
body.m-ativo #vendas-data-de, body.m-ativo #vendas-data-ate { font-size: 14px !important; padding: 0.4rem !important; }

body.m-ativo #websites-tab .portal-tab-btn { white-space: normal !important; line-height: 1.15; text-align: center; min-height: 44px !important; }

/* =============================================================================
   v6 -- tipografia de app e menu lateral de ponta a ponta
   ========================================================================== */

/* Escala de texto de app (Mercado Livre/iOS: corpo ~14px, secundario ~12px).
   Tudo que e medido em rem encolhe junto. Campos de digitacao continuam com
   16px (px, nao rem): abaixo disso o iPhone da zoom sozinho ao tocar. */
html { font-size: 14px; }
body.m-ativo { font-size: 14px; line-height: 1.4; }
body.m-ativo .tab-content h1,
body.m-ativo .tab-content > .glass-panel:first-child h2,
body.m-ativo .tab-content .glass-panel:first-child > div:first-child h2 { font-size: 1.3rem !important; }
body.m-ativo .modern-btn { font-size: 0.9rem; }
body.m-ativo #sidebar-title::after { font-size: 1.05rem; }

/* ---- Menu lateral ("Mais"): altura inteira da tela, acima de tudo --------
   O cabecalho que o contem tinha backdrop-filter; isso faz um elemento
   position:fixed se medir pelo cabecalho, nao pela tela -- e o menu parava
   no meio. Sem o filtro ali, ele ocupa a tela de cima a baixo. */
body.m-ativo .app-sidebar,
body.m-ativo .app-sidebar.glass-panel {
    backdrop-filter: none !important; -webkit-backdrop-filter: none !important;
    transform: none !important; filter: none !important; overflow: visible !important;
    padding: 0 !important; border-radius: 0 !important;
}
body.m-ativo .sidebar-header { backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); }
body.m-ativo #mobile-menu-overlay { position: fixed !important; inset: 0 !important; z-index: 190 !important; }
body.m-ativo .sidebar-content {
    position: fixed !important; top: 0 !important; bottom: 0 !important; left: -100%;
    height: 100vh !important; height: 100dvh !important; max-height: none !important;
    width: min(84vw, 320px) !important; max-width: 320px !important;
    z-index: 200 !important; overflow-y: auto !important; overscroll-behavior: contain;
    padding: calc(env(safe-area-inset-top, 0px) + 1rem) 0.75rem calc(env(safe-area-inset-bottom, 0px) + 1rem) !important;
    background: #0f172a !important; display: flex !important; flex-direction: column !important;
    justify-content: flex-start !important; gap: 0 !important;
}
body.m-ativo .sidebar-content.mobile-open { left: 0 !important; }
/* Itens compactos, como a lista de categorias do Mercado Livre. */
body.m-ativo .sidebar-content .nav-menu { gap: 2px !important; margin-bottom: 0.75rem !important; }
body.m-ativo .sidebar-content .nav-btn {
    min-height: 44px !important; padding: 0.55rem 0.8rem !important; font-size: 0.95rem !important;
    margin: 0 !important; border-radius: 10px !important; border-left: none !important; gap: 0.7rem !important;
}
body.m-ativo .sidebar-content .nav-btn > span:first-child { width: 1.4rem; text-align: center; font-size: 1.05rem; }
body.m-ativo .sidebar-content .nav-btn.active { background: rgba(59, 130, 246, 0.16) !important; color: #93c5fd !important; }
body.m-ativo .sidebar-content .bottom-actions { margin-top: auto !important; padding-top: 0.75rem; border-top: 1px solid var(--m-borda); }
body.m-ativo .sidebar-content .user-profile { margin: 0 0 0.6rem !important; font-size: 0.8rem; color: #94a3b8; overflow-wrap: anywhere; }
body.m-ativo .sidebar-content .sidebar-actions { gap: 0.4rem !important; }
body.m-ativo .sidebar-content .sidebar-actions .modern-btn { min-height: 42px !important; padding: 0.5rem 0.8rem !important; font-size: 0.88rem !important; }
body.m-ativo .sidebar-content #api-status-badge { margin-bottom: 0.4rem !important; font-size: 0.75rem; }

/* ---- Vendas: datas com espaco inteiro (o X vai para o canto do painel) -- */
body.m-ativo #vendas-tabela-wrap > .glass-panel:first-child { position: relative; padding-right: 3.2rem !important; }
body.m-ativo #vendas-fechar-tabela-btn {
    position: absolute; top: 0.45rem; right: 0.45rem; width: 36px !important; height: 36px; min-height: 36px !important; padding: 0 !important;
}
body.m-ativo #vendas-tabela-wrap > .glass-panel:first-child > div:last-child {
    display: grid !important; grid-template-columns: 1fr 1fr !important; gap: 0.45rem !important; width: 100%;
}
body.m-ativo #vendas-tabela-wrap > .glass-panel:first-child { padding-right: 0.7rem !important; }
body.m-ativo #vendas-tabela-wrap > .glass-panel:first-child > div:first-child { padding-right: 2.6rem; }
body.m-ativo #vendas-data-de, body.m-ativo #vendas-data-ate {
    grid-row: 1 !important; width: 100% !important; min-width: 0 !important; font-size: 15px !important;
    padding: 0.45rem 0.5rem !important; min-height: 42px;
}
body.m-ativo #vendas-data-de { grid-column: 1 !important; }
body.m-ativo #vendas-data-ate { grid-column: 2 !important; }
body.m-ativo #vendas-busca { grid-column: 1 / -1 !important; grid-row: 2 !important; }
body.m-ativo #vendas-limpar-btn { grid-column: 1 / -1 !important; grid-row: 3 !important; width: 100% !important; min-height: 40px !important; }

/* Caixas de selecao do tamanho do dedo (iOS: alvo minimo ~44pt; a caixa em si 22px). */
body.m-ativo input[type=checkbox] { width: 22px !important; height: 22px !important; min-width: 22px; accent-color: #3b82f6; }
body.m-ativo #db-quotes-body td:first-child:not(.m-titulo) { padding: 0.2rem !important; }
body.m-ativo label:has(> input[type=checkbox]) { min-height: 36px; display: inline-flex; align-items: center; }

/* O cabecalho (que contem o menu) cria uma camada propria; ela precisa ficar
   acima da barra inferior, senao a barra aparece por cima do menu aberto. */
body.m-ativo .app-sidebar { z-index: 150 !important; }
/* Vendas: linha do titulo com a altura do X, para o X nao encostar nas datas. */
body.m-ativo #vendas-tabela-wrap > .glass-panel:first-child > div:first-child { min-height: 36px; align-items: center; }
body.m-ativo input[type=checkbox] { width: 24px !important; height: 24px !important; min-width: 24px; }

/* =============================================================================
   v7 -- IA Sourcing como app de compras
   1) Busca no topo (barra de busca do Mercado Livre), nao mais flutuando.
   2) Resumo numa faixa fina de 4 numeros.
   3) Historico em cartoes limpos, inteiros tocaveis.
   4) Resultados em tela cheia com "Voltar".
   ========================================================================== */

/* 1. Ordem da tela: busca, resumo, historico. */
body.m-ativo #sourcing-tab:not(.hidden) { display: flex !important; flex-direction: column !important; gap: 0.75rem !important; }
body.m-ativo #sourcing-tab > .search-section { order: -3; }
body.m-ativo #sourcing-tab > .dashboard-section { order: -2; }
body.m-ativo .search-section.sticky-bottom {
    position: static !important; bottom: auto !important; margin: 0 !important;
    border-radius: 16px !important; box-shadow: none !important;
    border: 1px solid var(--m-borda) !important; background: rgba(30, 41, 59, 0.6) !important;
    padding: 0.7rem !important; z-index: auto !important;
}
body.m-ativo[data-m-aba="sourcing"] .main-content { padding-bottom: calc(var(--m-barra-h) + var(--m-seguro) + 1rem) !important; }
body.m-ativo #pn-input { height: 46px; min-height: 46px !important; max-height: 46px; border-radius: 12px; }
body.m-ativo #pn-input:focus { height: 110px; max-height: 110px; }
body.m-ativo #search-btn { height: 46px; width: 50px !important; }
body.m-ativo #pn-counter { top: 1.3rem; }

/* 2. Resumo: 4 numeros numa linha fina. */
body.m-ativo .dashboard-stats { grid-template-columns: repeat(4, 1fr) !important; gap: 0.35rem !important; }
body.m-ativo .dashboard-stats > .stat-card {
    padding: 0.45rem 0.35rem !important; text-align: center; border-radius: 12px !important;
    display: flex !important; flex-direction: column-reverse; gap: 2px; align-items: center;
}
body.m-ativo .dashboard-stats .stat-value { font-size: 1.1rem !important; line-height: 1.1; }
body.m-ativo .dashboard-stats .stat-title {
    font-size: 0.56rem !important; line-height: 1.15; text-transform: uppercase; letter-spacing: 0.02em;
    white-space: normal !important; overflow-wrap: normal; word-break: normal; hyphens: auto;
}

/* 3. Historico: cartoes limpos e inteiros tocaveis. */
body.m-ativo #sourcing-tab .glass-panel:has(#pagination-container) {
    background: transparent !important; border: none !important; box-shadow: none !important; padding: 0.1rem 0.1rem 0 !important;
}
body.m-ativo #results-tbody > tr:not(.expandable-content-row):has(> td.col-acoes) {
    grid-template-columns: minmax(0, 1fr) auto !important; grid-template-rows: auto auto auto;
    column-gap: 0.6rem !important; row-gap: 0.35rem !important; padding: 0.8rem 0.9rem !important;
    cursor: pointer; border-radius: 14px !important; position: relative;
    -webkit-tap-highlight-color: rgba(59, 130, 246, 0.15);
}
body.m-ativo #results-tbody > tr:not(.expandable-content-row):has(> td.col-acoes):active { background: rgba(59, 130, 246, 0.1) !important; }
/* o botao ▶ some: o cartao inteiro abre */
body.m-ativo #results-tbody > tr:has(> td.col-acoes) > td:nth-child(1) { display: none !important; }
/* linha 1: ID ........ status */
body.m-ativo #results-tbody > tr:has(> td.col-acoes) > td:nth-child(2) {
    grid-column: 1 !important; grid-row: 1 !important; font-size: 1rem !important; max-width: none !important;
    white-space: nowrap; overflow: hidden !important; text-overflow: ellipsis;
}
body.m-ativo #results-tbody > tr:has(> td.col-acoes) > td.status-cell {
    grid-column: 2 !important; grid-row: 1 !important; overflow: visible !important; justify-self: end;
}
body.m-ativo #results-tbody td.status-cell .meta-pill {
    display: inline-block !important; white-space: nowrap !important; font-size: 0.72rem !important;
    padding: 3px 10px !important; border-radius: 999px !important; max-width: none !important;
}
/* em andamento: a barra de progresso ganha a linha inteira */
body.m-ativo #results-tbody > tr:has(> td.col-acoes) > td.status-cell:has(.search-progress-container) {
    grid-column: 1 / -1 !important; grid-row: 4 !important; justify-self: stretch;
}
body.m-ativo #results-tbody .search-progress-container { max-width: none !important; min-width: 0 !important; }
/* linha 2: PNs em ate 2 linhas */
body.m-ativo #results-tbody > tr:has(> td.col-acoes) > td.pn-preview {
    grid-column: 1 / -1 !important; grid-row: 2 !important; max-width: none !important;
    white-space: normal !important; display: -webkit-box !important; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
    overflow: hidden !important; font-size: 0.82rem !important; line-height: 1.35; color: #cbd5e1 !important; word-break: break-word;
}
/* linha 3: data ........ lixeira  › */
body.m-ativo #results-tbody > tr:has(> td.col-acoes) > td:nth-child(4) {
    grid-column: 1 !important; grid-row: 3 !important; font-size: 0.74rem !important; color: #94a3b8 !important;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
body.m-ativo #results-tbody > tr:has(> td.col-acoes) > td.col-acoes {
    grid-column: 2 !important; grid-row: 3 !important; gap: 0.2rem; align-items: center;
}
body.m-ativo #results-tbody > tr:has(> td.col-acoes) > td.col-acoes::after {
    content: 'Abrir ›'; display: inline-block !important; font-size: 0.78rem; font-weight: 700; color: #60a5fa; margin-left: 0.35rem;
}
body.m-ativo #results-tbody .delete-search-btn { font-size: 0.95rem !important; min-width: 34px !important; min-height: 34px !important; opacity: 0.75; }
/* Com a busca aberta em tela cheia, o cartao dela fica marcado. */
body.m-ativo #results-tbody > tr.row-expanded { border-color: rgba(59, 130, 246, 0.5) !important; }

/* 4. Resultados em tela cheia. */
#m-res-topo { display: none; }
body.m-ativo.m-res-aberto #m-res-topo {
    display: flex; align-items: center; gap: 0.4rem; position: fixed; top: 0; left: 0; right: 0; z-index: 160;
    height: calc(52px + env(safe-area-inset-top, 0px)); padding: env(safe-area-inset-top, 0px) 0.6rem 0 0.2rem;
    background: #0f172a; border-bottom: 1px solid var(--m-borda);
}
#m-res-voltar {
    width: 44px; height: 44px; border: none; background: transparent; color: #e2e8f0;
    font-size: 2rem; line-height: 1; padding: 0; cursor: pointer; flex: none;
}
.m-res-textos { display: flex; flex-direction: column; min-width: 0; }
.m-res-textos strong { font-size: 1rem; color: #f1f5f9; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.m-res-textos span { font-size: 0.72rem; color: #94a3b8; }
body.m-ativo #results-tbody > tr.expandable-content-row.open.m-folha {
    display: block !important; position: fixed !important; z-index: 155;
    top: calc(52px + env(safe-area-inset-top, 0px)); left: 0; right: 0;
    bottom: calc(var(--m-barra-h) + var(--m-seguro));
    overflow-y: auto !important; -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
    background: #0b1220 !important; border: none !important; border-radius: 0 !important;
    margin: 0 !important; padding: 0.6rem 12px 1.2rem !important;
}
body.m-ativo.m-res-aberto { overflow: hidden; }
/* Cada PN como uma secao: titulo, descricao e botao de RFQ discretos. */
body.m-ativo .m-folha .pn-group { border-bottom: 1px solid var(--m-borda) !important; padding: 0.8rem 0 1rem !important; }
body.m-ativo .m-folha .pn-group > div:first-child { flex-direction: column !important; align-items: stretch !important; gap: 0.4rem !important; }
body.m-ativo .m-folha .pn-title { font-size: 1.1rem !important; color: #f1f5f9 !important; font-family: var(--font-mono); }
body.m-ativo .m-folha .gemini-desc { font-size: 0.8rem !important; color: #94a3b8; padding: 0 !important; border: none !important; background: none !important; }
body.m-ativo .m-folha .pn-group .modern-btn { min-height: 38px !important; font-size: 0.8rem !important; padding: 0.4rem 0.7rem !important; }

/* =============================================================================
   v8 -- sem barra de cima: a navegacao e so a barra de baixo (como Instagram,
   Mercado Livre e bancos). O menu "Mais" continua abrindo pela barra de baixo.
   ========================================================================== */
body.m-ativo .sidebar-header { display: none !important; }
body.m-ativo .app-sidebar { position: static !important; height: 0 !important; min-height: 0 !important; margin: 0 !important; border: none !important; }
body.m-ativo .main-content { padding-top: calc(env(safe-area-inset-top, 0px) + 12px) !important; }
/* O chat aberto e a tela de resultados usam a altura que era do topo. */
body.m-ativo .m-chat.m-chat-aberto { height: calc(100dvh - env(safe-area-inset-top, 0px) - var(--m-barra-h) - var(--m-seguro) - 24px) !important; }

/* =============================================================================
   v9 -- filtros do dashboard de vendas no celular: grade de 2 colunas
   ========================================================================== */
body.m-ativo .dv-filtros { display: grid !important; grid-template-columns: 1fr 1fr; gap: 0.5rem !important; overflow: visible !important; padding: 0.7rem !important; }
body.m-ativo .dv-filtro .modern-input { width: 100% !important; min-width: 0; }
body.m-ativo .dv-filtro-vendedor { grid-column: 1 / -1; }
body.m-ativo .dv-filtro-btn { width: 100%; padding: 0 0.4rem !important; font-size: 0.8rem !important; }
body.m-ativo #dv-aplicar { grid-column: 1 / -1; }
body.m-ativo .dv-filtro-msg { grid-column: 1 / -1; margin: 0; white-space: normal; }

/* v9 -- estrela e chat de dados no celular: acima da barra de baixo, chat em tela cheia */
body.m-ativo #ia-dados-fab { right: 14px; bottom: calc(var(--m-barra-h) + var(--m-seguro) + 14px); width: 58px; height: 58px; }
body.m-ativo #ia-dados-fab.aberto { display: none; }
body.m-ativo #ia-dados-pop {
    left: 0; right: 0; top: 0; width: 100%; height: auto; border-radius: 0; border: none;
    bottom: calc(var(--m-barra-h) + var(--m-seguro)); padding-top: env(safe-area-inset-top, 0px); z-index: 170;
}
body.m-ativo .ia-pop-entrada textarea { font-size: 16px; }
body.m-ativo #ia-dados-expandir { display: none; }

/* =============================================================================
   v10 -- cartao de cotacao no celular + campos de data + area segura
   Tudo aqui vale so com body.m-ativo (celular); o PC nao muda.
   ========================================================================== */

/* 1. Area segura: no app instalado no iPhone a barra de status fica POR CIMA
      da pagina (black-translucent + viewport-fit=cover). Modal colado no topo
      tinha o ✕ embaixo do relogio/entalhe, sem como tocar. */
body.m-ativo .modal-content {
    padding-top: calc(env(safe-area-inset-top, 0px) + 1rem) !important;
    padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 1rem) !important;
}

/* 2. Campos de data. No Safari do iPhone o campo de data tem largura minima
      propria e ignora a da caixa -- por isso "comia" o espaco do vizinho.
      Aparencia nativa desligada + largura da caixa + texto a esquerda. */
body.m-ativo input[type="date"],
body.m-ativo input[type="datetime-local"],
body.m-ativo input[type="month"],
body.m-ativo input[type="time"] {
    -webkit-appearance: none !important; appearance: none !important;
    display: block !important; box-sizing: border-box !important;
    width: 100% !important; min-width: 0 !important; max-width: 100% !important;
    height: 44px !important; min-height: 44px !important; line-height: 44px;
    padding: 0 0.7rem !important; margin: 0 !important;
    font-size: 16px !important; text-align: left !important; color-scheme: dark;
}
body.m-ativo input[type="date"]::-webkit-date-and-time-value,
body.m-ativo input[type="datetime-local"]::-webkit-date-and-time-value { text-align: left; margin: 0; min-height: 1.2em; }
body.m-ativo input[type="date"]::-webkit-datetime-edit,
body.m-ativo input[type="datetime-local"]::-webkit-datetime-edit { padding: 0; }
body.m-ativo input[type="date"]::-webkit-calendar-picker-indicator { margin-left: auto; padding: 0; opacity: 0.8; }
/* quem segura o campo tambem precisa poder encolher (seletores diretos:
   um "*:has(...)" aqui obrigava o navegador a reavaliar a pagina inteira) */
body.m-ativo .input-group, body.m-ativo .dv-filtro { min-width: 0 !important; max-width: 100%; }
/* pares "de / ate" lado a lado, cada um com metade */
body.m-ativo #vendas-tabela-wrap div:has(> #vendas-data-de) > input[type="date"] { width: 100% !important; }

/* 3. Cartao de cotacao (Vendas) em tela cheia, no jeito de app:
      topo fixo com ✕ grande, etapas numa linha, abas que rolam de lado,
      conteudo com uma rolagem so e rodape fixo com as acoes. */
body.m-ativo #crm-quote-modal .cq-caixa {
    padding: 0 !important; gap: 0 !important; height: 100dvh !important; max-height: 100dvh !important;
    display: flex !important; flex-direction: column !important; overflow: hidden !important;
    background: #0b1220 !important;
}
body.m-ativo #crm-quote-modal .cq-topo {
    position: relative; margin: 0 !important; gap: 0.6rem !important; align-items: center !important;
    padding: calc(env(safe-area-inset-top, 0px) + 0.55rem) 0.6rem 0.55rem 0.9rem !important;
    background: #0f172a; border-bottom: 1px solid rgba(148, 163, 184, 0.14);
}
body.m-ativo #crm-quote-modal .cq-titulo {
    font-size: 1rem !important; line-height: 1.3 !important; margin: 0 !important;
    white-space: normal !important; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
body.m-ativo #crm-quote-modal .cq-subtitulo {
    font-size: 0.74rem !important; margin: 0.15rem 0 0 !important;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
body.m-ativo #crm-quote-modal .cq-fechar {
    width: 44px !important; height: 44px !important; min-width: 44px; padding: 0 !important;
    border-radius: 50% !important; font-size: 1.15rem !important; display: flex; align-items: center; justify-content: center;
    background: rgba(148, 163, 184, 0.16) !important; border: none !important; color: #f1f5f9 !important;
}

/* etapas: uma linha, do jeito de rastreio de entrega */
body.m-ativo #crm-quote-modal .crm-passos {
    display: grid !important; grid-template-columns: repeat(6, minmax(0, 1fr)) !important;
    gap: 0 !important; margin: 0 !important; padding: 0.6rem 0.4rem 0.5rem !important;
    background: #0f172a; border-bottom: 1px solid rgba(148, 163, 184, 0.1);
}
body.m-ativo #crm-quote-modal .crm-passo { gap: 0.2rem !important; min-width: 0; }
body.m-ativo #crm-quote-modal .crm-passo-rotulo {
    font-size: 0.56rem !important; white-space: normal !important; text-align: center; line-height: 1.15;
    min-height: 1.3em; order: 2;
}
body.m-ativo #crm-quote-modal .crm-passo-bola { order: 1; }
body.m-ativo #crm-quote-modal .crm-passo-data { display: none !important; }
body.m-ativo #crm-quote-modal .crm-passo.atual .crm-passo-data {
    display: block !important; order: 3; font-size: 0.52rem !important; white-space: normal; text-align: center;
}

/* abas: quebram em duas linhas em vez de esconder "Linhas" fora da tela */
body.m-ativo #crm-quote-modal .cq-abas {
    flex-wrap: wrap !important; overflow: visible; margin: 0 !important;
    padding: 0.55rem 0.75rem !important; gap: 0.4rem !important; flex: none;
    border-bottom: 1px solid rgba(148, 163, 184, 0.1);
}
body.m-ativo #crm-quote-modal .cq-abas::-webkit-scrollbar { display: none; }
body.m-ativo #crm-quote-modal .cq-abas .modern-btn,
body.m-ativo #crm-quote-modal .cq-abas a.modern-btn {
    flex: 0 0 auto !important; width: auto !important; white-space: nowrap;
    padding: 0.4rem 0.8rem !important; font-size: 0.8rem !important; min-height: 36px !important; border-radius: 999px !important;
}
body.m-ativo #crm-quote-modal .cq-abas-espaco { display: none; }
body.m-ativo #crm-quote-modal .cq-btn-linhas { margin-left: auto; }
/* data de criacao e so leitura: sem risco de zoom, cabe inteira menor */
body.m-ativo #crm-quote-modal #crm-quote-data { font-size: 0.8rem !important; padding: 0.5rem !important; text-overflow: ellipsis; }

/* conteudo: uma rolagem so */
body.m-ativo #crm-quote-modal .cq-corpo {
    flex: 1 1 auto; min-height: 0; overflow-y: auto !important; -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain; padding: 0.75rem 0.75rem 1rem !important;
}
body.m-ativo #crm-quote-modal .cq-grid {
    display: flex !important; flex-direction: column !important; gap: 0.75rem !important; height: auto !important;
}
body.m-ativo #crm-quote-modal .cq-cartao { padding: 0.8rem !important; border-radius: 14px !important; min-height: 0 !important; }
body.m-ativo #crm-quote-modal .cq-cartao-titulo { font-size: 0.72rem !important; margin-bottom: 0.55rem !important; }
body.m-ativo #crm-quote-modal .cq-campos { display: grid !important; grid-template-columns: 1fr 1fr !important; gap: 0.6rem !important; }
body.m-ativo #crm-quote-modal .cq-campos .cq-largo,
body.m-ativo #crm-quote-modal .cq-campos .input-group:has(#crm-quote-cliente),
body.m-ativo #crm-quote-modal .cq-campos .input-group:has(#crm-quote-vendedor) { grid-column: 1 / -1; }
body.m-ativo #crm-quote-modal .cq-campos .crm-lbl { font-size: 0.68rem !important; margin-bottom: 0.2rem !important; }
body.m-ativo #crm-quote-modal .cq-inp { min-height: 42px; font-size: 16px !important; padding: 0.5rem 0.65rem !important; }
body.m-ativo #crm-quote-modal .cq-nota-nova { flex-direction: row !important; }
body.m-ativo #crm-quote-modal .cq-nota-nova button { width: auto !important; padding: 0 0.9rem !important; }
body.m-ativo #crm-quote-modal .cq-area-linhas { min-height: 0 !important; }
body.m-ativo #crm-quote-modal .cq-linhas-cab { gap: 0.5rem !important; }
body.m-ativo #crm-quote-modal .cq-btn-abrir { width: 100% !important; min-height: 42px; order: 5; }
body.m-ativo #crm-quote-modal .cq-preview { max-height: 260px; overflow: auto; }
body.m-ativo #crm-quote-modal #crm-quote-painel-email iframe { min-height: 60vh !important; }

/* rodape fixo: excluir e config viram icones; Template e Submit dividem o resto */
body.m-ativo #crm-quote-modal .cq-rodape {
    margin: 0 !important; flex: none; display: grid !important;
    grid-template-columns: 44px 1fr; grid-template-areas: "msg msg" "del acoes";
    gap: 0.45rem 0.5rem !important; align-items: center;
    padding: 0.55rem 0.75rem calc(env(safe-area-inset-bottom, 0px) + 0.6rem) !important;
    background: #0f172a !important; border-top: 1px solid rgba(148, 163, 184, 0.16);
}
body.m-ativo #crm-quote-modal .cq-msg { grid-area: msg; white-space: normal !important; font-size: 0.76rem !important; }
body.m-ativo #crm-quote-modal .cq-msg:empty { display: none; }
body.m-ativo #crm-quote-modal #crm-quote-excluir {
    grid-area: del; width: 44px !important; height: 44px !important; min-height: 44px !important; padding: 0 !important;
    font-size: 0 !important; border-radius: 12px !important; display: flex; align-items: center; justify-content: center;
}
body.m-ativo #crm-quote-modal #crm-quote-excluir::before { content: '🗑'; font-size: 1.1rem; }
body.m-ativo #crm-quote-modal .cq-rodape-dir {
    grid-area: acoes; display: grid !important; grid-template-columns: 44px 1fr 1.15fr; gap: 0.45rem !important; min-width: 0;
}
body.m-ativo #crm-quote-modal .cq-rodape .modern-btn {
    min-height: 44px !important; height: 44px; padding: 0 0.5rem !important; font-size: 0.82rem !important;
    width: 100% !important; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border-radius: 12px !important;
}
body.m-ativo #crm-quote-modal #crm-quote-template-cfg { padding: 0 !important; }

/* 4. Linhas da cotacao (modal proprio) no mesmo padrao: topo fixo e ✕ grande */
body.m-ativo #crm-linhas-modal .cq-linhas-caixa {
    padding: 0 !important; height: 100dvh !important; max-height: 100dvh !important; width: 100% !important;
}
body.m-ativo #crm-linhas-modal .cq-topo {
    margin: 0 !important; align-items: center !important; gap: 0.6rem !important;
    padding: calc(env(safe-area-inset-top, 0px) + 0.55rem) 0.6rem 0.55rem 0.9rem !important;
    background: #0f172a; border-bottom: 1px solid rgba(148, 163, 184, 0.14);
}
body.m-ativo #crm-linhas-modal .cq-fechar {
    width: 44px !important; height: 44px !important; padding: 0 !important; border-radius: 50% !important;
    display: flex; align-items: center; justify-content: center; border: none !important;
    background: rgba(148, 163, 184, 0.16) !important; font-size: 1.15rem !important;
}

/* =============================================================================
   v11 -- cartao de cotacao (Vendas) e linhas da cotacao no celular
   So vale com body.m-ativo; o PC nao muda.
   ========================================================================== */

/* 1. Uma aba por vez. A v10 forcava o painel "Dados" a aparecer sempre
      (display:flex !important), entao E-mail e Notas abriam com os dados
      embaixo. Agora so o painel da aba escolhida aparece. */
body.m-ativo #crm-quote-modal .cq-grid { display: none !important; }
body.m-ativo #crm-quote-modal .cq-grid:not(.hidden) { display: flex !important; }
body.m-ativo #crm-quote-modal #crm-quote-painel-email.hidden,
body.m-ativo #crm-quote-modal #crm-quote-painel-notas.hidden { display: none !important; }

/* aba ativa bem marcada */
body.m-ativo #crm-quote-modal .crm-quote-aba.ativo {
    background: linear-gradient(135deg, #2563eb, #1d4ed8) !important; color: #fff !important; border-color: transparent !important;
}

/* E-mail: o e-mail ocupa a area toda, com rolagem propria */
body.m-ativo #crm-quote-modal #crm-quote-painel-email:not(.hidden) { height: auto !important; display: flex !important; flex-direction: column; }
body.m-ativo #crm-quote-modal #crm-quote-corpo-frame {
    width: 100% !important; min-height: 0 !important; height: calc(100dvh - 330px) !important;
    border-radius: 12px !important;
}

/* Notas: lista em cartoes */
body.m-ativo #crm-quote-modal #crm-quote-painel-notas:not(.hidden) { height: auto !important; }
body.m-ativo #crm-quote-modal #crm-quote-notas-lista > * {
    background: rgba(30, 41, 59, 0.6); border: 1px solid rgba(148, 163, 184, 0.14); border-radius: 12px; padding: 0.65rem 0.75rem;
}

/* resumo das linhas dentro de "Dados" */
body.m-ativo #crm-quote-modal .cq-kpis { gap: 0.35rem !important; }
body.m-ativo #crm-quote-modal .cq-preview { max-height: none !important; overflow: visible !important; }

/* 2. Janela das linhas: tela cheia, com topo, barra e rodape fixos e a
      lista rolando no meio. A regra geral "tabela sem rolagem" dos
      cartoes travava esta lista -- nao dava para rolar. */
body.m-ativo #crm-linhas-modal .cq-linhas-caixa {
    display: flex !important; flex-direction: column !important; overflow: hidden !important;
    background: #0b1220 !important; gap: 0 !important;
}
body.m-ativo #crm-linhas-modal .cq-titulo { font-size: 1rem !important; margin: 0 !important; }
body.m-ativo #crm-linhas-modal .cq-subtitulo { font-size: 0.74rem !important; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin: 0.15rem 0 0 !important; }

body.m-ativo #crm-linhas-modal .cq-linhas-barra {
    flex: none; margin: 0 !important; padding: 0.6rem 0.75rem !important; gap: 0.5rem !important;
    display: flex !important; flex-direction: column !important; align-items: stretch !important;
    border-bottom: 1px solid rgba(148, 163, 184, 0.12);
}
body.m-ativo #crm-linhas-modal .cq-linhas-barra-esq {
    display: grid !important; grid-template-columns: 1fr 1fr; gap: 0.45rem !important;
}
body.m-ativo #crm-linhas-modal .cq-linhas-barra .modern-btn {
    width: 100% !important; min-height: 40px !important; padding: 0 0.5rem !important; font-size: 0.8rem !important;
    justify-content: center; white-space: nowrap; border-radius: 10px !important;
}
body.m-ativo #crm-linhas-modal #crm-linhas-busca {
    width: 100% !important; min-height: 40px; font-size: 16px !important; border-radius: 10px !important;
}
body.m-ativo #crm-linhas-modal #crm-linhas-resumo {
    display: flex !important; flex-wrap: nowrap !important; overflow-x: auto; scrollbar-width: none; gap: 0.35rem !important;
}
body.m-ativo #crm-linhas-modal #crm-linhas-resumo > * { flex: 0 0 auto; }

body.m-ativo #crm-linhas-modal .cq-linhas-tabela-caixa {
    flex: 1 1 auto !important; min-height: 0 !important;
    overflow-y: auto !important; overflow-x: hidden !important;
    -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
    padding: 0.7rem 0.75rem 1rem !important;
}

/* cada linha vira um cartao: PN em destaque, acoes no topo, campos em
   duas colunas com o rotulo em cima; o resto fica em "Ver mais" */
body.m-ativo #crm-linhas-modal table.m-cartoes tbody { gap: 0.7rem !important; }
body.m-ativo #crm-linhas-modal table.m-cartoes tr {
    display: grid !important; grid-template-columns: 1fr 1fr; gap: 0.55rem 0.6rem;
    padding: 0.75rem !important; border-radius: 14px !important;
}
body.m-ativo #crm-linhas-modal table.m-cartoes tr:has(> td.m-cheia:only-child) { display: block !important; }
body.m-ativo #crm-linhas-modal table.m-cartoes td {
    display: flex !important; flex-direction: column !important; align-items: stretch !important; justify-content: flex-start !important;
    gap: 0.2rem !important; text-align: left !important; padding: 0 !important; min-width: 0;
    position: static !important; background: transparent !important; box-shadow: none !important; width: auto !important;
}
body.m-ativo #crm-linhas-modal table.m-cartoes td[data-label]::before {
    max-width: none !important; font-size: 0.64rem !important; margin: 0;
}
body.m-ativo #crm-linhas-modal table.m-cartoes td input.crm-cel,
body.m-ativo #crm-linhas-modal table.m-cartoes td select.crm-cel {
    width: 100% !important; max-width: 100% !important; min-width: 0 !important; box-sizing: border-box;
    min-height: 40px; font-size: 16px !important; text-align: left !important; border-radius: 9px;
}
body.m-ativo #crm-linhas-modal table.m-cartoes td input[type="checkbox"] {
    width: 24px !important; min-height: 24px; align-self: flex-start;
}
/* acoes (Database, duplicar, excluir) numa faixa no topo, a direita */
body.m-ativo #crm-linhas-modal table.m-cartoes td.cq-col-acoes {
    grid-column: 1 / -1; order: -2; flex-direction: row !important; justify-content: flex-end !important; gap: 0.4rem !important;
}
body.m-ativo #crm-linhas-modal table.m-cartoes td.cq-col-acoes::before { display: none !important; }
body.m-ativo #crm-linhas-modal .crm-linha-acao {
    width: 38px; height: 38px; border-radius: 10px; font-size: 1rem;
    background: rgba(148, 163, 184, 0.12); border: 1px solid rgba(148, 163, 184, 0.18);
}
/* PN ocupa a linha toda, em destaque */
body.m-ativo #crm-linhas-modal table.m-cartoes td.m-titulo { grid-column: 1 / -1; order: -1; }
body.m-ativo #crm-linhas-modal table.m-cartoes td.m-titulo input.crm-cel {
    font-size: 17px !important; font-weight: 700; font-family: var(--font-mono);
}
/* campos longos na linha inteira */
body.m-ativo #crm-linhas-modal table.m-cartoes td[data-label="Description"],
body.m-ativo #crm-linhas-modal table.m-cartoes td[data-label="Supplier"],
body.m-ativo #crm-linhas-modal table.m-cartoes td[data-label="Client"],
body.m-ativo #crm-linhas-modal table.m-cartoes td[data-label="Remarks"] { grid-column: 1 / -1; }
/* numeros sem caixa ficam como texto */
body.m-ativo #crm-linhas-modal table.m-cartoes td[data-label="Total $"],
body.m-ativo #crm-linhas-modal table.m-cartoes td[data-label="Qty found"],
body.m-ativo #crm-linhas-modal table.m-cartoes td[data-label="Date"] {
    font-size: 0.95rem !important; font-weight: 700; justify-content: flex-end !important;
}
/* "Ver mais": a linha toda, como botao */
body.m-ativo #crm-linhas-modal table.m-cartoes tr.m-expansivel td.m-sec { display: none !important; }
body.m-ativo #crm-linhas-modal table.m-cartoes tr.m-expansivel.m-aberto td.m-sec { display: flex !important; }
body.m-ativo #crm-linhas-modal table.m-cartoes tr.m-expansivel::after {
    grid-column: 1 / -1; order: 99; display: block; text-align: center; padding: 0.45rem 0 0.1rem;
    border-top: 1px solid rgba(148, 163, 184, 0.14); color: #60a5fa; font-weight: 600; font-size: 0.8rem;
}

/* rodape fixo: Voltar e Salvar dividindo a largura */
body.m-ativo #crm-linhas-modal .cq-rodape {
    flex: none; margin: 0 !important; display: grid !important; grid-template-columns: 1fr; gap: 0.4rem !important;
    padding: 0.55rem 0.75rem calc(env(safe-area-inset-bottom, 0px) + 0.6rem) !important;
    background: #0f172a !important; border-top: 1px solid rgba(148, 163, 184, 0.16);
}
body.m-ativo #crm-linhas-modal .cq-msg { white-space: normal !important; font-size: 0.76rem !important; }
body.m-ativo #crm-linhas-modal .cq-msg:empty { display: none; }
body.m-ativo #crm-linhas-modal .cq-rodape-dir { display: grid !important; grid-template-columns: 1fr 1.3fr; gap: 0.5rem !important; }
body.m-ativo #crm-linhas-modal .cq-rodape .modern-btn {
    width: 100% !important; min-width: 0 !important; min-height: 46px !important; font-size: 0.86rem !important; border-radius: 12px !important;
}

/* =============================================================================
   v12 -- linhas da cotacao no celular: lista enxuta + editor de tela cheia
   (a tabela de 28 colunas fica so no PC)
   ========================================================================== */
#m-linhas-lista, #m-linha-editor { display: none; }
body.m-ativo #crm-linhas-modal table.crm-linhas-tabela { display: none !important; }
body.m-ativo #m-linhas-lista { display: flex; flex-direction: column; gap: 0.6rem; }

/* cartao da lista: toque inteiro abre o editor */
body.m-ativo .m-ll-item {
    position: relative; display: flex; flex-direction: column; gap: 0.3rem; width: 100%;
    text-align: left; font: inherit; color: #e2e8f0; cursor: pointer;
    background: rgba(30, 41, 59, 0.72); border: 1px solid rgba(148, 163, 184, 0.16);
    border-radius: 14px; padding: 0.75rem 2rem 0.75rem 0.85rem;
    -webkit-tap-highlight-color: rgba(59, 130, 246, 0.15); transition: background 0.15s, transform 0.1s;
}
body.m-ativo .m-ll-item:active { background: rgba(59, 130, 246, 0.14); transform: scale(0.99); }
body.m-ativo .m-ll-item.novo { border-color: rgba(16, 185, 129, 0.45); }
body.m-ativo .m-ll-l1 { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
body.m-ativo .m-ll-pn {
    font-family: var(--font-mono); font-weight: 700; font-size: 1rem; color: #f8fafc;
    min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
body.m-ativo .m-ll-st { flex: none; font-size: 0.66rem; font-weight: 700; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
body.m-ativo .m-ll-st.ok, body.m-ativo .m-le-seg .ok.on { background: #064e3b; color: #6ee7b7; }
body.m-ativo .m-ll-st.meio, body.m-ativo .m-le-seg .meio.on { background: #4a3606; color: #fcd34d; }
body.m-ativo .m-ll-st.nao, body.m-ativo .m-le-seg .nao.on { background: #4c1d1d; color: #fca5a5; }
body.m-ativo .m-ll-st.neutro, body.m-ativo .m-le-seg .neutro.on { background: #1f2a40; color: #cbd5e1; }
body.m-ativo .m-ll-desc { font-size: 0.8rem; color: #94a3b8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
body.m-ativo .m-ll-preco { display: flex; justify-content: space-between; align-items: baseline; gap: 0.5rem; font-size: 0.8rem; color: #cbd5e1; }
body.m-ativo .m-ll-preco b { font-size: 0.95rem; color: #f8fafc; font-variant-numeric: tabular-nums; }
body.m-ativo .m-ll-det { font-size: 0.74rem; color: #64748b; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
body.m-ativo .m-ll-seta { position: absolute; right: 0.7rem; top: 50%; transform: translateY(-50%); font-size: 1.4rem; color: #475569; }
body.m-ativo .m-ll-num { position: absolute; right: 0.75rem; top: 0.5rem; font-size: 0.6rem; color: #475569; display: none; }
body.m-ativo .m-ll-vazio { display: flex; flex-direction: column; gap: 0.35rem; text-align: center; padding: 2rem 1rem; color: #94a3b8; font-size: 0.85rem; }
body.m-ativo .m-ll-vazio b { color: #e2e8f0; font-size: 0.95rem; }

/* editor de tela cheia */
body.m-ativo #m-linha-editor:not(.hidden) {
    display: block !important; position: fixed; inset: 0; z-index: 1150; background: #0b1220; padding: 0 !important;
}
body.m-ativo .m-le-caixa { display: flex; flex-direction: column; height: 100dvh; }
body.m-ativo .m-le-topo {
    flex: none; display: flex; align-items: center; gap: 0.35rem;
    padding: calc(env(safe-area-inset-top, 0px) + 0.45rem) 0.5rem 0.45rem 0.25rem;
    background: #0f172a; border-bottom: 1px solid rgba(148, 163, 184, 0.14);
}
body.m-ativo .m-le-voltar {
    width: 44px; height: 44px; flex: none; border: none; background: transparent; color: #e2e8f0;
    font-size: 2rem; line-height: 1; cursor: pointer; padding: 0;
}
body.m-ativo .m-le-titulos { flex: 1; min-width: 0; display: flex; flex-direction: column; }
body.m-ativo .m-le-titulos strong { font-family: var(--font-mono); font-size: 1rem; color: #f8fafc; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
body.m-ativo .m-le-titulos span { font-size: 0.72rem; color: #94a3b8; }
body.m-ativo .m-le-acao {
    width: 40px; height: 40px; flex: none; border-radius: 12px; font-size: 1rem; cursor: pointer;
    background: rgba(148, 163, 184, 0.12); border: 1px solid rgba(148, 163, 184, 0.18); color: #e2e8f0;
}
body.m-ativo .m-le-acao.perigo { color: #fca5a5; border-color: rgba(248, 113, 113, 0.3); }
body.m-ativo .m-le-corpo {
    flex: 1 1 auto; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
    padding: 0.8rem 0.85rem 1.4rem;
}
body.m-ativo .m-le-secao { margin-bottom: 1.1rem; }
body.m-ativo .m-le-secao h4 {
    margin: 0 0 0.55rem; font-size: 0.7rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: #60a5fa;
}
body.m-ativo .m-le-grade { display: grid; grid-template-columns: 1fr 1fr; gap: 0.7rem 0.6rem; }
body.m-ativo .m-le-campo { grid-column: 1 / -1; display: flex; flex-direction: column; gap: 0.3rem; min-width: 0; }
body.m-ativo .m-le-campo.meia { grid-column: auto; }
body.m-ativo .m-le-rot { font-size: 0.72rem; font-weight: 600; color: #94a3b8; }
body.m-ativo .m-le-campo input:not([type="checkbox"]),
body.m-ativo .m-le-campo select,
body.m-ativo .m-le-campo textarea {
    width: 100%; box-sizing: border-box; min-height: 46px; padding: 0.6rem 0.75rem; margin: 0;
    font: inherit; font-size: 16px; color: #f1f5f9; background: rgba(15, 23, 42, 0.85);
    border: 1px solid rgba(148, 163, 184, 0.22); border-radius: 12px; outline: none;
}
body.m-ativo .m-le-campo textarea { resize: vertical; line-height: 1.4; }
body.m-ativo .m-le-campo input:focus, body.m-ativo .m-le-campo select:focus, body.m-ativo .m-le-campo textarea:focus {
    border-color: #3b82f6; box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}
body.m-ativo .m-le-campo input.mono { font-family: var(--font-mono); font-weight: 700; letter-spacing: 0.02em; }
body.m-ativo .m-le-leitura {
    min-height: 46px; display: flex; align-items: center; padding: 0 0.75rem; box-sizing: border-box;
    border-radius: 12px; background: rgba(148, 163, 184, 0.08); color: #cbd5e1; font-size: 0.95rem;
    font-variant-numeric: tabular-nums;
}
body.m-ativo .m-le-leitura.calc { font-weight: 700; color: #f8fafc; }
body.m-ativo .m-le-leitura.boa { color: #6ee7b7; }
body.m-ativo .m-le-leitura.baixa { color: #fcd34d; }
body.m-ativo .m-le-leitura.neg { color: #fca5a5; }
body.m-ativo .m-le-leitura.vazio { color: #64748b; font-weight: 500; font-size: 0.8rem; }
/* status em botoes (segmented control) */
body.m-ativo .m-le-seg { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.3rem; background: rgba(15, 23, 42, 0.85); border: 1px solid rgba(148, 163, 184, 0.18); border-radius: 12px; padding: 0.25rem; }
body.m-ativo .m-le-seg button {
    min-height: 40px; border: none; border-radius: 9px; background: transparent; color: #94a3b8;
    font: inherit; font-size: 0.74rem; font-weight: 600; cursor: pointer; padding: 0 0.2rem; line-height: 1.1;
}
/* chave liga/desliga */
body.m-ativo .m-le-chave { position: relative; width: 52px; height: 32px; display: inline-block; }
body.m-ativo .m-le-chave input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 1; }
body.m-ativo .m-le-chave span { position: absolute; inset: 0; border-radius: 999px; background: #334155; transition: background 0.2s; }
body.m-ativo .m-le-chave span::after {
    content: ''; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%; background: #fff; transition: transform 0.2s;
}
body.m-ativo .m-le-chave input:checked + span { background: #10b981; }
body.m-ativo .m-le-chave input:checked + span::after { transform: translateX(20px); }
/* rodape: anterior / concluir / proxima */
body.m-ativo .m-le-rodape {
    flex: none; display: grid; grid-template-columns: 1fr 1.25fr 1fr; gap: 0.45rem;
    padding: 0.55rem 0.75rem calc(env(safe-area-inset-bottom, 0px) + 0.6rem);
    background: #0f172a; border-top: 1px solid rgba(148, 163, 184, 0.16);
}
body.m-ativo .m-le-rodape button {
    min-height: 48px; border-radius: 12px; font: inherit; font-size: 0.86rem; font-weight: 600; cursor: pointer;
    border: 1px solid rgba(148, 163, 184, 0.2); background: rgba(148, 163, 184, 0.1); color: #e2e8f0;
}
body.m-ativo .m-le-rodape button:disabled { opacity: 0.35; cursor: default; }
body.m-ativo .m-le-rodape .m-le-pronto { background: linear-gradient(135deg, #2563eb, #1d4ed8); border: none; color: #fff; }
/* v12b -- a faixa de totais rola de lado sem alargar a janela (antes ela
   empurrava a janela para fora da tela e cortava o comeco dos cartoes) */
body.m-ativo #crm-linhas-modal .cq-linhas-caixa { width: 100% !important; max-width: 100vw !important; min-width: 0 !important; }
body.m-ativo #crm-linhas-modal .cq-linhas-barra,
body.m-ativo #crm-linhas-modal .cq-linhas-barra > *,
body.m-ativo #crm-linhas-modal .cq-topo > div { min-width: 0 !important; max-width: 100% !important; }
body.m-ativo #crm-linhas-modal #crm-linhas-resumo { width: 100%; }

/* v13 -- Email Template no celular: tela cheia, papel rolando, botoes embaixo */
body.m-ativo #cq-email-modal .cq-email-caixa {
    padding: 0 !important; height: 100dvh !important; max-height: 100dvh !important; width: 100% !important; background: #0b1220 !important;
}
body.m-ativo #cq-email-modal .cq-topo {
    margin: 0 !important; align-items: center !important; gap: 0.6rem !important;
    padding: calc(env(safe-area-inset-top, 0px) + 0.55rem) 0.6rem 0.55rem 0.9rem !important;
    background: #0f172a; border-bottom: 1px solid rgba(148, 163, 184, 0.14);
}
body.m-ativo #cq-email-modal .cq-titulo { font-size: 1rem !important; margin: 0 !important; }
body.m-ativo #cq-email-modal .cq-subtitulo { font-size: 0.72rem !important; margin: 0.15rem 0 0 !important; }
body.m-ativo #cq-email-modal .cq-fechar {
    width: 44px !important; height: 44px !important; padding: 0 !important; border-radius: 50% !important; border: none !important;
    display: flex; align-items: center; justify-content: center; background: rgba(148, 163, 184, 0.16) !important;
}
body.m-ativo #cq-email-modal .cq-email-aviso { margin: 0.6rem 0.75rem 0 !important; }
body.m-ativo #cq-email-modal .cq-email-papel-caixa { padding: 0.6rem !important; border-radius: 0 !important; background: #0b1220 !important; -webkit-overflow-scrolling: touch; }
body.m-ativo #cq-email-modal .cq-email-papel { padding: 1rem 0.9rem !important; font-size: 13px; }
body.m-ativo #cq-email-modal .cq-email-papel table { font-size: 11px !important; }
body.m-ativo #cq-email-modal .cq-email-papel td, body.m-ativo #cq-email-modal .cq-email-papel th { padding: 5px 6px !important; }
body.m-ativo #cq-email-modal .cq-rodape {
    margin: 0 !important; display: grid !important; grid-template-columns: 1fr; gap: 0.4rem !important;
    padding: 0.55rem 0.75rem calc(env(safe-area-inset-bottom, 0px) + 0.6rem) !important;
    background: #0f172a !important; border-top: 1px solid rgba(148, 163, 184, 0.16);
}
body.m-ativo #cq-email-modal .cq-msg:empty { display: none; }
body.m-ativo #cq-email-modal .cq-rodape-dir { display: grid !important; grid-template-columns: 1fr 1fr; gap: 0.45rem !important; }
body.m-ativo #cq-email-modal .cq-rodape .modern-btn { width: 100% !important; min-height: 44px !important; font-size: 0.82rem !important; justify-content: center; border-radius: 12px !important; }
body.m-ativo #cq-email-modal #cq-email-copiar { grid-column: 1 / -1; order: -1; min-height: 48px !important; }
/* no rodape do cartao: Email Template vira icone, ao lado da engrenagem */
body.m-ativo #crm-quote-modal .cq-rodape-dir { grid-template-columns: 44px 44px 1fr 1.15fr !important; }
body.m-ativo #crm-quote-modal #crm-quote-email-tpl { font-size: 0 !important; padding: 0 !important; }
body.m-ativo #crm-quote-modal #crm-quote-email-tpl::before { content: '✉️'; font-size: 1.1rem; }
/* previa do e-mail no celular: letra menor so na tela (o que e copiado
   mantem o tamanho do e-mail) e a tabela rola de lado se precisar */
body.m-ativo #cq-email-papel { overflow-x: hidden; font-size: 12px !important; }
body.m-ativo #cq-email-papel p, body.m-ativo #cq-email-papel div { font-size: 12px !important; }
body.m-ativo #cq-email-papel td, body.m-ativo #cq-email-papel th,
body.m-ativo #cq-email-papel td *, body.m-ativo #cq-email-papel th * { font-size: 10.5px !important; }
body.m-ativo #cq-email-papel table { min-width: 560px; }

/* =============================================================================
   v14 -- Buscar (IA Sourcing) no celular: compositor fixo embaixo, contador
   discreto, opcoes sob demanda, paginacao estavel e animacoes leves
   ========================================================================== */
body.m-ativo { --m-comp-h: 68px; }

/* 1. Compositor fixo logo acima da barra de baixo (como um app de mensagens) */
body.m-ativo #sourcing-tab > .search-section,
body.m-ativo .search-section.sticky-bottom {
    position: fixed !important; left: 0 !important; right: 0 !important; top: auto !important;
    bottom: calc(var(--m-barra-h) + var(--m-seguro)) !important;
    margin: 0 !important; z-index: 140 !important; order: 0 !important;
    padding: 0.55rem 0.65rem 0.6rem !important; border-radius: 18px 18px 0 0 !important;
    background: rgba(12, 18, 34, 0.94) !important; border: none !important;
    border-top: 1px solid rgba(148, 163, 184, 0.16) !important;
    -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
    box-shadow: 0 -10px 28px rgba(0, 0, 0, 0.35) !important;
    transition: bottom 0.18s ease, transform 0.25s ease, opacity 0.2s ease;
}
body.m-ativo .search-section #search-section-title,
body.m-ativo .search-section #search-section-subtitle { display: none !important; }
/* com a tela cheia de resultados aberta, o compositor sai de cena */
body.m-ativo.m-res-aberto .search-section { transform: translateY(120%); opacity: 0; pointer-events: none; }
/* teclado aberto: o compositor sobe junto e a barra de baixo some */
body.m-ativo.m-teclado #m-barra { display: none !important; }
body.m-ativo.m-teclado .search-section { bottom: var(--m-kb, 0px) !important; border-radius: 0 !important; }

/* conteudo da aba termina acima do compositor */
body.m-ativo[data-m-aba="sourcing"] .main-content {
    padding-bottom: calc(var(--m-barra-h) + var(--m-seguro) + max(var(--m-comp-h, 68px), 64px) + 1.2rem) !important;
}

/* grade: campo + botao na 1a linha, opcoes na 2a (so quando ativo) */
body.m-ativo .search-section .search-box {
    position: relative; display: grid !important; grid-template-columns: minmax(0, 1fr) 46px;
    grid-template-areas: "campo botao" "opcoes opcoes"; gap: 0 0.5rem !important; align-items: end;
}
body.m-ativo .search-section .search-actions { display: contents !important; }
body.m-ativo .search-section #aviation-search-inputs,
body.m-ativo .search-section #general-search-inputs { grid-area: campo; min-width: 0; }
body.m-ativo .search-section #search-btn { grid-area: botao; }
body.m-ativo .search-section .search-actions > div:first-child {
    grid-area: opcoes; display: flex !important; flex-wrap: nowrap !important; gap: 0.4rem !important;
    align-items: center; overflow-x: auto; scrollbar-width: none; min-width: 0; margin: 0 !important;
}
body.m-ativo .search-section .search-actions > div:first-child::-webkit-scrollbar { display: none; }
body.m-ativo .search-section:not(.m-busca-ativa) .search-actions > div:first-child > :not(#pn-counter) { display: none !important; }
body.m-ativo .search-section.m-busca-ativa .search-actions > div:first-child { padding-top: 0.5rem; }
body.m-ativo .search-section.m-busca-ativa .search-actions > div:first-child > :not(#pn-counter) {
    animation: m-opcoes-entra 0.24s cubic-bezier(.2, .8, .2, 1) both;
}
body.m-ativo .search-section.m-busca-ativa .search-actions > div:first-child > :nth-child(3) { animation-delay: 0.04s; }
@keyframes m-opcoes-entra { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* campo: uma linha, cresce enquanto digita (ate ~4 linhas) */
body.m-ativo .search-section #pn-input {
    display: block; width: 100% !important; box-sizing: border-box;
    min-height: 46px !important; height: 46px; max-height: 128px !important; resize: none !important;
    padding: 0.7rem 4.1rem 0.7rem 0.95rem !important; margin: 0 !important;
    font-size: 16px !important; line-height: 1.35 !important; border-radius: 23px !important;
    background: rgba(15, 23, 42, 0.95) !important; border: 1px solid rgba(148, 163, 184, 0.22) !important;
    transition: border-color 0.2s, box-shadow 0.2s, height 0.12s ease;
}
body.m-ativo .search-section #pn-input:focus {
    border-color: #3b82f6 !important; box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.18) !important;
}
body.m-ativo .search-section #general-search-inputs .modern-input { font-size: 16px !important; min-height: 42px; border-radius: 12px !important; }

/* contador: etiqueta discreta no canto do campo */
body.m-ativo .search-section #pn-counter {
    position: absolute !important; top: 13px !important; right: calc(46px + 0.5rem + 12px) !important; left: auto !important; bottom: auto !important;
    margin: 0 !important; padding: 2px 8px !important; border-radius: 999px; z-index: 2; pointer-events: none;
    font-size: 0.68rem !important; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: 0.01em;
    color: #94a3b8 !important; background: rgba(148, 163, 184, 0.12); border: 1px solid rgba(148, 163, 184, 0.14);
    transition: color 0.2s, background 0.2s, transform 0.2s;
}
body.m-ativo .search-section #pn-counter.m-cont-cheio { color: #93c5fd !important; background: rgba(59, 130, 246, 0.16); border-color: rgba(59, 130, 246, 0.3); }
body.m-ativo .search-section #pn-counter.m-cont-alerta { color: #fcd34d !important; background: rgba(245, 158, 11, 0.16); border-color: rgba(245, 158, 11, 0.35); }
body.m-ativo .search-section #pn-counter.m-cont-max { color: #fca5a5 !important; background: rgba(239, 68, 68, 0.16); border-color: rgba(239, 68, 68, 0.4); }
body.m-ativo .search-section #pn-counter.m-cont-pulso { animation: m-pulso 0.28s ease; }
@keyframes m-pulso { 50% { transform: scale(1.14); } }

/* botao de buscar: redondo, ao lado do campo */
body.m-ativo .search-section #search-btn {
    width: 46px !important; height: 46px !important; min-width: 46px !important; min-height: 46px !important;
    padding: 0 !important; margin: 0 !important; border-radius: 50% !important;
    display: flex !important; align-items: center; justify-content: center;
    box-shadow: 0 6px 16px rgba(37, 99, 235, 0.4); transition: transform 0.12s ease, box-shadow 0.2s, opacity 0.2s;
}
body.m-ativo .search-section #search-btn:active { transform: scale(0.9); }
body.m-ativo .search-section #search-btn:disabled { opacity: 0.55; box-shadow: none; }

/* chips da 2a linha */
body.m-ativo .search-section .ps-badge { min-height: 32px !important; border-radius: 999px !important; padding: 0.2rem 0.7rem !important; }
body.m-ativo .search-section .search-actions > div:first-child > div:last-child {
    flex: 0 0 auto !important; display: flex !important; align-items: center; gap: 0.4rem !important;
    padding: 0.15rem 0.35rem 0.15rem 0.6rem !important; border-radius: 999px !important; min-height: 32px;
}

/* 2. Historico: cartoes entram suaves a cada pagina */
body.m-ativo #results-tbody > tr:not(.expandable-content-row) { animation: m-cartao-entra 0.32s cubic-bezier(.2, .8, .2, 1) both; }
body.m-ativo #results-tbody > tr:nth-child(3)  { animation-delay: 0.03s; }
body.m-ativo #results-tbody > tr:nth-child(5)  { animation-delay: 0.06s; }
body.m-ativo #results-tbody > tr:nth-child(7)  { animation-delay: 0.09s; }
body.m-ativo #results-tbody > tr:nth-child(9)  { animation-delay: 0.12s; }
body.m-ativo #results-tbody > tr:nth-child(11) { animation-delay: 0.15s; }
body.m-ativo #results-tbody > tr:nth-child(13) { animation-delay: 0.18s; }
body.m-ativo #results-tbody > tr:nth-child(n+15) { animation-delay: 0.21s; }
@keyframes m-cartao-entra { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* paginacao: alvos de toque maiores e pagina atual bem marcada */
body.m-ativo #pagination-container .pagination-btn {
    min-width: 36px !important; height: 36px !important; border-radius: 10px !important;
    transition: background 0.2s, transform 0.12s;
}
body.m-ativo #pagination-container .pagination-btn:active { transform: scale(0.92); }
body.m-ativo #pagination-container .pagination-btn.active { box-shadow: 0 4px 12px rgba(59, 130, 246, 0.45); }
body.m-ativo #pagination-container .pagination-btn:disabled { opacity: 0.3; }

@media (prefers-reduced-motion: reduce) {
    body.m-ativo #results-tbody > tr, body.m-ativo .search-section .search-actions > div:first-child > *,
    body.m-ativo .search-section #pn-counter { animation: none !important; }
}

/* cabecalho do Historico: titulo e filtro numa linha, paginacao inteira embaixo */
body.m-ativo #sourcing-tab .results-section .section-header {
    display: grid !important; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 0.6rem 0.5rem !important;
}
body.m-ativo #sourcing-tab .results-section .section-header > h3 { grid-column: 1; grid-row: 1; white-space: nowrap; }
body.m-ativo #sourcing-tab .results-section .section-header > div { display: contents !important; }
body.m-ativo #sourcing-tab #btn-toggle-filters { grid-column: 2; grid-row: 1; }
body.m-ativo #sourcing-tab #pagination-container {
    grid-column: 1 / -1; grid-row: 2; width: 100%; box-sizing: border-box; justify-content: space-between !important;
}
/* estrela na aba Buscar: acima da busca fixa (enquanto nao foi arrastada) */
body.m-ativo[data-m-aba="sourcing"] #ia-dados-fab:not(.ia-fab-livre) {
    bottom: calc(var(--m-barra-h) + var(--m-seguro) + max(var(--m-comp-h, 68px), 64px) + 14px);
}
body.m-ativo.m-res-aberto #ia-dados-fab, body.m-ativo.m-teclado #ia-dados-fab { display: none; }

/* Auto Sourcing: sem as larguras fixas das colunas, o card ocupa a tela toda */
body.m-ativo #as-tabela colgroup { display: none; }
body.m-ativo #as-tabela, body.m-ativo #as-tabela tbody, body.m-ativo #as-tabela tr { width: 100% !important; max-width: 100%; box-sizing: border-box; }
body.m-ativo #as-tabela td { width: auto !important; }
/* chat aberto: estrela acima do campo de mensagem */
body.m-ativo.chat-aberto #ia-dados-fab:not(.ia-fab-livre) { bottom: calc(var(--m-barra-h) + var(--m-seguro) + 96px); }

/* botoes de condicao: uma linha que rola de lado, alvo de toque maior */
body.m-ativo .cond-chips { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; padding: 0.45rem 0.55rem; }
body.m-ativo .cond-chips::-webkit-scrollbar { display: none; }
body.m-ativo .cond-chip { height: 32px; padding: 0 0.75rem; font-size: 0.78rem; flex: 0 0 auto; }
body.m-ativo .cond-rotulo { display: none; }

/* empresa logada: no celular o menu lateral vira barra, o selo nao cabe la */
body.m-ativo .sidebar-empresa { display: none !important; }

/* ===================== Busca em volume no celular ===================== */
/* faixa de indicadores: uma linha que rola de lado, em vez de 3 linhas */
body.m-ativo .busca-resumo { padding: 0.5rem !important; margin: 0 0 0.5rem !important; border-radius: 12px; }
body.m-ativo .busca-ind-linha, body.m-ativo .busca-filtros { flex-wrap: nowrap !important; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
body.m-ativo .busca-ind-linha::-webkit-scrollbar, body.m-ativo .busca-filtros::-webkit-scrollbar, body.m-ativo .pn-card-chips::-webkit-scrollbar { display: none; }
body.m-ativo .busca-ind-chip { flex: 0 0 auto; font-size: 0.74rem; padding: 0.3rem 0.55rem; }
body.m-ativo .busca-ind-chip b { font-size: 0.86rem; }
body.m-ativo .busca-filtros { margin-top: 0.45rem; gap: 0.3rem; align-items: center; }
body.m-ativo .busca-filtros .cond-rotulo { display: none; }
body.m-ativo .busca-filtro { flex: 0 0 auto; height: 36px !important; min-height: 36px !important; padding: 0 0.7rem !important; font-size: 0.78rem !important; width: auto !important; }
body.m-ativo .busca-filtro-texto { order: -1; flex: 0 0 46%; min-width: 150px; max-width: none; height: 36px; font-size: 16px; }
/* cartao de PN: PN + seta numa linha, descricao e selos embaixo, tudo a esquerda */
body.m-ativo .pn-group.pn-card { padding: 0 !important; margin: 0 0 6px !important; border-style: solid !important; border-width: 1px 1px 1px 3px !important; border-color: var(--m-borda, rgba(255,255,255,0.08)); border-radius: 10px !important; background: rgba(255,255,255,0.02) !important; }
body.m-ativo .pn-group.pn-card[data-res="preco"] { border-left-color: #22d3ee !important; }
body.m-ativo .pn-group.pn-card[data-res="disp"] { border-left-color: #a78bfa !important; }
body.m-ativo .pn-group.pn-card[data-res="nada"] { border-left-color: rgba(239,68,68,0.6) !important; }
body.m-ativo .pn-group.pn-card > .pn-card-topo { flex-direction: row !important; flex-wrap: wrap !important; align-items: center !important; justify-content: flex-start !important; gap: 0.25rem 0.5rem !important; padding: 0.55rem 0.65rem; min-height: 44px; text-align: left; }
body.m-ativo .pn-card-pn { font-size: 0.95rem; }
body.m-ativo .pn-card-desc { order: 2; flex: 1 1 100%; text-align: left; font-size: 0.76rem; }
body.m-ativo .pn-card-chips { order: 3; flex: 1 1 100%; max-width: 100% !important; justify-content: flex-start !important; flex-wrap: nowrap !important; overflow-x: auto; scrollbar-width: none; }
body.m-ativo .pn-chip { flex: 0 0 auto; height: 24px; font-size: 0.72rem; }
body.m-ativo .pn-card-corpo { padding: 0.45rem 0.55rem 0.7rem !important; }
body.m-ativo .pn-card-corpo > div:first-child { flex-direction: column !important; align-items: stretch !important; gap: 0.5rem !important; }
body.m-ativo .pn-card-corpo .gemini-desc { text-align: left; }
body.m-ativo .pn-card-corpo .modern-btn { width: 100% !important; min-height: 40px; }
/* PNs na fila e em busca: linhas finas */
body.m-ativo .pn-group.pn-fila { flex-direction: row !important; padding: 0.35rem 0.65rem !important; margin: 0 0 3px !important; border: 1px dashed rgba(255,255,255,0.08) !important; border-radius: 8px !important; }
body.m-ativo .pn-group.pn-buscando { padding: 0.5rem 0.65rem !important; margin: 0 0 4px !important; border: 1px solid rgba(250,204,21,0.3) !important; border-radius: 8px !important; background: rgba(250,204,21,0.03) !important; }
body.m-ativo .pn-group.pn-buscando > .pn-buscando-topo { flex-direction: row !important; flex-wrap: wrap; gap: 0.3rem 0.5rem !important; align-items: center !important; }
body.m-ativo .pn-buscando .live-progress-text { flex: 1 1 100%; order: 3; font-size: 0.72rem; }
/* seta e PN na mesma linha; borda discreta (a regra geral zera a cor da borda) */
body.m-ativo .pn-group.pn-card { border-color: rgba(255,255,255,0.09) !important; }
body.m-ativo .pn-group.pn-card > .pn-card-topo > .pn-card-seta { flex: 0 0 12px !important; width: 12px !important; order: 0; }
body.m-ativo .pn-group.pn-card > .pn-card-topo > .pn-card-pn { flex: 1 1 60% !important; width: auto !important; order: 1; text-align: left; }
/* no celular o cartao inteiro e o toque: a seta so gastava uma linha */
body.m-ativo .pn-group.pn-card > .pn-card-topo > .pn-card-seta { display: none !important; }
body.m-ativo .pn-group.pn-card > .pn-card-topo { padding: 0.5rem 0.65rem 0.55rem; }

/* chat no celular: a lista ocupa a largura toda (no PC ela ficou mais larga) */
body.m-ativo .chat-coluna-lista { width: 100% !important; }
/* chat no celular: mesma escala do padrao (nenhum texto abaixo de 12 px) */
body.m-ativo #chat-thread-messages > div > div { font-size: var(--chat-fs-corpo) !important; }
body.m-ativo .m-chat .chat-subtab { font-size: var(--chat-fs-sec) !important; }
body.m-ativo .m-chat-item span { font-size: var(--chat-fs-corpo) !important; }
body.m-ativo .m-chat-item > div:last-child { font-size: var(--chat-fs-sec) !important; }

/* Ajustes no celular: escala sem a reducao do PC e idiomas empilhados */
body.m-ativo .ajustes-caixa { width: 94% !important; padding: 1.1rem !important; height: auto !important; min-height: 0 !important; max-height: 88vh !important; border-radius: 16px !important; }
body.m-ativo .ajustes-fundo { align-items: center !important; }
body.m-ativo .ajustes-topo h2 { font-size: 1.15rem; }
body.m-ativo .ajustes-rotulo b { font-size: 0.98rem; }
body.m-ativo .ajustes-rotulo span, body.m-ativo .ajustes-nota { font-size: 0.82rem; }
body.m-ativo .ajustes-idiomas { grid-template-columns: 1fr; }
body.m-ativo .ajustes-idioma { min-height: 56px; }
body.m-ativo .ajustes-idioma-txt b { font-size: 0.98rem; }
body.m-ativo .ajustes-idioma-txt small { font-size: 0.8rem; }

/* bolinha de não lidas no celular (sem a redução do PC) */
body.m-ativo .chat-bolinha { min-width: 1.15rem; height: 1.15rem; font-size: 0.68rem; padding: 0 0.3rem; }
body.m-ativo .chat-bolinha-aba { top: -0.35rem; right: -0.15rem; }
body.m-ativo .ajustes-testar { font-size: 0.8rem; }
body.m-ativo .m-barra-badge { background: linear-gradient(180deg, #ff6b6b 0%, #ef4444 55%, #dc2626 100%); border: 1.5px solid rgba(255,255,255,0.85); box-shadow: 0 2px 6px rgba(239,68,68,0.45); box-sizing: border-box; }

/* =============================================================================
   Conversa do chat aberta (celular): tela cheia, so a conversa.
   - a barra de baixo some (nao faz falta dentro da conversa; "‹" volta)
   - a pagina de tras nao rola: so a lista de mensagens rola
   - a altura acompanha o que sobra acima do teclado (--m-vvh, do mobile.js)
   ============================================================================= */
html.m-conversa-html, body.m-ativo.m-conversa { overflow: hidden !important; overscroll-behavior: none; height: 100%; }
body.m-ativo.m-conversa #m-barra { display: none !important; }
body.m-ativo.m-conversa .main-content { padding: 0 !important; }
body.m-ativo.m-conversa #chat-tab { gap: 0 !important; }
body.m-ativo.m-conversa .m-chat.m-chat-aberto {
    height: var(--m-vvh, 100dvh) !important; min-height: 0 !important; max-height: var(--m-vvh, 100dvh) !important;
    margin: 0 !important; border-radius: 0 !important; border: none !important;
    padding: env(safe-area-inset-top, 0px) 0 0 0 !important;
}
body.m-ativo.m-conversa #chat-thread-messages {
    overflow-y: auto !important; overflow-x: hidden !important; -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain; touch-action: pan-y;
    scrollbar-width: thin; scrollbar-color: rgba(148,163,184,0.35) transparent;
}
body.m-ativo.m-conversa #chat-thread-messages::-webkit-scrollbar { width: 3px; }
body.m-ativo.m-conversa #chat-thread-messages::-webkit-scrollbar-thumb { background: rgba(148,163,184,0.35); border-radius: 3px; }
body.m-ativo.m-conversa #chat-composer {
    flex: 0 0 auto; padding: 0.45rem 0.5rem calc(0.45rem + env(safe-area-inset-bottom, 0px)) !important;
}
body.m-ativo.m-conversa #m-chat-voltar { top: env(safe-area-inset-top, 0px); }
/* o botao da IA nao cobre o campo de mensagem */
body.m-ativo.m-conversa #ia-dados-fab:not(.ia-fab-livre) { display: none !important; }
body.m-ativo.m-conversa #chat-toast-host { bottom: 84px !important; }

/* Campo de mensagem: sem texto de ajuda (cortava); uma barrinha piscando
   mostra onde digitar. Ao tocar, entra o cursor normal do teclado. */
body.m-ativo #chat-message-input { min-height: 44px; font-size: 16px !important; line-height: 1.35 !important; }
body.m-ativo #chat-message-input:placeholder-shown:not(:focus) {
    background-image: linear-gradient(#34d399, #34d399) !important; background-repeat: no-repeat !important;
    background-size: 2px 1.25em !important; background-position: 1rem center !important;
    animation: mChatCursor 1.1s steps(1, end) infinite;
}
@keyframes mChatCursor { 0%, 100% { background-size: 2px 1.25em; } 50% { background-size: 0 0; } }
@media (prefers-reduced-motion: reduce) { body.m-ativo #chat-message-input:placeholder-shown:not(:focus) { animation: none; } }

/* =============================================================================
   Faixa do topo (relogio / bateria / recorte da camera).
   O app desenha por baixo da barra de status do aparelho (viewport-fit=cover).
   Parado, o conteudo comeca abaixo dela; mas ao rolar, titulos e botoes subiam
   para tras do relogio e ficavam cortados e embaralhados. Uma faixa fixa e
   opaca segura essa area, com um degrade curto para o corte nao ser seco.
   ============================================================================= */
body.m-ativo { --m-topo: env(safe-area-inset-top, 0px); }
body.m-ativo::before {
    content: ''; position: fixed; top: 0; left: 0; right: 0; z-index: 95; pointer-events: none;
    /* exatamente a area do relogio, sem degrade: o degrade descia por cima
       dos titulos e deixava o topo das telas esmaecido */
    height: var(--m-topo);
    background: #0f172a;
}
/* na conversa do chat o proprio painel ja cobre essa area */
body.m-ativo.m-conversa::before { display: none; }
body.m-ativo.m-conversa .m-chat.m-chat-aberto { background: #0f172a !important; backdrop-filter: none !important; -webkit-backdrop-filter: none !important; }
body.m-ativo.m-conversa .m-chat.m-chat-aberto #chat-thread-header { background: #1e293b !important; color: #e2e8f0; }
body.m-ativo.m-conversa #ia-dados-fab { display: none !important; }

/* Database no celular: botoes de acao recolhidos atras de "Ações" */
body.m-ativo #database-tab div.m-acoes:has(> #import-db-btn):not(.m-acoes-aberto) { display: none !important; }
body.m-ativo #database-tab div.m-acoes.m-acoes-aberto { animation: mAcoesAbre 0.18s ease-out; }
@keyframes mAcoesAbre { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
body.m-ativo #database-tab > .glass-panel > div:first-child { margin-bottom: 0.5rem !important; }

/* =============================================================================
   Celular: sem efeito de vidro (desfoque) em nenhuma tela.
   Os paineis usam backdrop-filter: blur() no PC. No celular -- principalmente
   no iPhone com o app instalado -- isso deixava o topo das telas embacado
   (o desfoque pega o que passa por tras, inclusive a area do relogio) e
   pesava na rolagem. Aqui os paineis ficam com fundo solido.
   ============================================================================= */
body.m-ativo *, body.m-ativo *::before, body.m-ativo *::after {
    backdrop-filter: none !important; -webkit-backdrop-filter: none !important;
}
body.m-ativo .glass-panel { background: #172033 !important; }
body.m-ativo .stat-card { background: #121a2b !important; }
body.m-ativo #m-barra { background: #0f172a !important; }
body.m-ativo .modal-overlay, body.m-ativo #mobile-menu-overlay { background: rgba(2, 6, 23, 0.78) !important; }

/* =============================================================================
   Cabecalho da conversa no celular: duas linhas limpas, como app de mensagem.
   Antes era uma linha so, com selo translucido em letra miuda e negrito sobre
   fundo translucido -- no aparelho isso lia como "embacado". Agora: nome grande
   em cima; embaixo o papel (comprando / vendendo / interna) e o PN, tudo em
   cor solida, sem transparencia, sem sombra e sem espacamento de letras.
   ============================================================================= */
body.m-ativo.m-conversa .m-chat.m-chat-aberto #chat-thread-header {
    display: flex !important; flex-wrap: wrap; align-items: center; column-gap: 0.45rem; row-gap: 0.2rem;
    white-space: normal !important; overflow: hidden; min-height: 58px;
    padding: 0.55rem 0.8rem 0.55rem 3rem !important;
    background: #17233a !important; border-bottom: 1px solid #2a3a57 !important;
    box-shadow: none !important; text-shadow: none !important; opacity: 1 !important; filter: none !important;
    -webkit-font-smoothing: antialiased; line-height: 1.25 !important; color: #cbd5e1;
}
body.m-ativo.m-conversa #chat-thread-header .chat-cab-nome {
    order: 1; flex: 0 0 100%; min-width: 0; font-size: 1.05rem; font-weight: 600; color: #f8fafc !important;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: 0;
}
body.m-ativo.m-conversa #chat-thread-header .chat-cab-selo {
    order: 2; margin: 0 !important; padding: 2px 8px !important; border-radius: 6px !important; border: none !important;
    font-size: 0.78rem !important; font-weight: 600 !important; letter-spacing: 0 !important; white-space: nowrap;
    background: #22344f !important;
}
body.m-ativo.m-conversa #chat-thread-header .chat-cab-pn {
    order: 3; margin: 0 !important; font-size: 0.82rem; color: #c4b5fd !important; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; flex: 0 1 auto;
}
body.m-ativo.m-conversa #chat-thread-header .chat-cab-assunto { display: none; }
body.m-ativo.m-conversa #chat-thread-header .chat-cab-quem {
    order: 4; flex: 1 1 0; min-width: 0; margin: 0 !important; font-size: 0.8rem !important; color: #94a3b8;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
body.m-ativo.m-conversa #m-chat-voltar { height: 58px; color: #f8fafc; }
/* a faixa do relogio na mesma cor do cabecalho: topo inteiro uniforme */
body.m-ativo.m-conversa .m-chat.m-chat-aberto { background: #17233a !important; }
body.m-ativo.m-conversa .m-chat.m-chat-aberto > div:last-child { background: #0b1220 !important; }

/* bolinha de não lidas na barra de baixo: mesma animação do resto do chat */
body.m-ativo .m-barra-badge { top: -7px; right: -12px; min-width: 18px; height: 18px; font-size: 0.66rem; z-index: 2; }
body.m-ativo .m-barra-badge.chegou { animation: chatBolinhaSalto 0.6s cubic-bezier(.34,1.56,.64,1) 1, chatBolinhaOnda 1.4s ease-out 1; }
body.m-ativo .m-barra-ico { overflow: visible; }
/* aviso de mensagem nova: acima da barra de baixo, sem tapar o ícone do Chat */
body.m-ativo #chat-toast-host { left: 12px !important; right: 12px !important; bottom: calc(var(--m-barra-h) + var(--m-seguro) + 12px) !important; }
body.m-ativo.m-conversa #chat-toast-host { bottom: 84px !important; }

body.m-ativo #vendas-chips .vendas-chip.vendas-todas { grid-column: 1 / -1; margin-left: 0; }

/* excluir várias pesquisas no celular: barra acima do campo de busca, cartoes marcaveis */
body.m-ativo #btn-bulk-delete { padding: 0.5rem 0.7rem !important; font-size: 0.8rem !important; min-height: 40px; white-space: nowrap; }
body.m-ativo #busca-selecao-barra { left: 10px; right: 10px; transform: none; bottom: calc(var(--m-barra-h) + var(--m-seguro) + 10px); z-index: 185;
    border-radius: 16px; padding: 0.55rem 0.6rem 0.55rem 0.85rem; gap: 0.4rem; flex-wrap: wrap; justify-content: space-between; max-width: none; animation: none; }
body.m-ativo #busca-selecao-barra .bsb-info { font-size: 0.86rem; flex: 1 1 auto; }
body.m-ativo #busca-selecao-barra .bsb-btn { padding: 0.5rem 0.7rem; font-size: 0.8rem; min-height: 38px; }
body.m-ativo.busca-selecionando .search-section { display: none !important; }
body.m-ativo.busca-selecionando #ia-dados-fab { display: none !important; }
body.m-ativo.busca-selecionando #results-tbody > tr:has(> td .delete-search-btn) { outline: 2px dashed rgba(148, 163, 184, 0.35); outline-offset: -2px; }
body.m-ativo.busca-selecionando #results-tbody > tr.sel-marcada { outline: 2px solid #ef4444 !important; background: rgba(239, 68, 68, 0.12) !important; }
body.m-ativo.busca-selecionando #results-tbody > tr.sel-marcada > td { background: transparent !important; }

body.m-ativo .busca-tudo-caixa { height: auto !important; min-height: 0 !important; max-height: 88vh !important; border-radius: 16px !important; }
body.m-ativo .busca-tudo-fundo { align-items: center !important; }
body.m-ativo .busca-tudo-caixa h2 { font-size: 1.1rem; }
body.m-ativo .busca-tudo-caixa .bt-texto, body.m-ativo .bt-opcao span, body.m-ativo .bt-confirma { font-size: 0.86rem; }
body.m-ativo .bt-opcao small { font-size: 0.78rem; }
body.m-ativo .bt-acoes .modern-btn { flex: 1; min-height: 44px; }
body.m-ativo #bt-palavra { font-size: 16px !important; }

/* cartao da linha da cotacao: lupa do Database sempre a mostra, no lugar da seta */
body.m-ativo .m-ll-cartao { position: relative; }
body.m-ativo .m-ll-cartao .m-ll-item { width: 100%; padding-right: 3.6rem !important; }
body.m-ativo .m-ll-cartao .m-ll-seta { display: none; }
body.m-ativo .m-ll-lupa { position: absolute; right: 0.55rem; top: 50%; transform: translateY(-50%); width: 42px; height: 42px; border-radius: 12px;
    display: flex; align-items: center; justify-content: center; font-size: 1.05rem; cursor: pointer;
    border: 1px solid rgba(96, 165, 250, 0.4); background: rgba(59, 130, 246, 0.14); color: #93c5fd; }
body.m-ativo .m-ll-lupa:active { background: rgba(59, 130, 246, 0.32); transform: translateY(-50%) scale(0.95); }

/* =============================================================================
   Barra de baixo no estilo iPhone: capsula flutuante e uma "bolha" que desliza
   ate o item ativo. --m-barra-h continua sendo o espaco que o conteudo reserva
   embaixo (capsula de 62px + 10px de folga).
   ============================================================================= */
body.m-ativo { --m-barra-h: 76px; }
body.m-ativo #m-barra {
    left: 12px !important; right: 12px !important; bottom: calc(var(--m-seguro) + 10px) !important;
    height: 62px !important; padding: 5px !important; border-radius: 31px !important;
    background: rgba(17, 25, 43, 0.94) !important; border: 1px solid rgba(148, 163, 184, 0.16) !important;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.06) !important;
    grid-template-columns: repeat(5, 1fr); overflow: visible;
}
body.m-ativo #m-barra-bolha {
    position: absolute; top: 5px; bottom: 5px; left: 5px; z-index: 0; pointer-events: none;
    width: calc((100% - 10px) / 5); border-radius: 26px;
    transform: translateX(calc(100% * var(--i, 0)));
    transition: transform 0.42s cubic-bezier(0.34, 1.32, 0.5, 1);
    background: linear-gradient(180deg, rgba(96, 165, 250, 0.32), rgba(59, 130, 246, 0.22));
    border: 1px solid rgba(147, 197, 253, 0.35);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12), 0 4px 12px rgba(37, 99, 235, 0.25);
}
@media (prefers-reduced-motion: reduce) { body.m-ativo #m-barra-bolha { transition: none; } }
body.m-ativo .m-barra-btn { position: relative; z-index: 1; gap: 3px; border-radius: 26px; color: #8b9ab3; transition: color 0.25s; }
body.m-ativo .m-barra-btn::before { display: none !important; }
body.m-ativo .m-barra-btn .m-barra-ico { font-size: 1.28rem; transition: transform 0.3s cubic-bezier(0.34, 1.5, 0.5, 1), filter 0.25s, opacity 0.25s; }
body.m-ativo .m-barra-btn.ativo { color: #f8fafc; }
body.m-ativo .m-barra-btn.ativo .m-barra-ico { transform: translateY(-1px) scale(1.08); filter: none; opacity: 1; }
body.m-ativo .m-barra-btn .m-barra-txt { font-size: 0.66rem; font-weight: 600; letter-spacing: 0.01em; }
body.m-ativo .m-barra-btn.ativo .m-barra-txt { font-weight: 700; }
body.m-ativo .m-barra-btn:active .m-barra-ico { transform: scale(0.9); }
body.m-ativo .m-barra-badge { top: -6px; right: -13px; }

/* =============================================================================
   Inspecao das telas no celular (outubro/2026)
   ============================================================================= */
/* login: sem barra de baixo nem botao da IA antes de entrar */
body.m-ativo:has(#auth-container:not(.hidden)) #m-barra,
body.m-ativo:has(#auth-container:not(.hidden)) #ia-dados-fab { display: none !important; }
body.m-ativo #auth-container a { display: inline-block; padding: 0.55rem 0.4rem; margin: -0.3rem 0; }

/* botao da IA: menor, e some com o menu "Mais" aberto */
body.m-ativo #ia-dados-fab:not(.ia-fab-livre) { width: 50px !important; height: 50px !important; right: 12px !important; }
body.m-ativo:has(.sidebar-content.mobile-open) #ia-dados-fab { display: none !important; }
/* o fim de cada tela rola acima do botao da IA, sem ficar escondido atras dele */
body.m-ativo .main-content { padding-bottom: calc(var(--m-barra-h) + var(--m-seguro) + 72px) !important; }
body.m-ativo.m-conversa .main-content { padding-bottom: 0 !important; }

/* letra minima legivel (11px) nos rotulos de cartoes e etiquetas */
body.m-ativo .stat-title, body.m-ativo #dash-searched-title, body.m-ativo #dash-returned-title { font-size: 0.66rem !important; letter-spacing: 0.02em !important; line-height: 1.2 !important; }
body.m-ativo .vendas-card-titulo { font-size: 0.72rem !important; letter-spacing: 0.02em !important; }
body.m-ativo .vendas-card-hoje { font-size: 0.76rem !important; }
body.m-ativo [id^="dash-kpi-"][id$="-sub"] { font-size: 0.76rem !important; }
body.m-ativo .meta-pill { font-size: 0.72rem !important; }
body.m-ativo #pn-counter { font-size: 0.72rem !important; }
body.m-ativo .as-campo > span { font-size: 0.7rem !important; }

/* IA Sourcing: "Excluir varias" compacto, na mesma linha do historico */
body.m-ativo #btn-bulk-delete { width: auto !important; flex: 0 0 auto !important; align-self: flex-end; padding: 0.45rem 0.8rem !important; min-height: 38px; font-size: 0.78rem !important; border-radius: 999px !important; }

/* Auto Sourcing: periodo e etapa um embaixo do outro, sem cortar o texto */
body.m-ativo .as-barra .as-campo { grid-column: 1 / -1; display: flex; justify-content: space-between; align-items: center; }
body.m-ativo .as-barra .as-campo select { flex: 1; min-width: 0; max-width: 70%; }

/* caixas de marcar no tema escuro (eram quadrados brancos) */
body.m-ativo input[type="checkbox"]:not(.crm-cel):not(.m-le-chave > input):not(.bd-duas > input) { accent-color: #3b82f6; width: 22px; height: 22px; }
body.m-ativo .db-row-checkbox { width: 26px !important; height: 26px !important; border-radius: 7px; }

/* fileira de condicoes (NE, NS...): mostra que rola para o lado */
body.m-ativo .cond-chips-db { -webkit-mask-image: linear-gradient(90deg, #000 85%, transparent); mask-image: linear-gradient(90deg, #000 85%, transparent); padding-right: 1.5rem !important; }

/* --- segunda passada da inspecao: vence as regras antigas mais especificas --- */
body.m-ativo .dashboard-stats .stat-title.stat-title,
body.m-ativo .dashboard-stats #dash-searched-title, body.m-ativo .dashboard-stats #dash-returned-title { font-size: 0.78rem !important; letter-spacing: 0.02em !important; }
body.m-ativo #dashboard-tab div[id^="dash-kpi-"][id$="-sub"] { font-size: 0.8rem !important; }
body.m-ativo .vendas-card .vendas-card-titulo { font-size: 0.8rem !important; }
body.m-ativo .meta-pill.meta-pill { font-size: 0.8rem !important; }
body.m-ativo #pn-counter.pn-counter, body.m-ativo #pn-counter { font-size: 0.8rem !important; }
body.m-ativo .as-barra .as-campo > span { font-size: 0.78rem !important; }
body.m-ativo #api-status-badge { font-size: 0.8rem !important; }
body.m-ativo #sourcing-tab #btn-bulk-delete { width: max-content !important; max-width: max-content !important; justify-self: end; align-self: flex-end; margin-left: auto !important; }

/* caixas de marcar desenhadas no tema (o navegador pintava de branco) */
body.m-ativo .db-row-checkbox, body.m-ativo #outlook-use-shared, body.m-ativo #select-all-db {
    -webkit-appearance: none; appearance: none; flex: none; cursor: pointer;
    width: 26px !important; height: 26px !important; border-radius: 7px; margin: 0;
    border: 2px solid #475569; background: #0f172a center / 16px 16px no-repeat;
    transition: background-color 0.15s, border-color 0.15s;
}
body.m-ativo .db-row-checkbox:checked, body.m-ativo #outlook-use-shared:checked, body.m-ativo #select-all-db:checked {
    background-color: #3b82f6; border-color: #3b82f6;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3 8.5l3.2 3L13 4.5' fill='none' stroke='white' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}
/* rotulos dos 4 cartoes do IA Sourcing: cabem na largura do cartao */
body.m-ativo .dashboard-stats .stat-title.stat-title,
body.m-ativo .dashboard-stats #dash-searched-title, body.m-ativo .dashboard-stats #dash-returned-title {
    font-size: 0.7rem !important; letter-spacing: 0 !important; overflow-wrap: anywhere; hyphens: auto;
}
body.m-ativo .dashboard-stats .stat-card { padding-left: 0.2rem !important; padding-right: 0.2rem !important; }
body.m-ativo .dashboard-stats .stat-title.stat-title,
body.m-ativo .dashboard-stats #dash-searched-title, body.m-ativo .dashboard-stats #dash-returned-title { font-size: 0.66rem !important; overflow-wrap: normal; hyphens: manual; }

/* --- inspecao 2 ----------------------------------------------------------- */
/* indicadores com o mesmo tamanho (IA Sourcing e Dashboard) */
body.m-ativo .dashboard-stats { align-items: stretch !important; }
body.m-ativo .dashboard-stats .stat-card { height: auto !important; align-self: stretch !important; display: flex !important; flex-direction: column; justify-content: center; min-height: 60px; }
body.m-ativo #dashboard-tab div[style*="grid-template-columns:repeat(auto-fit, minmax(180px"] { align-items: stretch !important; grid-auto-rows: 1fr; }
body.m-ativo #dashboard-tab div[style*="grid-template-columns:repeat(auto-fit, minmax(180px"] > .glass-panel { height: 100%; }

/* IA Sourcing: "Excluir varias" vira um icone na linha do titulo, ao lado do filtro */
body.m-ativo #sourcing-tab .section-header {
    grid-template-columns: 1fr auto auto !important; grid-template-areas: "t b f" "p p p" !important; align-items: center !important;
}
body.m-ativo #sourcing-tab .section-header > h3 { grid-area: t; }
body.m-ativo #sourcing-tab #btn-bulk-delete {
    grid-area: b; width: 44px !important; max-width: 44px !important; height: 40px !important; min-height: 40px !important;
    padding: 0 !important; margin: 0 !important; justify-content: center; font-size: 0 !important; border-radius: 10px !important;
}
body.m-ativo #sourcing-tab #btn-bulk-delete > span { font-size: 1.05rem; }
body.m-ativo #sourcing-tab #btn-bulk-delete.ativo { background: rgba(239, 68, 68, 0.25) !important; }
body.m-ativo #sourcing-tab #btn-toggle-filters { grid-area: f; }
body.m-ativo #sourcing-tab #pagination-container { grid-area: p; }

/* Vendas: botoes e filtro do topo na mesma altura */
body.m-ativo #vendas-new-deal-btn, body.m-ativo #vendas-refresh-btn, body.m-ativo #vendas-dev-btn,
body.m-ativo .vendas-vendedor-filtro { height: 44px !important; min-height: 44px !important; box-sizing: border-box; }
body.m-ativo #vendas-new-deal-btn { padding-top: 0 !important; padding-bottom: 0 !important; }

/* topo das telas mais baixo, longe da barra de status do aparelho */
body.m-ativo .main-content { padding-top: calc(env(safe-area-inset-top, 0px) + 22px) !important; }
body.m-ativo .dashboard-stats .stat-card { flex-direction: column-reverse !important; gap: 2px; }

/* Pedido e documentos no celular */
body.m-ativo .ped-grade-3 { grid-template-columns: 1fr; }
body.m-ativo .ped-grade { grid-template-columns: 1fr 1fr; }
body.m-ativo .ped-docs { grid-template-columns: 1fr; }
body.m-ativo .ped-barra { position: static; }
body.m-ativo .ped-campo input, body.m-ativo .ped-campo select, body.m-ativo .ped-campo textarea { font-size: 16px; }

/* Rotaveis no celular */
body.m-ativo #rotaveis-tab.rot { padding: 0.2rem 0 2rem; }
body.m-ativo .rot-proj select { min-width: 0; flex: 1; }
body.m-ativo .rot-pn-grade { grid-template-columns: 1fr; }
body.m-ativo .rot-grafico { grid-column: auto; }
body.m-ativo .rot-filtros input[type=search] { min-width: 0; width: 100%; }
body.m-ativo .rot input, body.m-ativo .rot select, body.m-ativo .rot-modal input, body.m-ativo .rot-modal select { font-size: 16px; }

/* ---- IA Sourcing: busca atual x historico ---------------------------------- */
body.m-ativo #sourcing-tab .section-header h3 { font-size: 1.05rem !important; font-weight: 800; }
body.m-ativo #sourcing-tab .section-header h3::after { content: none; }
body.m-ativo #sourcing-tab .so-btn-modo { min-height: 38px; padding: 0.35rem 0.8rem; font-size: 0.8rem; }
/* na busca atual o resultado abre na propria tela, sem passar da largura */
body.m-ativo #sourcing-tab.so-atual #results-tbody > tr.expandable-content-row.open { display: block !important; width: 100%; max-width: 100%; overflow-x: hidden; box-sizing: border-box; }
body.m-ativo #sourcing-tab.so-atual #results-tbody > tr.expandable-content-row.open > td { display: block; width: 100%; max-width: 100%; box-sizing: border-box; }
body.m-ativo #sourcing-tab.so-atual #results-tbody > tr.expandable-content-row.open .expanded-inner-content { max-width: 100%; overflow-x: hidden; box-sizing: border-box; }

body.m-ativo #sourcing-tab.so-atual .modern-table-container table.m-cartoes { display: block !important; width: 100% !important; }
body.m-ativo #sourcing-tab.so-atual #results-tbody { width: 100% !important; min-width: 0 !important; }
body.m-ativo #sourcing-tab.so-atual #results-tbody > tr { max-width: 100% !important; min-width: 0 !important; box-sizing: border-box; }
body.m-ativo #sourcing-tab.so-atual #results-tbody .expanded-inner-content * { min-width: 0; }
/* Historico no canto da barra de busca (encostado na borda de cima) e sem o
   "Abrir" no cartao da busca atual, que ja fica aberto */
body.m-ativo #sourcing-tab .so-hist-canto { top: -0.85rem; left: 0.9rem; right: auto; padding: 0.15rem 0.6rem; font-size: 0.7rem; min-height: 26px; gap: 0.3rem; border-radius: 999px; background: #1e1b4b; }
body.m-ativo #sourcing-tab.so-atual #results-tbody > tr > td.col-acoes::after { content: none; }
body.m-ativo #sourcing-tab.so-atual #results-tbody > tr:not(.expandable-content-row) { cursor: default; }

/* =============================================================================
   IA Sourcing no celular -- mais limpo e centralizado
   Menos informacao na tela de busca: sem os numeros do topo, a ultima busca
   num cartao centralizado e cada fornecedor numa linha so (nome e preco em
   cima, quantidade/condicao/estoque embaixo). Detalhes continuam no toque.
   ============================================================================= */
body.m-ativo #sourcing-tab .dashboard-section { display: none !important; }

/* cartao da busca atual: tudo centralizado */
body.m-ativo #sourcing-tab.so-atual #results-tbody > tr:not(.expandable-content-row):has(> td.col-acoes) {
    grid-template-columns: minmax(0, 1fr) !important; justify-items: center; text-align: center;
    padding: 1rem 2.6rem 0.9rem !important; row-gap: 0.4rem !important;
    background: linear-gradient(180deg, rgba(59, 130, 246, 0.16), rgba(59, 130, 246, 0.05)) !important;
    border: 1px solid rgba(59, 130, 246, 0.4) !important; border-radius: 18px !important;
}
body.m-ativo #sourcing-tab.so-atual #results-tbody > tr:has(> td.col-acoes) > td { text-align: center !important; justify-self: center !important; }
body.m-ativo #sourcing-tab.so-atual #results-tbody > tr:has(> td.col-acoes) > td:nth-child(2) {
    grid-column: 1 !important; grid-row: 1 !important; font-size: 0.72rem !important; color: #93c5fd !important; letter-spacing: 0.04em; opacity: 0.85;
}
body.m-ativo #sourcing-tab.so-atual #results-tbody > tr:has(> td.col-acoes) > td.pn-preview {
    grid-column: 1 !important; grid-row: 2 !important; font-size: 1.12rem !important; font-weight: 800; color: #f8fafc !important;
    font-family: var(--font-mono); -webkit-line-clamp: 3;
}
body.m-ativo #sourcing-tab.so-atual #results-tbody > tr:has(> td.col-acoes) > td.status-cell { grid-column: 1 !important; grid-row: 3 !important; }
body.m-ativo #sourcing-tab.so-atual #results-tbody > tr:has(> td.col-acoes) > td.status-cell:has(.search-progress-container) { justify-self: stretch !important; width: 100%; }
body.m-ativo #sourcing-tab.so-atual #results-tbody > tr:has(> td.col-acoes) > td:nth-child(4) { grid-column: 1 !important; grid-row: 4 !important; white-space: normal; }
body.m-ativo #sourcing-tab.so-atual #results-tbody > tr:has(> td.col-acoes) > td:nth-child(4) .quem-cotou { display: inline; margin-left: 0.35rem; }
body.m-ativo #sourcing-tab.so-atual #results-tbody > tr:has(> td.col-acoes) > td.col-acoes { position: absolute; top: 0.55rem; right: 0.55rem; }

/* barra "baixar a busca inteira" numa linha so, discreta */
body.m-ativo #sourcing-tab .busca-export-barra { flex-direction: row !important; flex-wrap: wrap; align-items: center !important; justify-content: center !important; gap: 0.4rem 0.8rem !important; padding: 0.5rem 0.7rem !important; text-align: center; }
body.m-ativo #sourcing-tab .busca-export-acoes .vendor-exportar { min-height: 32px !important; min-width: 0 !important; padding: 0.2rem 0.75rem !important; font-size: 0.72rem !important; }

/* cada PN: titulo e descricao centralizados e compactos */
body.m-ativo #sourcing-tab .pn-title { text-align: center; font-size: 1.15rem !important; letter-spacing: 0.02em; }
body.m-ativo #sourcing-tab .gemini-desc { text-align: center; font-size: 0.78rem !important; line-height: 1.45 !important; padding: 0.45rem 0.6rem !important; border-left: none !important; border-radius: 10px; background: rgba(255, 255, 255, 0.03) !important; }
body.m-ativo #sourcing-tab .pn-group .modern-btn.primary { min-height: 40px !important; font-size: 0.8rem !important; border-radius: 12px !important; }
/* por PN so o filtro e a contagem; tamanho da pagina e exportar por PN saem (a busca inteira ja exporta) */
body.m-ativo #sourcing-tab .vendor-barra .vendor-tamanho,
body.m-ativo #sourcing-tab .vendor-barra .vendor-exportar { display: none !important; }
body.m-ativo #sourcing-tab .vendor-barra-dir { justify-content: center !important; }

/* fornecedores: um por linha, nome e preco em cima, detalhes embaixo */
body.m-ativo #sourcing-tab table.m-vitrine tbody { grid-template-columns: minmax(0, 1fr) !important; gap: 0.45rem !important; }
body.m-ativo #sourcing-tab table.m-vitrine tbody tr:not(:has(td.m-cheia)) {
    display: flex !important; flex-direction: row !important; flex-wrap: wrap; align-items: center; gap: 0.35rem 0.4rem !important;
    padding: 0.7rem 2rem 0.7rem 0.85rem !important; border-radius: 14px; min-height: 64px;
}
body.m-ativo #sourcing-tab table.m-vitrine tbody tr:not(:has(td.m-cheia))::before { content: ''; flex-basis: 100%; height: 0; order: 2; }
body.m-ativo #sourcing-tab table.m-vitrine td:nth-child(1) { order: 0; flex: 1 1 0; min-width: 0; padding-right: 0 !important; font-size: 0.9rem !important; }
body.m-ativo #sourcing-tab table.m-vitrine td:nth-child(1) strong { font-size: 0.9rem !important; }
body.m-ativo #sourcing-tab table.m-vitrine td:nth-child(3) { order: 1; flex: 0 0 auto; margin: 0 !important; font-size: 1.12rem !important; text-align: right; }
body.m-ativo #sourcing-tab table.m-vitrine td:nth-child(5) { order: 3; }
body.m-ativo #sourcing-tab table.m-vitrine td:nth-child(6) { order: 4; }
body.m-ativo #sourcing-tab table.m-vitrine td:nth-child(8) { order: 5; display: inline-flex !important; flex-wrap: wrap; gap: 0.3rem; }
body.m-ativo #sourcing-tab table.m-vitrine td:nth-child(2) { order: 6; margin-left: auto; }
body.m-ativo #sourcing-tab table.m-vitrine td:nth-child(5) .meta-pill,
body.m-ativo #sourcing-tab table.m-vitrine td:nth-child(6) .meta-pill,
body.m-ativo #sourcing-tab table.m-vitrine td:nth-child(8) .meta-pill { font-size: 0.68rem !important; padding: 2px 8px !important; border-radius: 999px !important; white-space: nowrap !important; max-width: 13rem; overflow: hidden; text-overflow: ellipsis; }
body.m-ativo #sourcing-tab table.m-vitrine tr:not(.m-aberto)::after { content: '›'; top: 50%; right: 0.7rem; transform: translateY(-50%); font-size: 1.4rem; color: #64748b; opacity: 1; }
/* aberto: detalhes (UOM, contato, acessar portal) ocupam a largura toda */
body.m-ativo #sourcing-tab table.m-vitrine tr.m-aberto td:nth-child(4),
body.m-ativo #sourcing-tab table.m-vitrine tr.m-aberto td:nth-child(7),
body.m-ativo #sourcing-tab table.m-vitrine tr.m-aberto td:nth-child(9) { order: 7; flex-basis: 100%; }
body.m-ativo #sourcing-tab .pn-group > div:first-child > div:first-child,
body.m-ativo #sourcing-tab .gemini-desc { width: 100% !important; max-width: none !important; box-sizing: border-box; }
/* assistente menor na tela de busca, para nao cobrir os precos */
body.m-ativo[data-m-aba="sourcing"] #ia-dados-fab:not(.ia-fab-livre) { width: 44px !important; height: 44px !important; opacity: 0.9; }

/* =============================================================================
   IA Sourcing no celular -- visual "buscador" (inspirado no Google)
   Fundo liso, sem caixas: resultados em lista com divisorias finas, nome do
   fornecedor como link azul, preco em destaque e detalhes em texto cinza.
   Filtros viram abas de texto. So celular.
   ============================================================================= */
body.m-ativo #sourcing-tab { --g-link: #8ab4f8; --g-cinza: #9aa0a6; --g-linha: rgba(255, 255, 255, 0.08); }

/* cabecalho da busca: sem caixa, como o topo de uma pagina de resultados */
body.m-ativo #sourcing-tab.so-atual #results-tbody > tr:not(.expandable-content-row):has(> td.col-acoes) {
    background: transparent !important; border: none !important; box-shadow: none !important;
    padding: 0.4rem 2.4rem 0.9rem !important; row-gap: 0.25rem !important;
    border-bottom: 1px solid var(--g-linha) !important; border-radius: 0 !important;
}
body.m-ativo #sourcing-tab.so-atual #results-tbody > tr:has(> td.col-acoes) > td:nth-child(2) { color: var(--g-cinza) !important; font-size: 0.7rem !important; }
body.m-ativo #sourcing-tab.so-atual #results-tbody > tr:has(> td.col-acoes) > td.pn-preview { font-size: 1.25rem !important; }
body.m-ativo #sourcing-tab.so-atual #results-tbody > tr:has(> td.col-acoes) > td:nth-child(4) { font-size: 0.72rem !important; color: var(--g-cinza) !important; }
body.m-ativo #sourcing-tab.so-atual #results-tbody td.status-cell .meta-pill { background: transparent !important; border: none !important; padding: 0 !important; font-size: 0.78rem !important; }
body.m-ativo #sourcing-tab.so-atual #results-tbody .delete-search-btn { opacity: 0.45; background: transparent !important; border: none !important; }
body.m-ativo #sourcing-tab .modern-table-container,
body.m-ativo #sourcing-tab #results-tbody > tr.expandable-content-row,
body.m-ativo #sourcing-tab #results-tbody > tr.expandable-content-row > td { background: transparent !important; border: none !important; box-shadow: none !important; }

/* "baixar" e resumo: texto simples, sem caixas */
body.m-ativo #sourcing-tab .busca-export-barra { background: transparent !important; border: none !important; padding: 0.55rem 0 0.2rem !important; font-size: 0.75rem; color: var(--g-cinza); }
body.m-ativo #sourcing-tab .busca-export-rotulo { font-weight: 500 !important; color: var(--g-cinza) !important; font-size: 0.75rem !important; }
body.m-ativo #sourcing-tab .busca-export-acoes .vendor-exportar { background: transparent !important; border: 1px solid var(--g-linha) !important; color: var(--g-link) !important; border-radius: 999px !important; }
body.m-ativo #sourcing-tab .busca-resumo { background: transparent !important; border: none !important; box-shadow: none !important; padding: 0 !important; margin: 0 0 0.3rem !important; }
body.m-ativo #sourcing-tab .busca-ind-linha { display: none !important; }
/* filtros como abas do Google: texto, com sublinhado azul na ativa */
body.m-ativo #sourcing-tab .busca-filtros { gap: 0 !important; border-bottom: 1px solid var(--g-linha); padding-bottom: 0 !important; }
body.m-ativo #sourcing-tab .busca-filtros .busca-filtro {
    background: transparent !important; border: none !important; border-radius: 0 !important; box-shadow: none !important;
    color: var(--g-cinza) !important; font-weight: 500 !important; font-size: 0.82rem !important; padding: 0.55rem 0.75rem !important;
    border-bottom: 3px solid transparent !important; min-height: 40px; white-space: nowrap;
}
body.m-ativo #sourcing-tab .busca-filtros .busca-filtro.ativo { color: var(--g-link) !important; border-bottom-color: var(--g-link) !important; }
body.m-ativo #sourcing-tab .busca-filtros .busca-filtro-texto { order: 9; background: transparent !important; border: none !important; min-width: 9rem; font-size: 16px !important; color: #e8eaed; }

/* cada PN: titulo, descricao em texto cinza, RFQ como botao contornado */
body.m-ativo #sourcing-tab .pn-group { border-bottom: 6px solid rgba(255, 255, 255, 0.03) !important; padding: 1rem 0 0.6rem !important; }
body.m-ativo #sourcing-tab .pn-title { font-size: 1.3rem !important; color: #e8eaed !important; margin-bottom: 0.1rem; border: none !important; }
body.m-ativo #sourcing-tab .pn-group > div:first-child > div:first-child { border: none !important; }
body.m-ativo #sourcing-tab .gemini-desc { background: transparent !important; border: none !important; padding: 0 0.2rem !important; color: var(--g-cinza) !important; font-size: 0.76rem !important; }
body.m-ativo #sourcing-tab .gemini-desc b, body.m-ativo #sourcing-tab .gemini-desc strong { color: #bdc1c6 !important; font-weight: 600; }
body.m-ativo #sourcing-tab .pn-group .modern-btn.primary {
    background: transparent !important; border: 1px solid rgba(138, 180, 248, 0.45) !important; color: var(--g-link) !important;
    border-radius: 999px !important; min-height: 38px !important; width: auto !important; align-self: center; padding: 0.35rem 1.1rem !important; box-shadow: none !important;
}
/* busca de fornecedor: campo em pilula; condicoes como pilulas finas */
body.m-ativo #sourcing-tab .vendor-busca { background: rgba(255, 255, 255, 0.04) !important; border: 1px solid var(--g-linha) !important; border-radius: 999px !important; }
body.m-ativo #sourcing-tab .vendor-contagem { color: var(--g-cinza) !important; font-size: 0.72rem !important; }
body.m-ativo #sourcing-tab .cond-chips { background: transparent !important; border: none !important; gap: 0.35rem !important; padding: 0.4rem 0 !important; }
body.m-ativo #sourcing-tab .cond-chip { background: transparent !important; border: 1px solid var(--g-linha) !important; border-radius: 999px !important; min-height: 32px !important; padding: 0.15rem 0.8rem !important; font-size: 0.75rem !important; box-shadow: none !important; }
body.m-ativo #sourcing-tab .cond-chip.ativo { background: rgba(138, 180, 248, 0.16) !important; border-color: rgba(138, 180, 248, 0.5) !important; color: var(--g-link) !important; }
body.m-ativo #sourcing-tab .cond-chip.vazio { opacity: 0.35; }

/* fornecedores: lista com divisorias, sem cartoes */
body.m-ativo #sourcing-tab table.m-vitrine tbody { gap: 0 !important; padding: 0 !important; }
body.m-ativo #sourcing-tab table.m-vitrine tbody tr:not(:has(td.m-cheia)) {
    background: transparent !important; border: none !important; border-bottom: 1px solid var(--g-linha) !important; border-radius: 0 !important;
    box-shadow: none !important; padding: 0.8rem 1.8rem 0.8rem 0.15rem !important; min-height: 0; gap: 0.25rem 0 !important;
}
body.m-ativo #sourcing-tab table.m-vitrine tbody tr.inner-best-row { box-shadow: none !important; border-bottom-color: rgba(52, 211, 153, 0.35) !important; }
body.m-ativo #sourcing-tab table.m-vitrine td:nth-child(1),
body.m-ativo #sourcing-tab table.m-vitrine td:nth-child(1) strong { color: var(--g-link) !important; font-weight: 500 !important; font-size: 1rem !important; }
body.m-ativo #sourcing-tab table.m-vitrine td:nth-child(1) .best-badge { background: transparent !important; border: none !important; padding: 0 !important; color: #34d399 !important; font-size: 0.66rem !important; letter-spacing: 0.04em; }
body.m-ativo #sourcing-tab table.m-vitrine td:nth-child(3) { color: #e8eaed !important; font-weight: 600 !important; font-size: 1.05rem !important; }
body.m-ativo #sourcing-tab table.m-vitrine td:nth-child(3).best { color: #34d399 !important; }
/* detalhes como texto cinza separado por pontos */
body.m-ativo #sourcing-tab table.m-vitrine td:nth-child(5) .meta-pill,
body.m-ativo #sourcing-tab table.m-vitrine td:nth-child(6) .meta-pill,
body.m-ativo #sourcing-tab table.m-vitrine td:nth-child(8) .meta-pill,
body.m-ativo #sourcing-tab table.m-vitrine td:nth-child(2) .meta-pill {
    background: transparent !important; border: none !important; padding: 0 !important; color: var(--g-cinza) !important;
    font-size: 0.74rem !important; font-weight: 400 !important; letter-spacing: 0 !important; opacity: 1 !important; box-shadow: none !important;
}
body.m-ativo #sourcing-tab table.m-vitrine td:nth-child(6) .meta-pill::before,
body.m-ativo #sourcing-tab table.m-vitrine td:nth-child(8) .meta-pill::before,
body.m-ativo #sourcing-tab table.m-vitrine td:nth-child(2) .meta-pill::before { content: '\00B7'; margin: 0 0.4rem; color: #5f6368; }
body.m-ativo #sourcing-tab table.m-vitrine td:nth-child(8) { gap: 0 !important; }
body.m-ativo #sourcing-tab table.m-vitrine td:nth-child(2) { margin-left: 0 !important; }
body.m-ativo #sourcing-tab table.m-vitrine tr:not(.m-aberto)::after { color: #5f6368; font-size: 1.2rem; }
body.m-ativo #sourcing-tab table.m-vitrine tr.m-aberto { background: rgba(138, 180, 248, 0.06) !important; border-radius: 12px !important; padding-left: 0.6rem !important; }

/* barra de busca: pilula com sombra suave */
body.m-ativo #sourcing-tab #pn-input { border-radius: 999px !important; background: #303134 !important; border: 1px solid #5f6368 !important; box-shadow: 0 1px 6px rgba(0, 0, 0, 0.35); }
body.m-ativo #sourcing-tab #pn-input:focus { border-radius: 18px !important; }
body.m-ativo #sourcing-tab table.m-vitrine td:nth-child(n+2) { align-self: center; line-height: 1.35 !important; }
body.m-ativo #sourcing-tab table.m-vitrine td .meta-pill { line-height: 1.35 !important; vertical-align: baseline !important; display: inline !important; margin: 0 !important; }

/* ===== Ajustes de UI no celular (17/11/2026) ===== */
/* Pedido: os campos saiam da tela (535 px numa tela de 390) */
body.m-ativo .ped-grade { grid-template-columns: repeat(2, minmax(0, 1fr)); }
body.m-ativo .ped-grade-3 { grid-template-columns: minmax(0, 1fr); }
body.m-ativo .ped-campo, body.m-ativo .ped-campo input, body.m-ativo .ped-campo select { min-width: 0; width: 100%; }
/* Janelas dos Rotaveis: rodape com os botoes fica acima da barra de baixo */
body.m-ativo .rot-modal-fundo { padding-bottom: calc(var(--m-barra-h, 64px) + var(--m-seguro, 0px) + 8px); z-index: 4000; }
body.m-ativo .rot-modal, body.m-ativo .rot-modal.modal-content { max-height: calc(100dvh - var(--m-barra-h, 64px) - var(--m-seguro, 0px) - 24px); }
/* Ultimos itens rolam acima da barra de baixo e do assistente */
body.m-ativo #rotaveis-tab.rot { padding-bottom: calc(var(--m-barra-h, 64px) + var(--m-seguro, 0px) + 80px); }
/* Cartao da cotacao: titulo longo sem espacos (RE: RFQ - RC 103018/103019/...) quebrava para fora */
body.m-ativo #crm-quote-modal .cq-titulo { overflow-wrap: anywhere; word-break: break-word; }
/* Rodape do cartao: "Gerar Template" cabia cortado; mais espaco e reticencias de verdade */
body.m-ativo #crm-quote-modal .cq-rodape-dir { grid-template-columns: 44px 44px 1.3fr 1fr !important; }
body.m-ativo #crm-quote-modal #crm-quote-template, body.m-ativo #crm-quote-modal .cq-rodape-dir .modern-btn.primary { font-size: 0.78rem !important; display: block !important; text-align: center; line-height: 44px; }

/* 17/11/2026: graficos dos Rotaveis no celular */
body.m-ativo .rot-graf { font-size: 12px; }

/* 17/11/2026: cadastro de PNs dos Rotaveis no celular */
body.m-ativo .rot-modal-cad { width: 100vw; }
body.m-ativo .rot-cad-barra input[type="search"] { min-width: 0; width: 100%; }
body.m-ativo .rot-cad-grade { grid-template-columns: 1fr 1fr; }
body.m-ativo .rot-cad-campo input, body.m-ativo .rot-cad-campo select, body.m-ativo .rot-cad-campo textarea { font-size: 16px; }
body.m-ativo .rot-cad-lista { max-height: 40vh; }
body.m-ativo .rot-cad-meio { grid-template-columns: 1fr; }
body.m-ativo .rot-cad-meio .rot-cad-lista { max-height: 40vh; }
body.m-ativo .rot-cad-meio #rot-cad-form { max-height: none; overflow: visible; }

/* 17/11/2026: assinatura no celular */
body.m-ativo #ass-trava { padding: 12px; }
body.m-ativo .ass-caixa { padding: 1.1rem; }
body.m-ativo .ass-regiao { align-self: stretch; }
body.m-ativo .ass-regiao button { flex: 1; padding: 0.55rem 0.4rem; }
body.m-ativo .ass-aviso { top: auto; bottom: calc(var(--m-barra-h, 64px) + var(--m-seguro, 0px) + 10px); border-radius: 14px; width: calc(100vw - 24px); flex-wrap: wrap; }
body.m-ativo .ass-modal { width: 100vw; max-height: calc(100dvh - var(--m-barra-h, 64px) - var(--m-seguro, 0px) - 24px); }
body.m-ativo .ass-resumo { grid-template-columns: 1fr; gap: 0.1rem; }
body.m-ativo .ass-resumo dd { margin-bottom: 0.5rem; }
body.m-ativo.ass-bloqueado #ass-trava { padding-bottom: 24px; }
