.fl-tabbar, .fl-move-btn { display: none; }

@media (max-width: 1024px) {
    :root {
        --fl-tabbar-h: 60px;
        --fl-brand: #0E90D9;
    }

    html { -webkit-tap-highlight-color: transparent; }

    body {
        padding-bottom: calc(var(--fl-tabbar-h) + env(safe-area-inset-bottom));
        overscroll-behavior-y: none;
    }

    .fl-tabbar {
        position: fixed;
        inset: auto 0 0 0;
        z-index: 10002;
        display: flex;
        height: calc(var(--fl-tabbar-h) + env(safe-area-inset-bottom));
        padding-bottom: env(safe-area-inset-bottom);
        background: rgba(255, 255, 255, .96);
        backdrop-filter: blur(12px);
        border-top: 1px solid #e5e7eb;
    }

    .dark .fl-tabbar { background: rgba(17, 24, 39, .96); border-color: #1f2937; }

    .fl-tab {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 2px;
        min-width: 0;
        font-size: 11px;
        font-weight: 500;
        color: #6b7280;
        background: none;
        border: 0;
        text-decoration: none;
    }

    .fl-tab i { font-size: 24px; line-height: 1; }
    .fl-tab.is-active { color: var(--fl-brand); }
    .fl-tab:active { opacity: .6; }

    /* O menu lateral abre pelo "Mais" da barra inferior */
    .fl-app-header .fl-drawer-toggle { display: none; }
    .fl-app-header { padding-top: calc(.625rem + env(safe-area-inset-top)); }

    /* O rodapé de créditos só ocupa a tela do aplicativo */
    .fl-app-footer { display: none; }

    /* O assistente flutuante sobe para não ficar atrás da barra */
    #floweasy-root { bottom: calc(var(--fl-tabbar-h) + 14px + env(safe-area-inset-bottom)) !important; }

    /* Kanban: uma etapa por tela, deslizando para o lado */
    .fl-kanban-board {
        scroll-snap-type: x mandatory;
        scroll-padding-inline: 0;
        gap: 10px;
        margin-inline: -4px;
        padding-inline: 4px;
        -webkit-overflow-scrolling: touch;
    }

    .fl-kanban-board > .fl-kanban-column {
        min-width: calc(100vw - 48px);
        max-width: calc(100vw - 48px);
        scroll-snap-align: center;
    }

    /* Áreas de toque confortáveis */
    button, a, [role="button"] { touch-action: manipulation; }

    /* Cabeçalho da página: título em cima, ações embaixo em linha rolável */
    .fl-page-header {
        flex-wrap: wrap;
        gap: 10px;
        padding: 12px 14px;
    }

    .fl-page-header > div:first-child { flex: 1 1 100%; }
    .fl-page-header .text-xl { font-size: 1.25rem; line-height: 1.5rem; }

    .fl-page-header > div:last-child {
        flex: 1 1 100%;
        flex-wrap: wrap;
        justify-content: flex-start;
        gap: 8px;
    }

    .fl-page-header .primary-button,
    .fl-page-header .secondary-button,
    .fl-page-header .transparent-button {
        min-height: 40px;
        padding: 8px 14px;
        font-size: 14px;
        white-space: nowrap;
    }

    .fl-page-header .primary-button { flex: 1 1 auto; text-align: center; }

    /* Barra de busca e filtros da lista */
    /* Depende da estrutura do toolbar do datagrid do core (Webkul), que não pode ser marcado */
    .toolbarLeft, .toolbarLeft > div { width: 100%; }
    .toolbarLeft input[name="search"] { min-height: 42px; font-size: 16px; }

    /* Listas em cartões, no lugar de tabela */
    .fl-dg-card {
        margin: 10px;
        padding: 14px;
        background: #fff;
        border: 1px solid #e5e7eb;
        border-radius: 14px;
        box-shadow: 0 1px 2px rgba(0, 0, 0, .04);
    }

    .dark .fl-dg-card { background: #111827; border-color: #1f2937; }
    .fl-dg-card:active { background: #f9fafb; }

    .fl-dg-row { flex-wrap: nowrap; justify-content: space-between; gap: 12px; padding: 3px 0; font-size: 14px; }
    .fl-dg-label { flex: none; font-size: 12px; color: #6b7280; }
    .fl-dg-value { text-align: right; min-width: 0; overflow-wrap: anywhere; }
    .fl-dg-card .icon-view, .fl-dg-card .icon-edit, .fl-dg-card .icon-delete { padding: 8px; }

    /* O iOS amplia a tela ao focar campo com fonte menor que 16px; o tema usa !important em vários campos, então o seletor precisa de mais especificidade */
    html:root body input:not([type="checkbox"]):not([type="radio"]),
    html:root body select,
    html:root body textarea,
    html:root body [contenteditable="true"] { font-size: 16px !important; }

    /* Colunas flexíveis encolhem em vez de alargar a página */
    /* Utilitária do Tailwind: serve a telas do core e do Flowinner */
    .flex-1 { min-width: 0; }

    /* Formulários: o salvar fica fixo acima da barra inferior */
    /* Depende da barra de ações dos formulários, comum a views do core (Webkul) e do Flowinner */
    form > div > .scroll-reactive-sticky {
        position: fixed;
        top: auto;
        bottom: calc(var(--fl-tabbar-h) + env(safe-area-inset-bottom));
        left: 0;
        right: 0;
        z-index: 10001;
        padding: 10px 14px;
        border-radius: 0;
        border-width: 1px 0 0;
        justify-content: stretch;
    }

    form > div > .scroll-reactive-sticky > div:first-child { display: none; }
    form > div > .scroll-reactive-sticky > div:last-child,
    form > div > .scroll-reactive-sticky > div:last-child > div { flex: 1; width: 100%; }
    form > div > .scroll-reactive-sticky .primary-button { width: 100%; min-height: 46px; font-size: 16px; }

    form:has(> div > .scroll-reactive-sticky) { padding-bottom: 72px; }

    /* Campos do formulário em uma coluna só */
    .fl-form .grid { grid-template-columns: minmax(0, 1fr) !important; }
    .fl-form .flex.w-full.gap-2 { flex-direction: column; }
    .fl-form input, .fl-form select, .fl-form textarea { min-height: 46px; }

    /* Tabelas largas rolam dentro do próprio quadro e não alargam a página */
    /* O seletor da tabela do core cobre as telas que o Flowinner não sobrescreve */
    .fl-scroll-x,
    div:has(> table.min-w-\[800px\]) { overflow-x: auto; max-width: 100%; -webkit-overflow-scrolling: touch; }

    /* Itens de grade e de linha podem encolher abaixo do conteúdo, para uma tabela larga rolar dentro do seu quadro em vez de alargar a página */
    .fl-scroll-x,
    .fl-forecast-scroll { max-width: 100%; }
    .grid > *, .flex > * { min-width: 0; }
    /* Os balões de dica do painel são para o mouse; no toque só alargavam a página por ficarem fora da tela */
    [data-fl-tip]::after { display: none; }

    /* Com modal ou painel aberto, a barra inferior sai da frente e o assistente também */
    /* A sobreposição de modal e painel vem do componente do core (Webkul) */
    body:has(.fl-quick-sheet:not([style*="display: none"])) .fl-tabbar,
    body:has(.fixed.inset-0[class*="bg-gray-500"]:not([style*="display: none"])) .fl-tabbar,
    body:has(.fixed.inset-0[class*="bg-gray-500"]:not([style*="display: none"])) #floweasy-root { display: none; }

    /* Criação rápida ("+") como painel que sobe de baixo */
    .fl-quick-sheet {
        position: fixed !important;
        inset: auto 0 0 0 !important;
        width: auto !important;
        max-height: 75vh;
        overflow-y: auto;
        margin: 0 !important;
        padding-bottom: env(safe-area-inset-bottom);
        border-radius: 20px 20px 0 0 !important;
        box-shadow: 0 -12px 40px rgba(0, 0, 0, .25);
        z-index: 10003;
    }

    .fl-quick-sheet::before {
        content: "";
        display: block;
        width: 40px;
        height: 4px;
        margin: 10px auto 0;
        border-radius: 2px;
        background: #d1d5db;
    }

    .fl-quick-sheet .grid > div { padding: 14px 8px; }
    .fl-quick-sheet .grid span { font-size: 14px; }

    /* Kanban: botão de mover etapa e painel de escolha */
    .fl-move-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 6px;
        min-height: 40px;
        margin-top: -6px;
        font-size: 13px;
        font-weight: 600;
        color: var(--fl-brand);
        background: #fff;
        border: 1px solid #bfe0f5;
        border-radius: 8px;
    }

    .fl-move-sheet {
        position: absolute;
        inset: auto 0 0 0;
        max-height: 80vh;
        overflow-y: auto;
        padding: 14px 14px calc(14px + env(safe-area-inset-bottom));
        background: #fff;
        border-radius: 20px 20px 0 0;
    }

    .dark .fl-move-sheet { background: #111827; color: #e5e7eb; }

    .fl-move-sheet__title { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: #6b7280; }
    .fl-move-sheet__lead { margin: 2px 0 10px; font-size: 15px; font-weight: 600; }

    .fl-move-sheet__item {
        display: flex;
        width: 100%;
        align-items: center;
        justify-content: space-between;
        min-height: 48px;
        padding: 0 14px;
        margin-bottom: 6px;
        font-size: 15px;
        text-align: left;
        border: 1px solid #e5e7eb;
        border-radius: 12px;
        background: #fff;
    }

    .dark .fl-move-sheet__item { background: #1f2937; border-color: #374151; }
    .fl-move-sheet__item.is-current { opacity: .45; border-style: dashed; }
    .fl-move-sheet__item.is-blocked:not(.is-current) { opacity: .45; background: #f9fafb; }
    .fl-move-sheet__count { font-size: 12px; color: #6b7280; }
}

/* Login: no celular o formulário vem primeiro, sem o painel de apresentação */
@media (max-width: 768px) {
    .fl-login-wrap .fl-brand { display: none; }
    .fl-login-page { align-items: flex-start; }
}
