:root {
    --bg: #05100c;
    --bg-elevado: #0a1a15;
    --superficie: #0e1a16;
    --superficie-2: #122019;
    --borda: #1c2e27;
    --texto: #eef6f2;
    --texto-dim: #9db3aa;
    --texto-faint: #64796f;
    --acento: #22e6a0;
    --acento-2: #17b880;
    --acento-suave: rgba(34, 230, 160, .13);
    --perigo: #f0655a;
    --raio: 16px;
    --raio-sm: 10px;
}
* { box-sizing: border-box; }
/* Trava de segurança contra overflow horizontal no mobile (pedido do
   usuário, 2026-09-16: "os pop up estão passando da tela quando é do
   celular ai fica cortado ali, e tem coisa q fica cortado ali") — mesmo
   testando de verdade em viewport estreito via CDP (360/375/390px, ver
   nota mais completa sobre essa técnica logo abaixo) não reproduzi um
   culpado óbvio (nenhum elemento realmente rolava horizontalmente), mas
   isso não descarta acontecer num aparelho real com outra largura/zoom.
   ⚠️ CORRIGIDO (mesmo dia, usuário reportou na hora): a primeira versão
   usava `overflow-x: hidden`, que QUEBROU a sidebar fixa (`.sidebar` com
   `position:sticky` passou a subir junto com o scroll) — achado clássico
   do CSS: se `overflow-x` vira algo diferente de `visible` e `overflow-y`
   ficava `visible`, o spec FORÇA `overflow-y` a virar `auto` também
   (criando um scroll container novo no body, que quebra sticky de filho).
   `overflow-x: clip` é EXPLICITAMENTE isento dessa regra de acoplamento —
   mesma trava contra overflow horizontal, sem efeito colateral nenhum no
   `overflow-y`. Confirmado via CDP: antes (`hidden`) a sidebar subia -201px
   ao rolar 400px a página; depois (`clip`), sidebar.top continua 0.
*/
html { overflow-x: clip; }
body {
    margin: 0;
    overflow-x: clip;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: radial-gradient(ellipse 1200px 800px at 15% -10%, #0d251d 0%, var(--bg) 55%);
    color: var(--texto);
    min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
.app {
    display: flex;
    min-height: 100vh;
}

/* ---- Sidebar ---- */
.sidebar {
    width: 260px;
    flex-shrink: 0;
    background: var(--bg-elevado);
    border-right: 1px solid var(--borda);
    padding: 1.4rem 1rem;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--borda) transparent;
}
.sidebar::-webkit-scrollbar { width: 5px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: var(--borda); border-radius: 999px; }
.sidebar::-webkit-scrollbar-thumb:hover { background: var(--texto-faint); }
.sidebar .marca {
    padding: 0 .5rem;
    margin-bottom: 1.6rem;
}
.sidebar .marca img {
    height: 74px;
    width: auto;
    max-width: 100%;
    object-fit: contain;
    margin-left: -.3rem;
}

.menu-lista { list-style: none; margin: 0; padding: 0; flex: 1; }
.menu-item a, .submenu-item a {
    display: flex;
    align-items: center;
    gap: .7rem;
    padding: .6rem .68rem;
    border-radius: var(--raio-sm);
    color: var(--texto-dim);
    font-size: .88rem;
    margin-bottom: .15rem;
    transition: background .15s, color .15s;
}
.menu-item a:hover, .submenu-item a:hover { background: var(--superficie-2); color: var(--texto); }
.menu-item a.ativo {
    background: linear-gradient(135deg, #35f2b0 0%, #16c084 55%, #0a8f63 100%);
    color: #fff;
    font-weight: 600;
    box-shadow: 0 6px 20px -6px rgba(34, 230, 160, .6);
}
.menu-item .icone { width: 18px; text-align: center; flex-shrink: 0; }
.menu-grupo .menu-grupo-titulo {
    font-size: .7rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--texto-faint);
    padding: 0 .75rem;
    margin-bottom: .4rem;
}
.submenu { list-style: none; margin: 0 0 0 1.6rem; padding: 0; max-height: 0; overflow: hidden; transition: max-height .22s ease; }
.submenu.aberto { max-height: 200px; }
.submenu-item a { font-size: .84rem; padding: .45rem .75rem; }
/* Item ativo DENTRO de um dropdown (ex. "Busca automática" com o menu
   "Automação" aberto) — antes só `.menu-item a.ativo` tinha destaque, o
   item do submenu ficava com a mesma cor de sempre mesmo sendo a página
   atual (pedido do usuário 2026-09-18: "coloca para se destacar o menu
   que ta, não o dropdown"). Mais discreto que o gradiente verde do item
   de topo (`.menu-item a.ativo`) — só cor de destaque + fundo suave —
   porque o toggle pai já carrega o destaque "forte" de grupo aberto. */
.submenu-item a.ativo { background: var(--acento-suave); color: var(--acento); font-weight: 600; }
.chevron-toggle { display: flex; transition: transform .2s ease; }
.menu-toggle.expandido .chevron-toggle { transform: rotate(180deg); }

.promo-lateral {
    margin-top: 1.2rem;
    background:
        linear-gradient(160deg, rgba(6,16,12,.35), rgba(6,16,12,.75)),
        url('../img/bg-textura.png');
    background-size: cover;
    background-position: center;
    border: 1px solid var(--borda);
    border-radius: var(--raio);
    padding: 1rem;
}
.promo-lateral img { height: 20px; margin-bottom: .5rem; }
.promo-lateral p { margin: 0; font-size: .8rem; color: var(--texto-dim); line-height: 1.4; }
.promo-lateral strong { color: var(--texto); }

/* ---- Main / Topbar ---- */
.main { flex: 1; min-width: 0; padding: 1.2rem 1.6rem 2.5rem; }
.topbar { display: flex; align-items: center; gap: 1rem; margin-bottom: 1.4rem; }
.busca {
    flex: 1;
    display: flex;
    align-items: center;
    gap: .6rem;
    background: var(--superficie);
    border: 1px solid var(--borda);
    border-radius: var(--raio-sm);
    padding: .65rem 1rem;
    color: var(--texto-faint);
    font-size: .88rem;
}
.busca kbd {
    margin-left: auto;
    background: var(--superficie-2);
    border: 1px solid var(--borda);
    border-radius: 5px;
    padding: .1rem .4rem;
    font-size: .72rem;
    color: var(--texto-faint);
}
.topbar-usuario {
    display: flex;
    align-items: center;
    gap: .7rem;
    background: var(--superficie);
    border: 1px solid var(--borda);
    border-radius: var(--raio-sm);
    padding: .45rem .9rem .45rem .45rem;
    font-size: .85rem;
    white-space: nowrap;
}
.avatar {
    width: 30px; height: 30px; border-radius: 50%;
    background: var(--acento); color: #062017;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: .8rem;
}
.topbar-usuario a.sair { color: var(--texto-faint); font-size: .78rem; }
.banner-topo {
    display: flex; align-items: center; gap: 1rem;
    background:
        linear-gradient(120deg, rgba(6,16,12,.4), rgba(6,16,12,.75)),
        url('../img/bg-textura.png');
    background-size: cover;
    background-position: center;
    border: 1px solid var(--borda);
    border-radius: var(--raio-sm);
    padding: .6rem 1.1rem;
    font-size: .85rem;
    white-space: nowrap;
}
.banner-topo img { height: 22px; }

/* ---- Componentes genéricos de página ---- */
.eyebrow { font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; color: var(--acento); margin-bottom: .3rem; }
.titulo-pagina { font-size: 1.7rem; margin: 0 0 .3rem; }
.subtitulo-pagina { color: var(--texto-dim); margin: 0; font-size: .92rem; }

.card {
    background: var(--superficie);
    border: 1px solid var(--borda);
    border-radius: var(--raio);
    padding: 1.2rem;
}
/* Movido de dashboard.css (2026-09-17) — é usado por várias páginas
   (leads, automacao-busca, marketplaces-vendas, textos, não só o
   dashboard), mas só existia lá; qualquer página que não carregasse
   dashboard.css junto ficava com .card-header sem display:flex nenhum
   (achado real testando o layout de "Meus textos" — os itens do cabeçalho
   simplesmente empilhavam em block normal, escondido porque geralmente
   cabem numa linha só por acaso). Fica em app.css agora, carregado em
   toda página do painel via app-head.php, pra não repetir esse bug.
   flex-wrap dá folga em telas estreitas sem quebrar o space-between em
   telas largas. */
.card-header { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .6rem; margin-bottom: .3rem; }
.card-header h3 { margin: 0; font-size: .98rem; }
.grid { display: grid; gap: 1rem; }
.badge {
    display: inline-flex; align-items: center; gap: .3rem;
    font-size: .7rem; padding: .15rem .5rem; border-radius: 999px;
}
.badge.up { color: var(--acento); background: var(--acento-suave); }
.badge.down { color: var(--perigo); background: rgba(255,107,107,.12); }
.badge.neutro { color: var(--texto-faint); background: rgba(255,255,255,.06); }
.btn {
    display: inline-flex; align-items: center; gap: .4rem;
    background: var(--acento); color: #062017; font-weight: 600;
    border: none; border-radius: var(--raio-sm); padding: .6rem 1.1rem;
    font-size: .85rem; cursor: pointer;
}
.btn.secundario { background: var(--superficie-2); color: var(--texto); border: 1px solid var(--borda); }
.link-seta { color: var(--acento); font-size: .82rem; font-weight: 600; }

/* ---- Mobile (menu vira off-canvas) ---- */
.btn-menu-mobile { display: none; }
.sidebar-backdrop { display: none; }

@media (max-width: 860px) {
    .sidebar {
        position: fixed;
        top: 0; left: 0;
        height: 100vh;
        z-index: 60;
        transform: translateX(-100%);
        transition: transform .25s ease;
        box-shadow: 0 0 40px rgba(0, 0, 0, .55);
    }
    .sidebar.aberta { transform: translateX(0); }

    .sidebar-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, .55);
        z-index: 55;
        opacity: 0;
        pointer-events: none;
        transition: opacity .2s ease;
    }
    .sidebar-backdrop.visivel { opacity: 1; pointer-events: auto; }

    .btn-menu-mobile {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 42px;
        height: 42px;
        flex-shrink: 0;
        background: var(--superficie);
        border: 1px solid var(--borda);
        border-radius: var(--raio-sm);
        color: var(--texto);
        cursor: pointer;
    }

    .main { padding: 1rem 1rem 2rem; }
    .banner-topo { display: none; }
    .busca kbd { display: none; }
    .topbar-usuario span { display: none; }

    .topbar { gap: .5rem; }
    .busca { min-width: 0; padding: .6rem .8rem; }
    .busca-texto { display: none; }
    .btn-menu-mobile, .topbar-usuario { flex-shrink: 0; }
}

