/* =====================================================================
   Detona Affiliates: CELULAR E TABLET (ate 900px).
   Carrega DEPOIS de painel.css e tema-claro.css. Tudo aqui mora dentro do
   @media, entao o desktop nao muda nada.

   Medido em 11/10 nas 28 telas (375px):
   - a .layout era flex "column wrap": com wrap o conteudo ganha a largura
     da maior tabela (845px numa tela de 375) e a pagina inteira rolava
     de lado. Por isso as caixas de rolagem das tabelas nao funcionavam.
   - o menu virava uma faixa de 260 a 440px de altura com os itens cortados.
   - campo com fonte menor que 16px faz o iPhone dar zoom ao tocar.
   - tabela espremida em 9 a 10px, ilegivel.
   ===================================================================== */

/* pecas que so' existem no celular */
.mbar, .mbar-fundo, .sb-fechar, .mnav { display: none; }

@media (max-width: 900px) {

  /* ── 1. ESQUELETO: uma coluna do tamanho da tela ─────────────────── */
  body { overflow-x: clip !important; }
  body.menu-aberto { overflow: hidden !important; }

  .layout {
    display: block !important;
    padding: 0 !important;
    min-height: 100vh;
  }
  .content {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    padding: 16px 14px 40px !important;
  }

  /* ── 2. BARRA DO TOPO (logo + menu) ──────────────────────────────── */
  .mbar {
    display: flex;
    align-items: center;
    gap: 8px;
    position: sticky;
    top: 0;
    z-index: 900;
    min-height: 56px;
    padding: env(safe-area-inset-top) 12px 0 4px;
    background: #FFFFFF;
    border-bottom: 1px solid var(--ln);
  }
  .mbar__menu {
    flex: 0 0 44px;
    width: 44px;
    height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--text);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }
  .mbar__menu:active { background: var(--ln-soft); }
  .mbar__menu svg { width: 24px; height: 24px; }
  .mbar__logo { height: 22px; width: auto; display: block; filter: none !important; }
  .mbar__papel {
    margin-left: auto;
    padding: 5px 10px;
    border-radius: 999px;
    background: var(--glass-bg-active);
    color: var(--accent-hover);
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    white-space: nowrap;
  }

  /* ── 3. MENU VIRA GAVETA LATERAL (igual ao menu do computador) ───── */
  .sidebar {
    position: fixed !important;
    top: 0 !important;
    bottom: 0 !important;
    left: 0 !important;
    height: 100% !important;
    max-height: none !important;
    width: min(84vw, 300px) !important;
    min-width: 0 !important;
    max-width: none !important;
    flex: none !important;
    z-index: 1000 !important;
    margin: 0 !important;
    padding: 0 0 calc(24px + env(safe-area-inset-bottom)) !important;
    border: 0 !important;
    border-right: 1px solid var(--ln) !important;
    border-radius: 0 !important;
    background: #FFFFFF !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    overscroll-behavior: contain;
    -webkit-mask-image: none !important;
            mask-image: none !important;
    transform: translateX(-104%);
    transition: transform 0.24s ease;
    box-shadow: none;
  }
  body.menu-aberto .sidebar {
    transform: translateX(0);
    box-shadow: 0 0 40px rgba(17, 24, 39, 0.18);
  }
  .sb-fechar {
    display: flex;
    position: absolute;
    top: 10px;
    right: 8px;
    z-index: 2;
    width: 40px;
    height: 40px;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
  }
  .sb-fechar svg { width: 22px; height: 22px; }
  .sidebar .logo { display: block !important; padding: 24px 20px 12px !important; }
  .sidebar .logo img { max-width: 150px; }
  .sidebar nav {
    display: block !important;
    width: auto !important;
    overflow: visible !important;
    padding: 14px 12px 0 !important;
    scroll-snap-type: none !important;
    touch-action: auto !important;
  }
  .sidebar nav hr { display: none !important; }   /* o Sair ja tem a linha dele em cima */
  .sidebar nav a {
    white-space: normal !important;
    flex-shrink: 1 !important;
    min-height: 46px;
    padding: 11px 12px !important;
    font-size: 15px !important;
    border-radius: var(--r-sm) !important;
    scroll-snap-align: none !important;
  }
  .sidebar nav a:hover { padding-left: 12px !important; }
  .sidebar nav a.active { background: #FEF2F2 !important; color: var(--accent-hover) !important; }

  .mbar-fundo {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 950;
    background: rgba(17, 24, 39, 0.45);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
  }
  body.menu-aberto .mbar-fundo { opacity: 1; pointer-events: auto; }

  /* ── BARRA DE NAVEGACAO DE BAIXO (navbar do celular) ─────────────── */
  /* atalhos dos itens principais de cada papel; o resto fica no Menu (gaveta) */
  .mnav {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(0, 1fr);
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 940;                      /* abaixo do fundo escuro (950) e da gaveta (1000) */
    padding: 4px 4px env(safe-area-inset-bottom);
    background: #FFFFFF;
    border-top: 1px solid var(--ln);
    box-shadow: 0 -4px 16px rgba(17, 24, 39, 0.06);
  }
  .mnav__item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-width: 0;
    min-height: 58px;
    padding: 4px 2px 6px;
    border: 0;
    background: transparent;
    color: var(--text-muted);
    font-family: inherit;
    font-size: 11px;
    font-weight: 600;
    line-height: 1.2;
    text-decoration: none;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }
  .mnav__item > span:last-child { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .mnav__ic {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 30px;
    border-radius: 999px;
    transition: background 0.15s ease;
  }
  .mnav__ic::before {
    content: "";
    width: 22px;
    height: 22px;
    background: currentColor;
    -webkit-mask: var(--ic) center / 22px 22px no-repeat;
            mask: var(--ic) center / 22px 22px no-repeat;
  }
  .mnav__item.is-on { color: var(--accent-hover); }
  .mnav__item.is-on .mnav__ic { background: #FEF2F2; }
  .mnav__item:active .mnav__ic { background: var(--ln-soft); }
  .mnav__ic--home { --ic: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><line x1='18' y1='20' x2='18' y2='10'/><line x1='12' y1='20' x2='12' y2='4'/><line x1='6' y1='20' x2='6' y2='14'/></svg>"); }
  .mnav__ic--usuarios { --ic: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2'/><circle cx='9' cy='7' r='4'/><path d='M23 21v-2a4 4 0 0 0-3-3.87'/></svg>"); }
  .mnav__ic--rede { --ic: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2'/><circle cx='9' cy='7' r='4'/><path d='M23 21v-2a4 4 0 0 0-3-3.87'/></svg>"); }
  .mnav__ic--links { --ic: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='M10 13a5 5 0 0 0 7.5.5l3-3a5 5 0 0 0-7-7l-1.5 1.5'/><path d='M14 11a5 5 0 0 0-7.5-.5l-3 3a5 5 0 0 0 7 7l1.5-1.5'/></svg>"); }
  .mnav__ic--saques { --ic: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='M20 12V8H6a2 2 0 0 1 0-4h12v4'/><path d='M4 6v12a2 2 0 0 0 2 2h14v-4'/><path d='M18 12a2 2 0 0 0 0 4h4v-4z'/></svg>"); }   /* carteira: nao confundir com o $ de Ganhos */
  .mnav__ic--ganhos { --ic: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><line x1='12' y1='1' x2='12' y2='23'/><path d='M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6'/></svg>"); }
  .mnav__ic--tabela { --ic: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><rect x='3' y='4' width='18' height='18' rx='2'/><line x1='3' y1='10' x2='21' y2='10'/><line x1='9' y1='4' x2='9' y2='22'/></svg>"); }
  .mnav__ic--resultados { --ic: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='23 6 13.5 15.5 8.5 10.5 1 18'/><polyline points='17 6 23 6 23 12'/></svg>"); }
  .mnav__ic--menu { --ic: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><line x1='4' y1='6' x2='20' y2='6'/><line x1='4' y1='12' x2='20' y2='12'/><line x1='4' y1='18' x2='20' y2='18'/></svg>"); }
  /* o conteudo nao pode ficar escondido atras da barra */
  body:has(.mnav) .content { padding-bottom: calc(92px + env(safe-area-inset-bottom)) !important; }

  /* ── 4. TEXTO E CARTOES ──────────────────────────────────────────── */
  .content h1 { font-size: 22px !important; line-height: 1.25 !important; margin-bottom: 12px; word-break: break-word; }
  .content h3 { font-size: 16px; }
  .card { padding: 16px !important; border-radius: 12px !important; }
  /* titulo de card (Novo gerente, Sub-gerentes...) ficava MAIOR que o titulo da pagina */
  /* (o tema poe 26px em todo h2/h3 COM style dentro de card, pensando nos numeros
     grandes; titulo que so tem margem no style tambem caia nessa) */
  .content .card > h2:not([style]),
  .content .card > div > h2:not([style]),
  .content .card > h3[style]:not([style*="font-size"]),
  .content .card > div > h3[style]:not([style*="font-size"]) { font-size: 18px !important; line-height: 1.3 !important; }
  /* tabela sem nenhuma linha (so o cabecalho) some; o aviso "Nenhum..." ja diz tudo */
  /* (:has dentro de :has e' invalido e o navegador joga a regra fora calado) */
  .content .table-wrap:not(:has(tbody tr)) { display: none; }

  /* faixa "Visualizando como" do admin */
  .content > div[style*="justify-content:space-between"] { flex-wrap: wrap; gap: 6px; }

  /* item com grid-column inline (ex.: Endereco "1/3" nas Configuracoes): com a grade
     forcada em 1 coluna, o "1/3" criava uma 2a coluna escondida e espremia o vizinho */
  .content [style*="grid-template-columns"] > [style*="grid-column"] { grid-column: 1 / -1 !important; }

  /* cabecalho de card com botao do lado: quebra em vez de vazar */
  .content .flex.justify-between { flex-wrap: wrap !important; gap: 10px; }
  .content .flex.justify-between > * { min-width: 0; }

  /* ── 5. CARTOES DE NUMERO: 2 por linha ───────────────────────────── */
  /* grade de cards de numero (tem h2, nao tem tabela nem formulario) */
  .content [style*="grid-template-columns"]:has(> .card h2):not(:has(table, form)) {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 10px !important;
  }
  .content [style*="grid-template-columns"]:has(> .card h2):not(:has(table, form)) > .card {
    padding: 14px !important;
    margin: 0 !important;
  }
  /* numero impar: o ultimo ocupa a linha inteira em vez de sobrar buraco */
  .content [style*="grid-template-columns"]:has(> .card h2):not(:has(table, form)) > .card:last-child:nth-child(odd) {
    grid-column: 1 / -1;
  }
  .content [style*="grid-template-columns"]:has(> .card h2):not(:has(table, form)) > .card h2,
  .content [style*="grid-template-columns"]:has(> .card h2):not(:has(table, form)) > .card h2[style] {
    font-size: 20px !important;
    line-height: 1.15 !important;
    word-break: break-word;
  }

  /* quadradinhos de numero feitos com grade auto-fit de minmax pequeno (Dashboard
     e Top Usuarios do admin). O painel.css forcava 1 coluna em TODA grade e eles
     empilhavam 11 cards de altura cheia. */
  .content [style*="grid-template-columns:repeat(auto-fit,minmax(130px"]:not(:has(input, select, textarea)),
  .content [style*="grid-template-columns:repeat(auto-fit,minmax(140px"]:not(:has(input, select, textarea)),
  .content [style*="grid-template-columns:repeat(auto-fit,minmax(150px"]:not(:has(input, select, textarea)),
  .content [style*="grid-template-columns:repeat(auto-fit,minmax(160px"]:not(:has(input, select, textarea)),
  .content [style*="grid-template-columns:repeat(auto-fit,minmax(180px"]:not(:has(input, select, textarea)) {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 8px !important;
  }
  .content [style*="grid-template-columns:repeat(auto-fit,minmax(130px"] > :last-child:nth-child(odd),
  .content [style*="grid-template-columns:repeat(auto-fit,minmax(140px"] > :last-child:nth-child(odd) { grid-column: 1 / -1; }
  /* Bruto | Distribuido | Lucro do Dashboard: 2 lado a lado e o lucro embaixo, inteiro */
  .content [style*="grid-template-columns:repeat(3,1fr)"]:not(:has(form, table, input, select)) {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 8px !important;
  }
  .content [style*="grid-template-columns:repeat(3,1fr)"]:not(:has(form, table, input, select)) > :last-child:nth-child(odd) { grid-column: 1 / -1; }
  /* rotulo de 9px era ilegivel no celular */
  .content [style*="grid-template-columns:repeat(auto-fit,minmax(1"] > div > [style*="font-size:9px"] { font-size: 10.5px !important; }

  /* ── 6. CAMPOS E BOTOES ──────────────────────────────────────────── */
  /* 16px e' o minimo pro iPhone NAO dar zoom quando a pessoa toca no campo */
  input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([type="range"]),
  select,
  textarea {
    font-size: 16px !important;
    min-height: 44px;
    max-width: 100%;
  }
  .btn { min-height: 42px; }
  .btn.btn-ghost { min-height: 36px; }

  /* filtro de periodo (formularios GET em linha): 2 por linha */
  .content form[method="GET" i][style*="display:flex"],
  .content form[method="GET" i][style*="display: flex"] {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px !important;
    align-items: end !important;
  }
  .content form[method="GET" i][style*="display:flex"] > *,
  .content form[method="GET" i][style*="display: flex"] > * {
    width: auto !important;
    min-width: 0 !important;
    margin: 0 !important;
    flex: none !important;
  }
  .content form[method="GET" i][style*="display:flex"] input,
  .content form[method="GET" i][style*="display: flex"] input,
  .content form[method="GET" i][style*="display:flex"] select,
  .content form[method="GET" i][style*="display: flex"] select { width: 100% !important; min-width: 0 !important; }
  .content form[method="GET" i][style*="display:flex"] > .btn,
  .content form[method="GET" i][style*="display: flex"] > .btn { width: 100%; justify-content: center; }
  /* filtro com classe .flex (Comissoes do admin): mesma grade de 2 */
  .content form[method="GET" i].flex:has(input[type="date"]) {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px !important;
    align-items: end !important;
  }
  .content form[method="GET" i].flex:has(input[type="date"]) > * {
    width: auto !important;
    min-width: 0 !important;
    margin: 0 !important;
    flex: none !important;
  }
  .content form[method="GET" i].flex:has(input[type="date"]) input,
  .content form[method="GET" i].flex:has(input[type="date"]) select { width: 100% !important; min-width: 0 !important; }
  .content form[method="GET" i].flex:has(input[type="date"]) > .btn { width: 100%; justify-content: center; }
  .content form[method="GET" i].flex:has(input[type="date"]) > :not(.btn) + .btn:last-child { grid-column: 1 / -1; }

  /* busca por texto ocupa a linha inteira; num filtro de datas, o select tambem */
  .content form[method="GET" i] > .form-group:has(input[type="text"], input[type="search"]) { grid-column: 1 / -1; }
  .content form[method="GET" i]:has(input[type="date"]) > .form-group:has(select) { grid-column: 1 / -1; }
  /* botao sozinho (sem outro botao do lado) ocupa a linha inteira; dois botoes ficam lado a lado */
  .content form[method="GET" i][style*="display:flex"] > :not(.btn) + .btn:last-child,
  .content form[method="GET" i][style*="display: flex"] > :not(.btn) + .btn:last-child { grid-column: 1 / -1; }

  /* formulario com o botao de enviar NO MEIO (Novo periodo: grade com o botao e,
     depois dela, mais campos). No celular o botao vai pro fim, senao parece que o
     formulario acaba antes da Meta. */
  .content form:has(> div[style*="display:grid"] > .btn[type="submit"]):has(> div[style*="display:grid"] + div) {
    display: flex !important;
    flex-direction: column;
    gap: 12px;
  }
  .content form:has(> div[style*="display:grid"] > .btn[type="submit"]):has(> div[style*="display:grid"] + div) > div[style*="display:grid"] { display: contents !important; }
  .content form:has(> div[style*="display:grid"] > .btn[type="submit"]):has(> div[style*="display:grid"] + div) .form-group { margin: 0 !important; }
  .content form:has(> div[style*="display:grid"] > .btn[type="submit"]):has(> div[style*="display:grid"] + div) > div[style*="display:grid"] > .btn[type="submit"] {
    order: 99;
    width: 100%;
    justify-content: center;
  }
  /* caixinha de marcar com explicacao: o texto quebra embaixo, alinhado */
  .content label:has(> input[type="checkbox"]) { flex-wrap: wrap; row-gap: 2px; }
  .content label:has(> input[type="checkbox"]) > .text-muted { flex: 1 1 100%; padding-left: 24px; }

  /* acordo da DetonaBet no admin (rotulo | real | que ele ve): continua em 3 colunas */
  .content form[style*="grid-template-columns:110px"] {
    grid-template-columns: 86px minmax(0, 1fr) minmax(0, 1fr) !important;
    gap: 8px !important;
  }
  .content form[style*="grid-template-columns:110px"] .form-label { font-size: 12px !important; }

  /* abas (Meus Ganhos): sublinhado, nao caixinha. O JS troca a classe .active */
  .content .tab-btn {
    border: 0 !important;
    border-bottom: 2px solid transparent !important;
    border-radius: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    padding: 10px 12px !important;
    min-height: 44px;
    color: var(--text-muted);
    font-weight: 600;
  }
  .content .tab-btn.active { border-bottom-color: var(--accent) !important; color: var(--text) !important; }

  /* ── SELETOR DE PERIODO (Dashboard, Tabela...): vira painel de baixo ── */
  /* No desktop e' um dropdown de 460px preso a direita do botao; no celular
     ele abria 300px pra FORA da tela, com os 2 meses espremidos em 101px. */
  #dpDrop {
    position: fixed !important;
    top: auto !important;
    right: 0 !important;
    bottom: 0 !important;
    left: 0 !important;
    width: 100% !important;
    min-width: 0 !important;        /* o JS poe min-width:460px inline */
    max-height: 88vh;
    overflow-x: hidden !important;  /* e overflow:hidden inline, que travava a rolagem */
    overflow-y: auto !important;
    padding: 16px 14px 0 !important;
    border-radius: 18px 18px 0 0 !important;
    z-index: 1100 !important;
    background: #FFFFFF !important;
    backdrop-filter: none !important;
    /* a sombra gigante escurece a pagina atras sem precisar de markup novo */
    box-shadow: 0 0 0 100vmax rgba(17, 24, 39, 0.4) !important;
    overscroll-behavior: contain;
  }
  /* o bloco em volta do seletor tem a animacao fade-up (transform). Transform num
     ancestral faz o position:fixed grudar NELE e nao na tela: o painel abria
     fora do lugar se tocasse durante a animacao (ou num celular lento). */
  .content :has(#dpDrop) { animation: none !important; transform: none !important; }
  #dpDrop > div { flex-direction: column !important; gap: 14px !important; }
  /* atalhos (Hoje, Ontem, 7 dias...) viram fichas em linha */
  #dpDrop > div > div:first-child {
    flex-direction: row !important;
    flex-wrap: wrap !important;
    gap: 6px !important;
    width: 100% !important;
  }
  #dpDrop .dp-sc,
  #dpDrop .dp-shortcut {   /* Tabela usa .dp-sc, Dashboard usa .dp-shortcut */
    width: auto !important;
    min-height: 36px;
    padding: 8px 12px !important;
    border: 1px solid var(--ln) !important;
    border-radius: 999px !important;
    font-size: 13px !important;
  }
  #dpDrop > div > div:last-child { width: 100% !important; }
  #dpCals { flex-direction: column !important; gap: 18px !important; width: 100% !important; }
  #dpDrop .dp-cal { min-width: 0 !important; width: 100% !important; }
  #dpDrop .dp-hd span { font-size: 15px !important; }
  #dpDrop .dp-hd button { min-width: 44px; min-height: 40px; font-size: 20px !important; }
  #dpDrop .dp-g { gap: 2px !important; }
  #dpDrop .dp-g .dw { font-size: 11px !important; padding: 6px 0 !important; }
  #dpDrop .dp-g .dd,
  #dpDrop .dp-grid .dp-day { height: 40px; padding: 0 !important; line-height: 40px; font-size: 15px !important; }   /* Dashboard: .dp-grid/.dp-day */
  /* Cancelar | Aplicar grudados no pe' do painel */
  #dpDrop > div > div:last-child > div:last-child {
    position: sticky;
    bottom: 0;
    gap: 10px !important;
    margin-top: 6px !important;
    padding: 12px 0 calc(14px + env(safe-area-inset-bottom)) !important;
    background: #FFFFFF;
  }
  #dpCancel, #dpApply { flex: 1 1 0; justify-content: center; min-height: 46px; }

  /* arvore da Rede (admin): nome comprido quebra linha em vez de empurrar a
     etiqueta "gerente" pra cima do olho */
  .content .tree-row > a:first-of-type { flex: 1 1 0; min-width: 0; overflow-wrap: anywhere; }
  .content .tree-row > .badge,
  .content .tree-row > span:not(:first-child),
  .content .tree-row > a:last-of-type:not(:first-of-type) { flex-shrink: 0; white-space: nowrap; }

  /* ── 7. TABELAS: legiveis e rolando dentro da propria caixa ──────── */
  .table-wrap {
    border-radius: 10px;
    -webkit-overflow-scrolling: touch;
    /* sombra no lado que ainda tem coluna escondida */
    background:
      linear-gradient(to right, #FFFFFF 30%, rgba(255, 255, 255, 0)),
      linear-gradient(to left, #FFFFFF 30%, rgba(255, 255, 255, 0)) 100% 0,
      radial-gradient(farthest-side at 0 50%, rgba(17, 24, 39, 0.16), rgba(17, 24, 39, 0)),
      radial-gradient(farthest-side at 100% 50%, rgba(17, 24, 39, 0.16), rgba(17, 24, 39, 0)) 100% 0;
    background-repeat: no-repeat;
    background-size: 40px 100%, 40px 100%, 14px 100%, 14px 100%;
    background-attachment: local, local, scroll, scroll;
  }
  /* a tabela fica do tamanho do conteudo e ROLA dentro da caixa. Espremida na
     largura da tela, a coluna de Acoes empilhava os botoes e cada linha virava 160px */
  .table-wrap > table { width: max-content !important; min-width: 100% !important; }
  .table-wrap > table td .flex,
  .table-wrap > table td [style*="flex-wrap:wrap"] { flex-wrap: nowrap !important; }

  main .table th,
  main .table td,
  .table-wrap > table:not(.table) > thead > tr > th,
  .table-wrap > table:not(.table) > tbody > tr > td,
  .table-wrap > table:not(.table) > tr > td {
    font-size: 13px !important;
    padding: 11px 12px !important;
    white-space: nowrap !important;
    overflow: visible !important;
    text-overflow: clip !important;
    letter-spacing: 0 !important;
  }
  main .table th,
  .table-wrap > table:not(.table) > thead > tr > th {
    font-size: 11px !important;
    letter-spacing: 0.04em !important;
  }
  main .table th[data-short]::after { font-size: 11px !important; }
  /* linha de aviso que ocupa a tabela toda ("Nenhum afiliado...") quebra e fica
     visivel, em vez de sumir pro lado junto com as colunas */
  .table-wrap > table td[colspan] {
    white-space: normal !important;
    text-align: left !important;
    position: sticky;
    left: 0;
    max-width: calc(100vw - 60px);
  }
  main .table td:first-child, main .table th:first-child { padding-left: 12px !important; }
  main .table td:last-child,  main .table th:last-child  { padding-right: 12px !important; }
}

/* telefone: respiro um pouco menor */
@media (max-width: 380px) {
  .content { padding: 14px 12px 36px !important; }
  .card { padding: 14px !important; }
  .content [style*="grid-template-columns"]:has(> .card h2):not(:has(table, form)) > .card h2,
  .content [style*="grid-template-columns"]:has(> .card h2):not(:has(table, form)) > .card h2[style] { font-size: 18px !important; }
}

