    /* variáveis de cor/forma: ver /public/css/tokens.css */

    * { box-sizing: border-box; }
    body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; margin: 0; background: var(--bg); color: var(--text); }

    .layout { display: flex; min-height: 100vh; }

    aside { width: 200px; flex-shrink: 0; background: var(--sidebar); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; transition: width 0.15s ease; }
    aside .brand { padding: 24px 20px; text-align: center; }
    aside .brand img { width: 100%; max-width: 120px; transition: opacity 0.1s; }
    aside nav { padding: 0 12px; }
    aside .grp-title { color: #6b6b6b; font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em; padding: 14px 24px 4px; }
    aside.recolhido .grp-title { visibility: hidden; height: 8px; padding: 8px 0 0; }
    aside nav a { display: flex; align-items: center; gap: 10px; color: #ababab; text-decoration: none; font-size: 14px; padding: 10px 12px; border-radius: 6px; margin-bottom: 2px; white-space: nowrap; overflow: hidden; }
    aside nav a svg { flex-shrink: 0; }
    aside nav a:hover { background: rgba(255,255,255,0.06); color: #fff; }
    aside nav a.active { background: var(--pink); color: #fff; }
    aside .userbox { padding: 16px 20px; border-top: 1px solid rgba(255,255,255,0.1); }
    aside .userbox form { margin: 0; }
    aside .userbox button { background: none; border: none; color: #ababab; cursor: pointer; font-size: 13px; padding: 0; }
    aside .userbox button:hover { color: #fff; }

    .menu-recolher-wrap { padding: 4px 12px 12px; }
    .menu-recolher { display: flex; align-items: center; gap: 8px; width: 100%; background: none; border: none; color: #767676; cursor: pointer; font-size: 12px; padding: 8px 12px; border-radius: 6px; white-space: nowrap; overflow: hidden; }
    .menu-recolher:hover { background: rgba(255,255,255,0.06); color: #fff; }
    .menu-recolher svg { flex-shrink: 0; transition: transform 0.15s ease; }

    aside.recolhido { width: 64px; }
    aside.recolhido .brand img { opacity: 0; width: 0; max-width: 0; }
    aside.recolhido .search-trigger span, aside.recolhido .search-trigger kbd { display: none; }
    aside.recolhido .search-trigger { justify-content: center; }
    aside.recolhido nav a span, aside.recolhido .userbox > div, aside.recolhido .userbox a span, aside.recolhido .userbox button span { display: none; }
    aside.recolhido nav a { justify-content: center; }
    aside.recolhido .userbox { text-align: center; }
    aside.recolhido .userbox a { display: flex; justify-content: center; }
    aside.recolhido .userbox button { display: flex; justify-content: center; width: 100%; }
    aside.recolhido .menu-recolher span { display: none; }
    aside.recolhido .menu-recolher { justify-content: center; }
    aside.recolhido .menu-recolher svg { transform: rotate(180deg); }

    /* min-width:0: sem isso o conteúdo largo (tabela, kanban, texto longo) impede o main de encolher e a página vaza pra direita */
    main { flex: 1; min-width: 0; max-width: 1480px; margin: 0; padding: 32px; width: 100%; }

    /* Menu lateral vira "gaveta" em telas pequenas — sem isso o conteúdo
       ficava espremido numa coluna estreita ao lado do menu fixo de 200px. */
    .mobile-topbar { display: none; }
    .aside-backdrop { display: none; }
    @media (max-width: 768px) {
      .mobile-topbar {
        display: flex; align-items: center; gap: 12px;
        position: fixed; top: 0; left: 0; right: 0; height: 56px;
        background: var(--sidebar); padding: 0 16px; z-index: 1100;
      }
      .mobile-topbar img { height: 36px; }
      .mobile-topbar svg { width: 22px; height: 22px; }
      .mobile-topbar button {
        background: none; border: none; color: #fff; padding: 8px;
        display: flex; align-items: center; cursor: pointer;
      }
      .layout { display: block; }
      aside {
        position: fixed; top: 0; left: 0; height: 100vh; width: 240px;
        transform: translateX(-100%); visibility: hidden; transition: transform 0.2s ease, visibility 0s linear 0.2s; z-index: 1200;
        overflow-y: auto;
      }
      aside.aberto { transform: translateX(0); visibility: visible; transition: transform 0.2s ease, visibility 0s; }
      .aside-backdrop.aberto {
        display: block; position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 1150;
      }
      /* "recolhido" (menu recolhido) é um conceito só de desktop — a
         gaveta mobile sempre abre completa, com rótulo, independente do
         que foi salvo no localStorage pra tela grande */
      aside.recolhido { width: 240px; }
      aside.recolhido .brand img { opacity: 1; width: 100%; max-width: 120px; }
      aside.recolhido .search-trigger { justify-content: flex-start; }
      aside.recolhido .search-trigger span, aside.recolhido .search-trigger kbd { display: inline; }
      aside.recolhido nav a { justify-content: flex-start; }
      aside.recolhido nav a span, aside.recolhido .userbox > div, aside.recolhido .userbox a span, aside.recolhido .userbox button span { display: inline; }
      aside.recolhido .userbox a, aside.recolhido .userbox button { justify-content: flex-start; }
      aside .menu-recolher-wrap { display: none; }
      aside.recolhido .grp-title { visibility: visible; height: auto; padding: 14px 24px 4px; }
      main { max-width: 100%; padding: 16px; padding-top: 72px; padding-bottom: calc(var(--barra-inferior-h) + env(safe-area-inset-bottom) + 16px); }
      .cards { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)) !important; }
      .cards .num { font-size: 20px; }
      table { font-size: 14px; }
      th, td { padding: 10px 12px; white-space: nowrap; }
      .lista-scroll { max-height: 60vh; }

      /* O cabeçalho fixo mede a largura NATURAL de cada coluna (ver
         montarCabecalhoFixo) — sem limite, uma coluna com nome de cliente
         longo ("CESTAS BÁSICAS RODRIGUES") ou rótulo comprido ("Total gasto
         (histórico)") força a coluna toda a ficar larga, e a tabela some
         praticamente inteira pra fora da tela num celular (bug real
         reportado: "colunas transparentes", fontes bagunçadas). Trunca com
         "..." pra travar a largura ANTES da medição — a coluna de ação
         (ícones, sempre a última) fica de fora, cortar ela esconderia botão. */
      .lista-scroll td:not(:last-child), .lista-scroll th:not(:last-child) {
        max-width: 130px; overflow: hidden; text-overflow: ellipsis;
      }
      .lista-scroll td:first-child, .lista-scroll th:first-child { max-width: 110px; }

      /* Menos colunas em telas pequenas — em vez de espremer tudo, mostra só
         o essencial de cada lista; o resto continua acessível pelo seletor
         de Colunas (Clientes) ou pela rolagem horizontal quando fizer falta. */
      td[data-col="telefone"], th[data-col="telefone"],
      td[data-col="email"], th[data-col="email"],
      td[data-col="documento"], th[data-col="documento"],
      td[data-col="perfil"], th[data-col="perfil"],
      td[data-col="aniversario"], th[data-col="aniversario"],
      td[data-col="pedidos"], th[data-col="pedidos"],
      td[data-col="cashback"], th[data-col="cashback"],
      td[data-col="sku"], th[data-col="sku"],
      td[data-col="ativo"], th[data-col="ativo"],
      td[data-col="nota"], th[data-col="nota"],
      /* Widgets do Dashboard (Clientes sumidos/Avaliação/Cross-sell) — mesma
         lógica, sem seletor de Colunas aqui (não tem onde clicar pra
         reexibir), então só esconde o que é redundante com o resto da
         linha ou com a aba já selecionada. */
      td[data-col="ultima-compra"], th[data-col="ultima-compra"],
      td[data-col="segmento"], th[data-col="segmento"],
      td[data-col="pedido-em"], th[data-col="pedido-em"] {
        display: none;
      }
    }
    h1 { font-size: 22px; font-weight: 600; margin-bottom: 16px; }
    h2 { font-size: 16px; font-weight: 600; }

    table { width: 100%; border-collapse: collapse; background: #fff; border-radius: 8px; overflow: hidden; box-shadow: 0 1px 2px rgba(0,0,0,0.06); }
    th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--border); font-size: 14px; }
    th { background: var(--th-bg); font-weight: 600; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.02em; }

    /* Rolagem interna nas listas grandes (Clientes/Pedidos/Produtos/Cashback/
       Análises). Cabeçalho sticky (thead ou th) foi tentado e revertido —
       quebra o alinhamento das colunas em telas com muita gente (bug real
       encontrado em teste, não só teórico); melhor rolar sem cabeçalho fixo
       do que entregar tabela com coluna sobreposta. Ver memória do projeto. */
    .lista-scroll { max-height: 65vh; overflow: auto; -webkit-overflow-scrolling: touch; border-radius: 8px; box-shadow: 0 1px 2px rgba(0,0,0,0.06); }
    .lista-scroll table { box-shadow: none; border-radius: 0; }

    /* Cabeçalho fixo "sombra": uma barra comum (não faz parte da tabela),
       largura de cada coluna sincronizada por JS com o <thead> real, que
       fica escondido. Como é um div qualquer dentro do mesmo container
       com scroll, position:sticky funciona sem briga com o layout de
       tabela (ver memória do projeto — tentativa anterior mexendo direto
       no <thead>/<th> quebrava alinhamento de coluna). */
    .lista-scroll-cabecalho { position: sticky; top: 0; z-index: 2; display: none; background: var(--th-bg); border-bottom: 1px solid var(--border); }
    .lista-scroll-cabecalho.ativo { display: flex; }
    .lista-scroll-cabecalho span {
      display: block; flex-shrink: 0; box-sizing: border-box; padding: 11px 14px;
      font-weight: 600; color: var(--muted); font-size: 12px; text-transform: uppercase;
      letter-spacing: 0.02em; white-space: normal; overflow-wrap: break-word; line-height: 1.25;
    }
    .lista-scroll table.lista-scroll-thead-escondido thead { display: none; }
    a.th-sort { color: inherit; text-decoration: none; }
    a.th-sort:hover { color: var(--pink); }
    tbody tr:last-child td { border-bottom: none; }
    tr:hover { background: #fafafa; }

    .card { background: #fff; padding: 18px 20px; border-radius: 8px; box-shadow: 0 1px 2px rgba(0,0,0,0.06); }
    .cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }
    a.card { display: block; text-decoration: none; color: inherit; transition: box-shadow .15s, transform .15s; }
    a.card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.1); transform: translateY(-1px); }
    .cards .num { font-size: 26px; font-weight: 700; }
    .cards .label { font-size: 13px; color: var(--muted); }
    .warn { color: var(--orange); }
    .vencido { color: #C0292E; font-weight: 700; }

    input[type=text], input[type=tel], input[type=email], input[type=url], input[type=password], input[type=number], input[type=time], input[type=date], select, textarea {
      padding: 8px 10px; border: 1px solid #ccc; border-radius: 6px; font-size: 14px; width: 100%; font-family: inherit;
    }
    input:focus, select:focus, textarea:focus { outline: 2px solid var(--pink); outline-offset: 1px; border-color: var(--pink); }
    input[type=checkbox] { accent-color: var(--pink); }
    label { display: block; font-size: 13px; margin: 12px 0 4px; color: var(--text); font-weight: 600; }

    .btn { display: inline-block; background: var(--pink); color: #fff; border: none; padding: 9px 18px; border-radius: 6px; cursor: pointer; font-size: 14px; text-decoration: none; font-weight: 600; box-shadow: 0 1px 2px rgba(236,0,90,0.35); }
    .btn:hover { background: #c40050; }

    .search { margin-bottom: 16px; }
    .erro { background: #fdeaea; color: #a12a2a; padding: 10px 14px; border-radius: 6px; margin-bottom: 16px; font-size: 14px; border-left: 4px solid #a12a2a; }
    .sucesso { background: #e8f5e9; color: #2e6b31; padding: 10px 14px; border-radius: 6px; margin-bottom: 16px; font-size: 14px; border-left: 4px solid #2e6b31; }
    .muted { color: var(--muted); font-size: 13px; }
    a.link { color: var(--text); text-decoration: none; font-weight: 600; }
    a.link:hover { color: var(--pink); }

    .badge { display: inline-block; padding: 3px 10px; border-radius: 100px; font-size: 12px; font-weight: 600; }
    .ajuste-sugestoes .sugestao-item:hover { background: #F5F5F5; }
    .badge-green { background: #E3F5E9; color: #1E8A4C; }
    .badge-amber { background: #FEF1DA; color: #B36B00; }
    .badge-red { background: #FBE5E5; color: #C0292E; }
    .badge-gray { background: #EEEEEE; color: #666; }

    .order-row { cursor: pointer; }
    .order-row .chevron { color: var(--muted); font-weight: 700; }
    .order-row:hover .chevron { color: var(--pink); }
    .order-items > td { background: #fafafa; padding: 0 0 12px 12px; }
    .order-items table.subtable { box-shadow: none; margin: 0; border-radius: 0; }
    .order-items table.subtable th { background: #eee; font-size: 11px; }
    .order-items table.subtable td { font-size: 13px; }

    .info-tip { display: inline-block; color: var(--muted); border: 1px solid var(--border); border-radius: 100px; width: 14px; height: 14px; line-height: 13px; text-align: center; font-size: 10px; font-style: normal; font-weight: 700; cursor: help; margin-left: 4px; }
    .info-tip:hover { color: var(--pink); border-color: var(--pink); }

    .ficha { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px 24px; }
    .ficha .item .k { font-size: 12px; color: var(--muted); margin-bottom: 2px; }
    .ficha .item .v { font-size: 14px; font-weight: 600; }

    .nota-acoes { display: flex; gap: 4px; align-items: center; flex-shrink: 0; }
    .nota-acoes form { margin: 0; }
    .nota-acoes summary { list-style: none; }
    .nota-acoes summary::-webkit-details-marker { display: none; }
    .icon-btn { background: none; border: 1px solid var(--border); color: var(--muted); border-radius: 6px; width: 26px; height: 26px; cursor: pointer; font-size: 12px; display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
    .icon-btn:hover { color: var(--pink); border-color: var(--pink); }
    .nota-editar { margin-top: 10px; }
    .nota-concluida { opacity: 0.6; }
    .nota-concluida .v, .nota-concluida p { text-decoration: line-through; }
    .nota-concluida .muted { text-decoration: none; }

    .tag { display: inline-block; padding: 3px 10px; border-radius: 100px; font-size: 12px; font-weight: 600; background: var(--pink-soft); color: var(--pink); margin-left: 8px; vertical-align: middle; }
    .tag-neutro { background: var(--th-bg); color: var(--muted); border: 1px solid var(--border); }

    details.filtros { margin-bottom: 16px; }
    details.filtros summary { cursor: pointer; font-size: 13px; font-weight: 600; color: var(--text); padding: 8px 0; }
    details.filtros summary:hover { color: var(--pink); }
    details.filtros .painel { background: #fff; border-radius: 8px; box-shadow: 0 1px 2px rgba(0,0,0,0.06); padding: 16px 20px; margin-top: 8px; display: flex; gap: 16px; flex-wrap: wrap; align-items: flex-end; }

    .search-trigger { display: flex; align-items: center; gap: 8px; margin: 0 12px 12px; padding: 8px 10px; background: rgba(255,255,255,0.06); border: none; border-radius: 6px; color: #ababab; cursor: pointer; font-size: 13px; width: calc(100% - 24px); text-align: left; }
    .search-trigger:hover { color: #fff; background: rgba(255,255,255,0.1); }
    .search-trigger kbd { margin-left: auto; font-size: 11px; border: 1px solid rgba(255,255,255,0.2); border-radius: 4px; padding: 1px 5px; }

    .busca-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 100; align-items: flex-start; justify-content: center; padding-top: 10vh; }
    .busca-overlay.aberta { display: flex; }
    .busca-box { background: #fff; border-radius: 10px; width: 100%; max-width: 560px; max-height: 70vh; overflow: hidden; display: flex; flex-direction: column; box-shadow: 0 8px 30px rgba(0,0,0,0.25); }
    .busca-box input { border: none; border-bottom: 1px solid var(--border); border-radius: 0; padding: 16px; font-size: 16px; }
    .busca-box input:focus { outline: none; border-color: var(--border); }
    .busca-resultados { overflow-y: auto; padding: 8px; }
    .busca-grupo-titulo { font-size: 11px; text-transform: uppercase; letter-spacing: 0.03em; color: var(--muted); padding: 10px 10px 4px; }
    .busca-item { display: block; padding: 10px; border-radius: 6px; text-decoration: none; color: var(--text); }
    .busca-item:hover, .busca-item.ativo { background: var(--pink-soft); }
    .busca-item .sub { color: var(--muted); font-size: 12px; }
    .busca-vazio { padding: 24px; text-align: center; color: var(--muted); font-size: 13px; }
    .busca-item-linha { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 4px 10px; border-radius: 6px; }
    .busca-item-linha:hover { background: var(--pink-soft); }
    .busca-item-linha .busca-item-link { flex: 1; min-width: 0; text-decoration: none; color: var(--text); padding: 6px 0; }
    .busca-item-acoes { display: flex; gap: 10px; flex-shrink: 0; }
    .busca-item-acoes button { background: none; border: none; padding: 0; cursor: pointer; font-size: 12px; color: var(--muted); }
    .busca-item-acoes button:hover { color: var(--pink); text-decoration: underline; }
    .busca-quick-form { padding: 8px 10px 12px; margin: 0 0 4px; background: var(--pink-soft); border-radius: 6px; }
    .busca-quick-form textarea { width: 100%; min-height: 50px; resize: vertical; font-family: inherit; font-size: 13px; }
    .busca-quick-form .busca-quick-linha { display: flex; gap: 8px; align-items: center; margin-top: 6px; }

    .funil { display: flex; gap: 16px; overflow-x: auto; padding-bottom: 8px; align-items: flex-start; }
    .funil-coluna { background: var(--th-bg); border-radius: 8px; padding: 12px; flex: 1 1 240px; min-width: 240px; max-width: 320px; flex-shrink: 0; display: flex; flex-direction: column; max-height: calc(100vh - 220px); }
    .funil-coluna-titulo { font-weight: 700; font-size: 13px; margin-bottom: 10px; flex-shrink: 0; }
    .funil-filtro { font-size: 12px !important; padding: 6px 8px !important; margin-bottom: 4px; flex-shrink: 0; }
    .funil-coluna-corpo { min-height: 60px; border-radius: 6px; transition: background .1s; overflow-y: auto; }
    .funil-coluna-corpo.sobre { background: var(--pink-soft); }
    .funil-card { background: #fff; border-radius: 6px; padding: 10px 12px; margin-bottom: 8px; box-shadow: 0 1px 2px rgba(0,0,0,0.06); cursor: grab; }
    .funil-card.arrastando { opacity: 0.4; }
    .funil-card form { margin: 0; }
    .icon-btn.confirmando { background: #FBE5E5; color: #C0292E; border-color: #C0292E; }
    .funil-add { flex-shrink: 0; margin-top: 8px; }
    .funil-add-toggle { font-size: 12px; font-weight: 400; color: var(--muted); }
    .funil-add-toggle:hover { color: var(--pink); }
    .funil-add-busca { margin-top: 8px; }
    .funil-add-input { font-size: 12px !important; padding: 6px 8px !important; }
    .funil-add-resultados { margin-top: 4px; max-height: 160px; overflow-y: auto; }
    .funil-add-item { display: block; width: 100%; text-align: left; background: #fff; border: 1px solid var(--border); border-top: none; padding: 7px 8px; font-size: 12px; cursor: pointer; color: var(--text); }
    .funil-add-item:hover { background: var(--pink-soft); }
    .funil-add-item:first-child { border-top: 1px solid var(--border); border-radius: 4px 4px 0 0; }
    .funil-add-item:last-child { border-radius: 0 0 4px 4px; }

    .funil-massa-barra { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
    .funil-massa-btn { background: #C0292E; box-shadow: none; }
    .funil-massa-btn:hover { background: #a12222; }
    .funil-massa-btn:disabled { background: #ccc; cursor: not-allowed; }
    .funil-selecionar-coluna { display: block; background: none; border: none; cursor: pointer; padding: 0; margin-bottom: 8px; font-size: 11px; color: var(--muted); text-decoration: underline; flex-shrink: 0; }
    .funil-selecionar-coluna:hover { color: var(--pink); }

    .funil-abrir-preview { color: var(--text); font-weight: 600; cursor: pointer; }
    .funil-abrir-preview:hover { color: var(--pink); text-decoration: underline; }

    .preview-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 100; align-items: center; justify-content: center; }
    .preview-overlay.aberto { display: flex; }
    .preview-box { background: #fff; border-radius: 10px; width: 100%; max-width: 420px; padding: 24px; box-shadow: 0 8px 30px rgba(0,0,0,0.25); }

    .linha-clicavel { cursor: pointer; }
    .linha-clicavel:hover { background: var(--pink-soft); }
    .carregando { opacity: 0.5; transition: opacity .15s; pointer-events: none; }

    /* Toggle liga/desliga — usado em Configurações no lugar de checkbox
       cru, mesma semântica (é um <input type="checkbox"> por baixo, só
       muda a aparência) */
    .toggle-switch { position: relative; display: inline-block; width: 36px; height: 20px; flex-shrink: 0; }
    .toggle-switch input { opacity: 0; width: 0; height: 0; position: absolute; }
    .toggle-switch .toggle-trilho {
      position: absolute; inset: 0; background: #ccc; border-radius: 20px; cursor: pointer; transition: background .15s;
    }
    .toggle-switch .toggle-trilho::before {
      content: ''; position: absolute; width: 16px; height: 16px; left: 2px; top: 2px;
      background: #fff; border-radius: 50%; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,0.2);
    }
    .toggle-switch input:checked + .toggle-trilho { background: var(--pink); }
    .toggle-switch input:checked + .toggle-trilho::before { transform: translateX(16px); }

html { overflow-x: clip; }