@media (max-width: 480px) {
    .titulo-pagina { font-size: 1.4rem; }
}

/* ---- Popup reutilizável (EvoltModal, ver public/assets/js/modal.js) ----
   Padrão pro sistema todo: qualquer confirmação/prompt novo usa esse
   componente em vez de confirm()/prompt() nativos do navegador. */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    opacity: 0;
    pointer-events: none;
    transition: opacity .15s ease;
    padding: 1rem;
}
.modal-backdrop.aberto { opacity: 1; pointer-events: auto; }
.modal {
    background: var(--superficie);
    border: 1px solid var(--borda);
    border-radius: var(--raio);
    padding: 1.5rem;
    width: 100%;
    /* min() trava a largura no viewport de verdade, não só no que o pai
       flex calcula — mesma ideia de segurança do overflow-x:hidden acima.
       max-height + overflow-y: sem isso, um popup com muito campo (ex: o
       formulário de Magalu com 3 campos + botões) podia ficar mais alto
       que a tela num celular baixo, cortando topo E rodapé por igual (o
       backdrop centraliza verticalmente) sem jeito nenhum de rolar até o
       botão — bug bem mais provável que o horizontal, pedido do usuário
       2026-09-16: "tem coisa q fica cortado ali". */
    max-width: min(380px, calc(100vw - 2rem));
    max-height: calc(100vh - 2rem);
    overflow-y: auto;
    transform: translateY(10px);
    transition: transform .15s ease;
    box-shadow: 0 20px 60px rgba(0, 0, 0, .5);
}
.modal-backdrop.aberto .modal { transform: translateY(0); }
/* Scrollbar do popup em si (quando o conteúdo passa de max-height) — o
   padrão do navegador é cinza claro/grosso, destoa MUITO do tema escuro
   (pedido do usuário, print mostrando o scroll feio em "Editar fila").
   scrollbar-width/-color cobre Firefox; ::-webkit-scrollbar cobre Chrome/
   Edge/Safari. */
.modal { scrollbar-width: thin; scrollbar-color: var(--borda) transparent; }
.modal::-webkit-scrollbar { width: 8px; }
.modal::-webkit-scrollbar-track { background: transparent; }
.modal::-webkit-scrollbar-thumb { background: var(--borda); border-radius: 999px; }
.modal::-webkit-scrollbar-thumb:hover { background: var(--texto-faint); }
.modal-titulo { margin: 0 0 .5rem; font-size: 1.05rem; }
.modal-texto { color: var(--texto-dim); font-size: .85rem; line-height: 1.5; margin: 0 0 1rem; }
.modal-input {
    width: 100%;
    background: var(--superficie-2);
    border: 1px solid var(--borda);
    border-radius: var(--raio-sm);
    color: var(--texto);
    padding: .6rem .75rem;
    font-size: .85rem;
    margin-bottom: .3rem;
    box-sizing: border-box;
}
.modal-acoes { display: flex; gap: .6rem; margin-top: 1.2rem; }
.modal-acoes .btn { flex: 1; justify-content: center; }
.modal.modal-perigo .modal-titulo { color: var(--perigo); }
.btn-perigo { background: var(--perigo); color: #fff; }

/* ---- Popup "página" (EvoltModal.pagina) — conteúdo maior/dinâmico, ex:
   formulário de conectar um marketplace. ---- */
.modal-pagina { max-width: min(460px, calc(100vw - 2rem)); position: relative; }
.modal-fechar {
    position: absolute;
    top: .9rem;
    right: .9rem;
    background: none;
    border: none;
    color: var(--texto-faint);
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
    padding: .2rem .5rem;
}
.modal-fechar:hover { color: var(--texto); }
.modal-pagina-topo {
    display: flex;
    align-items: center;
    gap: .9rem;
    margin-bottom: 1.2rem;
    padding-right: 1.6rem;
}
.modal-pagina-logo-box {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 4px 14px rgba(0, 0, 0, .25);
}
.modal-pagina-logo-box img { max-width: 36px; max-height: 30px; object-fit: contain; }
.modal-pagina-topo .modal-titulo { margin: 0 0 .2rem; }
.modal-pagina-sub { margin: 0; font-size: .8rem; color: var(--texto-dim); line-height: 1.4; }
.modal-pagina-corpo { min-height: 130px; }
.modal-pagina-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 130px;
}
.modal-spinner {
    width: 28px;
    height: 28px;
    border: 3px solid var(--borda);
    border-top-color: var(--acento);
    border-radius: 50%;
    animation: modal-spin .8s linear infinite;
}
@keyframes modal-spin { to { transform: rotate(360deg); } }

.modal-form-label {
    display: block;
    font-size: .78rem;
    color: var(--texto-dim);
    font-weight: 600;
    margin-bottom: 1rem;
}
.modal-form-label .modal-input { margin-top: .4rem; }

.modal-resumo { display: flex; flex-direction: column; gap: .8rem; margin-bottom: .3rem; }
.modal-resumo-linha { display: flex; flex-direction: column; gap: .15rem; }
.modal-resumo-label { font-size: .74rem; color: var(--texto-faint); }
.modal-resumo-valor { font-size: .86rem; color: var(--texto); word-break: break-all; }
.modal-textarea {
    min-height: 72px;
    resize: vertical;
    font-family: 'Courier New', monospace;
    font-size: .78rem;
}

/* Toggle switch — usado aqui pra "Fila ativa/pausada" */
.toggle-switch { position: relative; display: inline-block; width: 40px; height: 22px; flex-shrink: 0; }
.toggle-switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle-switch .slider { position: absolute; inset: 0; background: var(--superficie); border: 1px solid var(--borda); border-radius: 999px; cursor: pointer; transition: background .15s, border-color .15s; }
.toggle-switch .slider::before { content: ''; position: absolute; width: 16px; height: 16px; left: 2px; top: 2px; background: var(--texto-faint); border-radius: 50%; transition: transform .15s, background .15s; }
.toggle-switch input:checked + .slider { background: var(--acento-suave); border-color: var(--acento); }
.toggle-switch input:checked + .slider::before { transform: translateX(17px); background: var(--acento); }
.toggle-switch input:focus-visible + .slider { outline: 2px solid var(--acento); outline-offset: 2px; }

/* Aviso de acesso remoto do Master (topbar do painel) */
.acesso-remoto { position: sticky; top: 0; z-index: 40; display: flex; align-items: center; justify-content: space-between; gap: .8rem; flex-wrap: wrap; background: #3a2a06; border: 1px solid #ffc800; color: #ffe08a; border-radius: var(--raio-sm); padding: .55rem .9rem; margin-bottom: 1rem; font-size: .82rem; }
.acesso-remoto strong { color: #fff; }
.acesso-remoto .btn { padding: .35rem .8rem; font-size: .76rem; }

/* Ferramenta fora do plano: continua no menu, mas bloqueada (leva pra /planos). */
.menu-item a.bloqueado, .submenu-item a.bloqueado { opacity: .55; }
.menu-item a.bloqueado::after, .submenu-item a.bloqueado::after {
    content: ''; margin-left: auto; width: 13px; height: 13px; flex-shrink: 0; background: currentColor;
    -webkit-mask: url("data:image/svg+xml,%3Csvg 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'%3E%3Crect x='3' y='11' width='18' height='11' rx='2'/%3E%3Cpath d='M7 11V7a5 5 0 0 1 10 0v4'/%3E%3C/svg%3E") center / contain no-repeat;
    mask: url("data:image/svg+xml,%3Csvg 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'%3E%3Crect x='3' y='11' width='18' height='11' rx='2'/%3E%3Cpath d='M7 11V7a5 5 0 0 1 10 0v4'/%3E%3C/svg%3E") center / contain no-repeat;
}
