/* --- REGRA DE SEGURANÇA CRÍTICA --- */
/* Garante que elementos ocultos fiquem ocultos mesmo se o Tailwind falhar */
.hidden {
    display: none !important;
}

html, body {
    max-width: 100%;
    overflow-x: hidden;
}

/* Impede o "puxar para atualizar" nativo (Chrome Android / PWA) ao rolar a tela.
   A rolagem continua normal dentro da página; só deixa de recarregar o app inteiro. */
html, body,
#app,
#loginScreen,
#registrationScreen,
#mainContent,
#pageContent,
.main-scroll,
.sidebar-scroll,
.portal-editor-scroll,
.directory-page-list {
    overscroll-behavior-y: contain;
}

body { font-family: 'Figtree', system-ui, sans-serif; }

/* ========== Design system (padrão visual da aplicação) ========== */
:root {
    --brand-brown: #3f2a1f;
    --brand-olive: #6d7c4e;
    --brand-lime: #c6e03a;
    --brand-lime-deep: #9fbc1f;
    --ui-ink: #1f2937;
    --ui-muted: #6b7280;
    --ui-line: #e5e7eb;
    --ui-surface: #ffffff;
    --ui-bg: #f3f4f6;
    --radius-md: 0.75rem;
    --radius-lg: 1rem;
    --shadow-card: 0 10px 28px rgba(31, 41, 55, 0.08);
}

.page-title {
    margin: 0;
    font-family: 'Outfit', 'Figtree', sans-serif;
    font-size: clamp(1.5rem, 2.4vw, 1.9rem);
    font-weight: 800;
    color: var(--ui-ink);
    line-height: 1.15;
}
.req-star {
    color: #dc2626;
    font-weight: 800;
    margin-left: 0.15rem;
}
.field-invalid {
    border-color: #dc2626 !important;
    box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.22) !important;
    background: #fef2f2 !important;
}
.field-group-invalid {
    border-color: #dc2626 !important;
    box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.22);
    background: #fef2f2;
    border-radius: 0.65rem;
}
.client-field-error {
    border-color: #dc2626 !important;
    box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.22) !important;
    background: #fef2f2 !important;
}

.page-subtitle {
    margin: 0;
    color: var(--ui-muted);
    font-size: 0.95rem;
}

.surface-card {
    background: var(--ui-surface);
    border: 1px solid var(--ui-line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
}

/* Configurar Cobrança — blocos de ajuda e subseções WhatsApp */
.billing-help-box {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 0.65rem;
    padding: 0.65rem 0.75rem;
    line-height: 1.45;
}
.billing-wa-subcard {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 0.75rem;
    padding: 0.85rem 0.9rem;
}
.billing-wa-subcard h4 {
    margin: 0;
}

/* Resumo Geral por Edição */
.edition-summary {
    background: var(--ui-surface);
    border: 1px solid var(--ui-line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    overflow: hidden;
}
.edition-summary__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
    background: #f7f8f4;
    border-bottom: 1px solid var(--ui-line);
    border-left: 5px solid var(--brand-olive);
}
.edition-summary--list-only .edition-summary__head {
    border-bottom: none;
}
.edition-summary__title {
    margin: 0;
    font-family: 'Outfit', 'Figtree', sans-serif;
    font-size: clamp(1.05rem, 2.4vw, 1.25rem);
    font-weight: 800;
    color: var(--ui-ink);
    line-height: 1.2;
}
.edition-summary__body {
    padding: 0.9rem 1rem 1rem;
}
.edition-summary__group + .edition-summary__group {
    margin-top: 0.9rem;
    padding-top: 0.85rem;
    border-top: 1px dashed var(--ui-line);
}
.edition-summary__group-title {
    margin: 0 0 0.5rem;
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ui-muted);
}
.edition-summary__kpis {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.5rem;
}
@media (min-width: 768px) {
    .edition-summary__kpis--area { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .edition-summary__kpis--money { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
.edition-summary__kpi {
    min-height: 4.35rem;
    padding: 0.6rem 0.7rem;
    border-radius: 0.7rem;
    border: 1px solid var(--ui-line);
    background: #f9fafb;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 0.2rem;
}
.edition-summary__kpi-label {
    font-size: 0.65rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--ui-muted);
}
.edition-summary__kpi-value {
    font-size: 0.98rem;
    font-weight: 800;
    line-height: 1.2;
    color: var(--ui-ink);
    overflow-wrap: anywhere;
}
.edition-summary__kpi--total { border-left: 4px solid #374151; }
.edition-summary__kpi--available { border-left: 4px solid #dc2626; }
.edition-summary__kpi--available .edition-summary__kpi-value { color: #b91c1c; }
.edition-summary__kpi--sold { border-left: 4px solid var(--brand-olive); }
.edition-summary__kpi--sold .edition-summary__kpi-value { color: #4c5737; }
.edition-summary__kpi--contracted { border-left: 4px solid #15803d; }
.edition-summary__kpi--contracted .edition-summary__kpi-value { color: #166534; }
.edition-summary__kpi--received { border-left: 4px solid #0f766e; }
.edition-summary__kpi--received .edition-summary__kpi-value { color: #115e59; }
.edition-summary__kpi--interest { border-left: 4px solid #9a3412; }
.edition-summary__kpi--interest .edition-summary__kpi-value { color: #7c2d12; }
.edition-summary__kpi--pending { border-left: 4px solid #b45309; }
.edition-summary__kpi--pending .edition-summary__kpi-value { color: #92400e; }
.edition-summary__bar-wrap { margin-top: 0.6rem; }
.edition-summary__bar {
    position: relative;
    width: 100%;
    min-height: 1.7rem;
    height: 1.7rem;
    border-radius: 999px;
    background: #e5e7eb;
    overflow: hidden;
}
.edition-summary__bar > span {
    display: block;
    height: 100%;
    max-width: 100%;
    background: var(--brand-lime);
    border-radius: inherit;
}
.edition-summary__bar-label {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding: 0 0.7rem;
    margin: 0;
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.02em;
    color: #facc15;
    -webkit-text-stroke: 0.7px #111;
    paint-order: stroke fill;
    text-shadow:
        -1px -1px 0 #111,
        1px -1px 0 #111,
        -1px 1px 0 #111,
        1px 1px 0 #111;
    pointer-events: none;
    white-space: nowrap;
}
.edition-summary__bar-caption {
    margin: 0.4rem 0 0;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--ui-ink);
}
.edition-summary__hidden {
    margin: 0;
    font-size: 0.9rem;
    color: var(--ui-muted);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    border: 0;
    border-radius: var(--radius-md);
    font-family: 'Outfit', 'Figtree', sans-serif;
    font-weight: 700;
    font-size: 0.95rem;
    line-height: 1.1;
    padding: 0.7rem 1.1rem;
    cursor: pointer;
    text-decoration: none;
    transition: transform 0.15s ease, filter 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
    min-height: 44px;
    touch-action: manipulation;
}
.btn:hover { filter: brightness(1.03); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.65; cursor: wait; }

.btn-sm { padding: 0.45rem 0.85rem; font-size: 0.82rem; min-height: 38px; }
.btn-block { width: 100%; }

/* Padrões por função:
 * primary   = ação principal (Salvar / Novo / Tornar Visível)
 * invite    = convite / enviar link / gerar acesso / Gerar Novo Admin Master
 * success   = confirmar financeiro / reativar / assinatura concluída / Reenviar Cadastro
 * warn      = voltar / fechar / cancelar e fechar / alerta / aguardando
 * print     = credencial / imprimir / gerar termo
 * danger    = excluir / estornar / cancelar destrutivo
 * secondary = ações neutras destacadas (Editar pagamento, Ver/abrir, etc.)
 * neutral   = ações informativas/somente leitura (OK de aviso, Ver Boleto)
 * Nas listas de expositor, lojista e visitante a cor segue a coluna:
 *   Enviar Cadastro = laranja; Reenviar Cadastro = verde; credencial e selecionar acessos = amarelo;
 *   contratos e termos (gerar / aguardando / visualizar) = lilás / laranja / verde;
 *   editar = turquesa claro; docs/NFs = branco com contorno; excluir = vermelho; novo e salvar = lima
 */
.btn-primary {
    color: var(--brand-brown);
    background: linear-gradient(180deg, #d6ef55 0%, var(--brand-lime) 55%, var(--brand-lime-deep) 100%);
    box-shadow: 0 8px 18px rgba(120, 140, 30, 0.25);
}
.btn-secondary {
    color: #fff;
    background: linear-gradient(180deg, #7f8f5d 0%, var(--brand-olive) 55%, #556239 100%);
    box-shadow: 0 8px 16px rgba(109, 124, 78, 0.28);
}
.btn-secondary:hover { filter: brightness(1.05); }
.btn-invite {
    color: #fff;
    background: linear-gradient(180deg, #4f8cff 0%, #2563eb 55%, #1d4ed8 100%);
    box-shadow: 0 8px 16px rgba(37, 99, 235, 0.28);
}
.btn-success {
    color: #fff;
    background: linear-gradient(180deg, #34d399 0%, #16a34a 55%, #15803d 100%);
    box-shadow: 0 8px 16px rgba(22, 163, 74, 0.28);
}
.btn-warn {
    color: #fff;
    background: linear-gradient(180deg, #fbbf24 0%, #d97706 55%, #b45309 100%);
    box-shadow: 0 8px 16px rgba(217, 119, 6, 0.28);
}
/* Salvar com alterações pendentes: laranja pulsando (formDirty.js). */
.btn-unsaved {
    animation: btn-unsaved-pulse 1.6s ease-in-out infinite;
}
@keyframes btn-unsaved-pulse {
    0%, 100% { box-shadow: 0 8px 16px rgba(217, 119, 6, 0.28), 0 0 0 0 rgba(217, 119, 6, 0.55); }
    50% { box-shadow: 0 8px 16px rgba(217, 119, 6, 0.28), 0 0 0 7px rgba(217, 119, 6, 0); }
}
@media (prefers-reduced-motion: reduce) {
    .btn-unsaved { animation: none; outline: 3px solid rgba(217, 119, 6, 0.55); outline-offset: 2px; }
}
.btn-print {
    color: #fff;
    background: linear-gradient(180deg, #2dd4bf 0%, #0d9488 55%, #0f766e 100%);
    box-shadow: 0 8px 16px rgba(13, 148, 136, 0.28);
}
.btn-credential {
    color: #3f2a1f;
    background: linear-gradient(180deg, #fff6b0 0%, #ffe14a 52%, #f0c400 100%);
    box-shadow: 0 8px 16px rgba(196, 160, 0, 0.28);
}
.btn-danger {
    color: #fff;
    background: linear-gradient(180deg, #f87171 0%, #dc2626 55%, #b91c1c 100%);
    box-shadow: 0 8px 16px rgba(220, 38, 38, 0.22);
}
/* Personalização — seleção visível do padrão da etiqueta */
#credentialLabelPreset.credential-label-preset--custom,
#credentialLabelPreset.credential-label-preset--maker {
    border-color: var(--brand-olive);
    box-shadow: 0 0 0 2px rgba(109, 124, 78, 0.22);
    font-weight: 600;
}
.credential-label-preset-badge {
    display: inline-block;
    margin-right: 0.35rem;
    padding: 0.1rem 0.45rem;
    border-radius: 0.35rem;
    background: var(--brand-olive);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    vertical-align: middle;
}

/* Home — saldo Asaas disponível: bem visível no Resumo Geral */
.btn-sweep-home {
    font-size: 1.05rem;
    font-weight: 800;
    padding: 0.75rem 1.25rem;
    min-height: 2.75rem;
    letter-spacing: 0.01em;
    box-shadow: 0 10px 22px rgba(185, 28, 28, 0.35);
}
.btn-sweep-home:disabled {
    opacity: 0.72;
    cursor: not-allowed;
}
@media (max-width: 640px) {
    .btn-sweep-home {
        width: 100%;
        font-size: 1.02rem;
        padding: 0.85rem 1rem;
    }
}
/* Editar: azul da bandeira do Brasil (#002776) em toda a aplicação. */
:root { --flag-blue: #002776; }
/* Coluna Editar das listas (Admins, Clientes, Lojistas, Visitantes): azul turquesa claro. */
.btn-col-edit {
    color: #04302e;
    background: linear-gradient(180deg, #8ff0e8 0%, #40e0d0 55%, #1fc7b6 100%);
    box-shadow: 0 8px 16px rgba(32, 178, 170, 0.30);
}
.btn-col-lilac {
    color: #fff;
    background: linear-gradient(180deg, #c4b5fd 0%, #a78bfa 45%, #7c3aed 100%);
    box-shadow: 0 8px 16px rgba(124, 58, 237, 0.26);
}
/* Coluna Docs / NFs: branco com texto preto; o contorno interno mantém o botão visível no fundo claro. */
.btn-col-docs {
    color: #111827;
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 55%, #e2e8f0 100%);
    box-shadow: 0 8px 16px rgba(51, 65, 85, 0.20), inset 0 0 0 1px #94a3b8;
}
.btn-neutral {
    color: #1f2937;
    background: #e5e7eb;
    box-shadow: 0 4px 10px rgba(31, 41, 55, 0.08);
}
.btn-neutral:hover { background: #d1d5db; }
.btn-back {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    border: 1px solid rgba(180, 83, 9, 0.35);
    background: linear-gradient(180deg, #fbbf24 0%, #d97706 55%, #b45309 100%);
    color: #fff;
    border-radius: 999px;
    padding: 0.55rem 1rem;
    font-weight: 700;
    font-size: 0.88rem;
    min-height: 42px;
    box-shadow: 0 8px 16px rgba(217, 119, 6, 0.28);
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease, filter 0.15s ease;
}
.btn-back:hover {
    filter: brightness(1.05);
    border-color: rgba(180, 83, 9, 0.6);
    transform: translateX(-2px);
}

.ui-input {
    border: 1px solid #d1d5db;
    border-radius: var(--radius-md);
    padding: 0.7rem 0.85rem;
    font-size: 0.95rem;
    min-height: 44px;
    background: #fff;
    outline: none;
}
.ui-input:focus {
    border-color: var(--brand-lime-deep);
    box-shadow: 0 0 0 3px rgba(198, 224, 58, 0.28);
}

.file-actions {
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.35rem;
}
.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.35rem;
    height: 2.35rem;
    border-radius: 0.65rem;
    border: 1px solid rgba(109, 124, 78, 0.25);
    background: #eef4df;
    color: #3f2a1f;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.btn-icon:hover {
    background: #dfe8c8;
    color: #1d4ed8;
    border-color: #93c5fd;
}
.btn-icon:disabled {
    opacity: 0.55;
    cursor: wait;
}
.btn-icon-print { background: #ccfbf1; color: #0f766e; border-color: #99f6e4; }
.btn-icon-print:hover { background: #99f6e4; color: #115e59; border-color: #5eead4; }
.btn-icon-email { background: #e0e7ff; color: #3730a3; border-color: #c7d2fe; }
.btn-icon-email:hover { background: #c7d2fe; color: #312e81; border-color: #a5b4fc; }
.btn-icon-whatsapp { background: #dcfce7; color: #15803d; border-color: #bbf7d0; }
.btn-icon-whatsapp:hover { color: #166534; background: #bbf7d0; border-color: #86efac; }
.btn-icon-save { background: #fef3c7; color: #b45309; border-color: #fde68a; }
.btn-icon-save:hover { background: #fde68a; color: #92400e; border-color: #fcd34d; }
.btn-icon-danger { background: #fee2e2; color: #b91c1c; border-color: #fecaca; }
.btn-icon-danger:hover { color: #991b1b; background: #fecaca; border-color: #fca5a5; }
.btn-icon-edit { background: #e3e9f6; color: var(--flag-blue); border-color: #b9c6e4; }
.btn-icon-edit:hover { background: #c9d5ee; color: #001a52; border-color: #8fa3d1; }
/* Abrir lista (não é edição): mantém o azul claro anterior. */
.btn-icon-open { background: #dbeafe; color: #1d4ed8; border-color: #bfdbfe; }
.btn-icon-open:hover { background: #bfdbfe; color: #1e40af; }
.btn-icon-replace { background: #ede9fe; color: #6d28d9; border-color: #ddd6fe; }
.btn-icon-replace:hover { background: #ddd6fe; color: #5b21b6; border-color: #c4b5fd; }

.credential-name-item .credential-name-check {
    width: 1.05rem;
    height: 1.05rem;
    flex-shrink: 0;
    accent-color: var(--brand-olive, #5c6b3a);
}
.credential-name-input[readonly] {
    background: #f9fafb;
    color: #111827;
}
#credentialSelectAll {
    width: 1.05rem;
    height: 1.05rem;
    accent-color: var(--brand-olive, #5c6b3a);
}

/* Sidebar alinhada ao padrão */
.sidebar-btn {
    border-radius: var(--radius-md) !important;
    transition: background 0.15s ease, transform 0.15s ease !important;
}
.sidebar-btn:hover { transform: translateX(2px); }

/* ========== Portal do cliente (hub) ========== */
.client-portal-shell {
    animation: portalRise 0.45s ease both;
}
.portal-editor {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    overflow: hidden;
}
.portal-editor-top,
.portal-editor-actions {
    flex-shrink: 0;
}
.portal-editor-actions {
    position: relative;
    z-index: 5;
    margin-bottom: 0;
}
.portal-editor-scroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}
#app.portal-mode {
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
#app.portal-mode #mainContent {
    flex: 1;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
#app.portal-mode #pageContent {
    flex: 1;
    min-height: 0;
    overflow: auto;
}
#app.portal-mode #pageContent:has(.portal-editor) {
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
#app.portal-mode #pageContent:has(.portal-editor) > .portal-editor {
    flex: 1;
    min-height: 0;
    width: 100%;
}
.portal-hub-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.9rem;
}
@media (min-width: 720px) {
    .portal-hub-grid { grid-template-columns: 1fr; max-width: 42rem; }
}
.portal-hub-grid--admin {
    max-width: 64rem;
}
@media (min-width: 720px) {
    .portal-hub-grid--admin {
        grid-template-columns: 1fr 1fr;
        max-width: 64rem;
    }
    /* Último botão sozinho: ocupa a linha inteira (sem célula vazia ao lado). */
    .portal-hub-grid--admin > .portal-hub-card:last-child:nth-child(odd) {
        grid-column: 1 / -1;
    }
}
.portal-hub-copy {
    min-width: 0;
}
.portal-hub-card {
    width: 100%;
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 1rem;
    text-align: left;
    border: 1px solid var(--ui-line);
    background: var(--ui-surface);
    border-radius: 1.15rem;
    padding: 1.15rem 1.2rem;
    box-shadow: var(--shadow-card);
    cursor: pointer;
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}
.portal-hub-card:hover {
    transform: translateY(-2px);
    border-color: rgba(109, 124, 78, 0.45);
    box-shadow: 0 16px 34px rgba(31, 41, 55, 0.12);
}
.portal-hub-card:active { transform: translateY(0); }
.portal-hub-icon {
    width: 3.1rem;
    height: 3.1rem;
    border-radius: 0.95rem;
    display: grid;
    place-items: center;
    font-size: 1.25rem;
    color: #fff;
    flex-shrink: 0;
}
.portal-hub-card--cadastro .portal-hub-icon { background: linear-gradient(160deg, #3f2a1f, #5a4030); color: var(--brand-lime); }
.portal-hub-card--qr .portal-hub-icon { background: linear-gradient(160deg, #4f6b2f, #6d7c4e); }
.portal-hub-card--docs .portal-hub-icon { background: linear-gradient(160deg, #8a6a28, #b0892e); }
.portal-hub-card--creds .portal-hub-icon { background: linear-gradient(160deg, #0f766e, #14b8a6); }
.portal-hub-card--finance .portal-hub-icon { background: linear-gradient(160deg, #1d4ed8, #3b82f6); }
.portal-hub-label {
    display: block;
    font-family: 'Outfit', 'Figtree', sans-serif;
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--ui-ink);
    line-height: 1.2;
}
.portal-hub-desc {
    display: block;
    margin-top: 0.2rem;
    font-size: 0.88rem;
    color: var(--ui-muted);
}
.portal-hub-cta {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--brand-olive);
    white-space: nowrap;
    padding: 0.45rem 0.7rem;
    border-radius: 999px;
    background: rgba(109, 124, 78, 0.1);
}
.portal-hub-card:hover .portal-hub-cta {
    background: rgba(198, 224, 58, 0.28);
    color: var(--brand-brown);
}

#loginScreen, #registrationScreen {
    padding: max(1rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right)) max(1rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* ========== Portal de abertura ========== */
.portal-screen {
    --portal-brown: #3f2a1f;
    --portal-brown-soft: rgba(63, 42, 31, 0.78);
    --portal-olive: #6d7c4e;
    --portal-lime: #c6e03a;
    --portal-lime-deep: #9fbc1f;
    --portal-glass: rgba(255, 252, 246, 0.78);
    --portal-glass-border: rgba(255, 255, 255, 0.55);
    --portal-text: #2c2118;
    --portal-muted: #5c5348;
    position: fixed;
    inset: 0;
    z-index: 50;
    display: flex;
    align-items: stretch;
    justify-content: center;
}

.portal-bg {
    position: absolute;
    inset: 0;
    background:
        url('assets/portal-bg.png?v=20260911e') center center / cover no-repeat;
    transform: none;
}

.portal-veil {
    position: absolute;
    inset: 0;
    background:
        linear-gradient(120deg, rgba(40, 28, 18, 0.28) 0%, rgba(70, 85, 45, 0.18) 42%, rgba(255, 255, 255, 0.08) 100%),
        radial-gradient(ellipse at 18% 12%, rgba(198, 224, 58, 0.12), transparent 42%);
    pointer-events: none;
}

.portal-grain {
    position: absolute;
    inset: 0;
    pointer-events: none;
    opacity: 0.07;
    background-image: radial-gradient(rgba(255,255,255,0.55) 0.6px, transparent 0.6px);
    background-size: 3px 3px;
    mix-blend-mode: soft-light;
}

.portal-shell {
    position: relative;
    z-index: 1;
    width: min(1120px, 100%);
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 1.5rem;
    padding: 1.25rem 1rem 2rem;
}

.portal-shell--single {
    width: min(980px, 100%);
    min-height: 100%;
    justify-content: center;
    align-items: stretch;
    gap: 1.75rem;
}

.portal-hero {
    max-width: 40rem;
    animation: portalRise 0.7s ease both;
}

.portal-shell--single .portal-hero {
    max-width: none;
    text-align: left;
}

.portal-logo {
    display: block;
    width: clamp(5.5rem, 16vw, 7.5rem);
    height: auto;
    margin: 0 0 0.85rem;
    border-radius: 50%;
    box-shadow: 0 10px 28px rgba(20, 12, 6, 0.35);
    background: transparent;
}

.portal-brand {
    margin: 0 0 0.85rem;
    font-family: 'Outfit', sans-serif;
    font-size: clamp(2.35rem, 5.4vw, 3.75rem);
    font-weight: 800;
    line-height: 0.98;
    letter-spacing: -0.02em;
    color: #fff;
    text-shadow:
        0 2px 0 rgba(63, 42, 31, 0.18),
        0 12px 36px rgba(20, 12, 6, 0.45);
}

/* Fechar câmera / painel de leitura QR — alto contraste */
.btn-qr-close {
    color: #fff !important;
    background: linear-gradient(180deg, #f87171 0%, #dc2626 55%, #b91c1c 100%) !important;
    box-shadow: 0 8px 16px rgba(220, 38, 38, 0.28) !important;
    font-weight: 800;
    min-height: 42px;
    padding: 0.55rem 1.1rem;
}
.btn-qr-close:hover { filter: brightness(1.05); }

.portal-title {
    margin: 0;
    font-family: 'Outfit', sans-serif;
    font-size: clamp(1.45rem, 2.8vw, 2rem);
    font-weight: 700;
    line-height: 1.15;
    color: rgba(255, 252, 245, 0.96);
    text-shadow: 0 2px 16px rgba(30, 20, 12, 0.35);
}

.portal-audiences {
    margin: 0.55rem 0 0;
    color: rgba(255, 250, 242, 0.9);
    font-size: clamp(0.98rem, 1.6vw, 1.12rem);
    font-weight: 500;
    max-width: 34rem;
    text-shadow: 0 1px 10px rgba(30, 20, 12, 0.28);
}

.portal-title--access {
    max-width: 38rem;
    font-size: clamp(1.05rem, 2.4vw, 1.35rem);
    font-weight: 700;
    line-height: 1.45;
    color: #fff8e7;
    text-shadow: 0 1px 10px rgba(30, 20, 12, 0.28);
}
.portal-role-inline {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-weight: 800;
}
.portal-role-inline i {
    color: var(--portal-lime);
    font-size: 0.95em;
}
.portal-header-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 0.5rem;
    min-width: 0;
    max-width: 100%;
}
.portal-header-actions .btn {
    min-height: 44px;
}
@media (max-width: 640px) {
    /* Celular: botões menores e na mesma linha, sem ultrapassar a margem lateral. */
    .portal-header-actions {
        width: 100%;
        flex-wrap: nowrap;
        justify-content: stretch;
        gap: 0.4rem;
    }
    .portal-header-actions .btn {
        flex: 1 1 0;
        min-width: 0;
        min-height: 40px;
        padding: 0.35rem 0.5rem;
        font-size: 0.78rem;
        white-space: normal;
        line-height: 1.15;
        text-align: center;
    }
}
.portal-event-note {
    margin: 0.85rem 0 0;
    max-width: 36rem;
    color: #fff8e7;
    font-size: 0.92rem;
    font-weight: 700;
    line-height: 1.35;
    text-shadow: 0 1px 10px rgba(30, 20, 12, 0.28);
}
.portal-event-note--detail {
    margin-top: 0.35rem;
    font-size: 0.8rem;
    font-weight: 500;
    line-height: 1.45;
    color: rgba(255, 248, 231, 0.92);
}
.portal-event-highlight {
    color: #facc15;
    font-weight: 800;
}

.portal-login-stage {
    width: min(26.5rem, 100%);
    animation: portalRise 0.85s ease both;
    animation-delay: 0.08s;
}

.portal-login-panel {
    position: relative;
    border-radius: 1.35rem;
    padding: 1.35rem 1.3rem 1.2rem;
    background: linear-gradient(165deg, rgba(255, 252, 246, 0.9), rgba(255, 255, 255, 0.78));
    border: 1px solid rgba(255, 255, 255, 0.62);
    box-shadow:
        0 22px 50px rgba(40, 28, 18, 0.22),
        inset 0 1px 0 rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    overflow: hidden;
}

.portal-login-panel::before {
    content: '';
    position: absolute;
    inset: 0 auto auto 0;
    width: 100%;
    height: 3px;
    background: linear-gradient(90deg, var(--portal-brown), var(--portal-lime), var(--portal-olive));
}

.portal-panel-head {
    margin-bottom: 0.85rem;
}

.portal-panel-head h2 {
    margin: 0;
    font-family: 'Outfit', sans-serif;
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--portal-text);
}

.portal-panel-head p {
    margin: 0.25rem 0 0;
    font-size: 0.86rem;
    color: var(--portal-muted);
}

.portal-login-form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.portal-label {
    display: flex;
    flex-direction: column;
    gap: 0.28rem;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: var(--portal-brown);
}

.portal-label input {
    width: 100%;
    border: 1px solid rgba(63, 42, 31, 0.16);
    background: rgba(255, 255, 255, 0.9);
    border-radius: 0.75rem;
    padding: 0.78rem 0.9rem;
    font-size: 0.98rem;
    color: var(--portal-text);
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.portal-label input:focus {
    border-color: var(--portal-lime-deep);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(198, 224, 58, 0.28);
}

.portal-password-wrap {
    position: relative;
    display: block;
}

.portal-password-wrap input {
    padding-right: 3.1rem;
}

/* Windows/Edge/Chrome: esconde o olho nativo — o app já tem o botão próprio */
.portal-password-wrap input::-ms-reveal,
.portal-password-wrap input::-ms-clear {
    display: none;
}
.portal-password-wrap input::-webkit-credentials-auto-fill-button,
.portal-password-wrap input::-webkit-strong-password-auto-fill-button {
    display: none !important;
    visibility: hidden;
    pointer-events: none;
    margin: 0;
    width: 0;
    height: 0;
}

.portal-pass-toggle {
    position: absolute;
    right: 0.2rem;
    top: 50%;
    transform: translateY(-50%);
    width: 2.75rem;
    height: 2.75rem;
    border: 0;
    border-radius: 0.6rem;
    background: rgba(255, 255, 255, 0.75);
    color: var(--portal-olive);
    cursor: pointer;
    display: grid;
    place-items: center;
    z-index: 5;
    pointer-events: auto;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    transition: background 0.15s ease, color 0.15s ease;
}

.portal-pass-toggle:hover,
.portal-pass-toggle:active {
    background: rgba(109, 124, 78, 0.16);
    color: var(--portal-brown);
}

#registrationForm .portal-pass-toggle {
    color: #4b5563;
    background: transparent;
}

#registrationForm .portal-pass-toggle:hover,
#registrationForm .portal-pass-toggle:active {
    background: rgba(75, 85, 99, 0.12);
    color: #111827;
}

/* Listas (expositor, lojista, visitante): só as linhas rolam; o topo fica parado. */
#mainContent:has(.directory-page) {
    overflow: hidden;
}
#pageContent:has(> .directory-page) {
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}
.directory-page {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.directory-page-lock {
    flex: 0 0 auto;
}
.directory-page-list {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
}
.directory-page-list .clients-table-head > div,
.directory-page-list thead th {
    position: sticky;
    top: 0;
    z-index: 4;
    background: #f9fafb;
}

.clients-table-wrap {
    overflow: visible;
}
.directory-list-count {
    padding: 0.7rem 1rem 0.55rem;
    font-size: 0.92rem;
    font-weight: 700;
    color: #111827;
    background: #fff;
    border-bottom: 1px solid #e5e7eb;
    line-height: 1.3;
}
.directory-list-count[data-empty="1"] {
    color: #6b7280;
    font-weight: 600;
}
@media (max-width: 1024px) {
    .directory-list-count {
        padding: 0.55rem 0.75rem 0.45rem;
        font-size: 0.84rem;
    }
}
.clients-table {
    display: table;
    width: 100%;
    table-layout: fixed;
    border-collapse: collapse;
}
.clients-table-row {
    display: table-row;
}
.clients-table-row > div {
    display: table-cell;
    vertical-align: middle;
    border-bottom: 1px solid #e5e7eb;
}
.clients-table-head > div {
    background: #f9fafb;
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    color: #4b5563;
    border-bottom: 1px solid #e5e7eb;
}
.clients-col-check {
    padding: 0.75rem 0.5rem;
    text-align: center;
    width: 2.75rem;
    border-right: 2px solid #d1d5db;
}
.clients-col-check input[type="checkbox"] {
    width: 1.1rem;
    height: 1.1rem;
    margin: 0;
    cursor: pointer;
    accent-color: var(--brand-olive, #6d7c4e);
    vertical-align: middle;
}
.clients-bulk-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 0.75rem;
    padding: 0.65rem 0.85rem;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 0.5rem;
}
.clients-bulk-bar-copy {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    min-width: 12rem;
    flex: 1;
}
.clients-bulk-bar .btn[disabled] {
    opacity: 0.45;
    cursor: not-allowed;
}
.clients-col-name {
    padding: 0.85rem 0.75rem;
    border-right: 2px solid #d1d5db;
    white-space: normal;
    width: 26%;
    overflow-wrap: anywhere;
}
.clients-col-name .font-medium,
.clients-col-name .text-sm {
    white-space: normal;
    overflow-wrap: anywhere;
}
.registry-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-bottom: 0.25rem;
    white-space: normal;
    max-width: none;
}
.registry-tag {
    display: inline-flex;
    align-items: center;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    line-height: 1.2;
    padding: 0.2rem 0.5rem;
    border-radius: 999px;
    white-space: normal;
    overflow-wrap: anywhere;
    max-width: 100%;
}
@media (max-width: 1024px) {
    .registry-tag {
        font-size: 9px;
        padding: 0.22rem 0.45rem;
    }
}
.registry-tag-pending {
    background: #fef3c7;
    color: #92400e;
}
.registry-tag-invite {
    background: #e0f2fe;
    color: #075985;
}
.registry-tag-doc {
    background: #ffe4e6;
    color: #9f1239;
}
.registry-tag-ok {
    background: #dcfce7;
    color: #166534;
}
.registry-tag-dup {
    background: #ffedd5;
    color: #9a3412;
}
.registry-tag-alert {
    background: #fecaca;
    color: #991b1b;
}
.clients-doc-btn {
    white-space: normal;
    line-height: 1.25;
    width: 100%;
    max-width: none;
    min-height: 44px;
}
.clients-col-action {
    padding: 0.55rem 0.4rem;
    text-align: center;
    border-right: 2px solid #d1d5db;
    white-space: normal;
    overflow-wrap: anywhere;
}
.clients-col-action .btn {
    width: 100%;
    max-width: none;
    white-space: normal;
}
.clients-col-action:last-child {
    border-right: 0;
}
.clients-table-head .clients-col-docs {
    white-space: normal;
    line-height: 1.25;
    text-align: center;
    vertical-align: middle;
}
.view-portal-docs-btn {
    white-space: normal;
    line-height: 1.2;
    width: 100%;
    max-width: none;
}
.clients-table-row:hover > div {
    background: #f9fafb;
}
@media (max-width: 768px) {
    .directory-page-list .clients-table {
        width: max-content;
        min-width: 100%;
        table-layout: auto;
    }
    /* Largura fixa: tags e nomes quebram/empilham como no PC em vez de alargar a coluna. */
    .clients-col-name { width: 15rem; min-width: 15rem; max-width: 15rem; }
    .clients-col-name > * { width: 13.5rem; max-width: 13.5rem; }
    .clients-col-name > span { display: block; }
    .clients-col-action { min-width: 8.5rem; }
}

/* Celular e tablet: o topo continua travado, mas compacto, para a lista não sumir. */
@media (max-width: 1024px) {
    .directory-page {
        padding: 0.5rem 0.65rem;
    }
    .directory-page .page-sticky-head {
        margin-bottom: 0.35rem;
        padding: 0.15rem 0;
        gap: 0.35rem;
    }
    .directory-page .page-title {
        font-size: 1.05rem;
    }
    .directory-page .page-subtitle {
        display: none;
    }
    .directory-page .btn-back {
        margin-bottom: 0.2rem;
        min-height: 34px;
    }
    .directory-page .mb-3,
    .directory-page .mb-4,
    .directory-page .mb-6 {
        margin-bottom: 0.35rem;
    }
    .directory-page .clients-bulk-bar {
        margin-bottom: 0.35rem;
        padding: 0.35rem 0.5rem;
    }
    .directory-page .clients-bulk-bar .text-xs {
        display: none;
    }
    .directory-page .page-sticky-head .btn,
    .directory-page-lock .btn {
        padding: 0.35rem 0.55rem;
        font-size: 0.75rem;
        min-height: 34px;
    }
    .directory-page-lock:first-child {
        max-height: 34dvh;
        overflow: auto;
    }
    .directory-page-list {
        flex: 1 1 auto;
    }
    .portal-editor-top {
        padding: 0.55rem 0.75rem 0.2rem;
        max-height: 34dvh;
        overflow: auto;
    }
    .portal-editor .page-title {
        font-size: 1.15rem;
    }
    .portal-editor .page-subtitle {
        margin-top: 0.15rem;
        font-size: 0.8rem;
    }
    .portal-editor .btn-back {
        margin-bottom: 0.25rem;
    }
    .portal-editor-scroll {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }
}

.portal-submit {
    margin-top: 0.2rem;
    width: 100%;
    border: 0;
    border-radius: 0.85rem;
    padding: 0.9rem 1rem;
    font-family: 'Outfit', sans-serif;
    font-size: 1.02rem;
    font-weight: 800;
    color: var(--portal-brown);
    background: linear-gradient(180deg, #d6ef55 0%, var(--portal-lime) 55%, var(--portal-lime-deep) 100%);
    box-shadow: 0 12px 26px rgba(120, 140, 30, 0.3);
    cursor: pointer;
    transition: transform 0.15s ease, filter 0.15s ease, box-shadow 0.15s ease;
}

.portal-submit:hover:not(:disabled) {
    filter: brightness(1.03);
    transform: translateY(-1px);
    box-shadow: 0 16px 30px rgba(120, 140, 30, 0.36);
}

.portal-submit:disabled {
    opacity: 0.72;
    cursor: wait;
}

.portal-precadastro-wrap {
    margin-top: 1rem;
    padding-top: 0.95rem;
    border-top: 1px dashed rgba(63, 42, 31, 0.18);
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
}
.portal-precadastro-or {
    margin: 0;
    text-align: center;
    font-size: 0.82rem;
    font-weight: 700;
    color: #5b4636;
}
.portal-precadastro-btn {
    width: 100%;
    min-height: 52px;
    border: 0;
    border-radius: 0.9rem;
    padding: 0.85rem 1rem;
    font-family: 'Outfit', sans-serif;
    font-size: 1.05rem;
    font-weight: 800;
    color: #3f2a1f;
    background: linear-gradient(180deg, #fde047 0%, #facc15 45%, #eab308 100%);
    box-shadow: 0 12px 24px rgba(202, 138, 4, 0.38);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.55rem;
}
.portal-precadastro-btn:hover {
    filter: brightness(1.05);
    transform: translateY(-1px);
}
.portal-precadastro-btn i {
    color: #3f2a1f;
    font-size: 1.1rem;
}
.btn-cancel-close {
    white-space: nowrap;
}
@media (max-width: 640px) {
    .btn-cancel-close { white-space: normal; }
}
.form-actions-bar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.5rem;
    flex-wrap: wrap;
    flex-shrink: 0;
}
.template-tools {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem;
    margin-bottom: 0.55rem;
}
.template-tools .btn {
    min-height: 44px;
}
.template-tools select {
    min-height: 44px;
    flex: 1 1 12rem;
    max-width: 100%;
    border: 1px solid #d1d5db;
    border-radius: 0.45rem;
    padding: 0 0.65rem;
    background: #fff;
    color: #1f2937;
    font-size: 0.9rem;
}
.template-source-note {
    margin: 0 0 0.55rem;
    padding: 0.5rem 0.65rem;
    font-size: 0.85rem;
    line-height: 1.35;
    color: #92400e;
    background: #fffbeb;
    border: 1px solid #fcd34d;
    border-radius: 0.45rem;
}
.template-source-note.hidden {
    display: none;
}
.template-preview-caption {
    margin: 0;
    flex: 1;
    text-align: left;
    font-size: 0.85rem;
    line-height: 1.35;
    color: #4b5563;
}
.template-preview-frame {
    width: 100%;
    flex: 1;
    min-height: 0;
    border: 1px solid #e5e7eb;
    background: #fff;
}
#templatePreviewModal {
    z-index: 80;
}

/* Cabeçalho estático em páginas e modais com lista/conteúdo rolável */
.page-sticky-head {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1rem;
    padding: 0.65rem 0;
    background: #f3f4f6;
    box-shadow: 0 8px 14px -10px rgba(20, 12, 6, 0.28);
}
.page-sticky-head--card {
    background: #fff;
    margin: -0.25rem -0.25rem 0.85rem;
    padding: 0.65rem 0.25rem;
}
.modal-sticky-head {
    position: sticky;
    top: 0;
    z-index: 6;
    flex-shrink: 0;
    background: #fff;
    padding-top: 0.15rem;
    padding-bottom: 0.75rem;
    margin-bottom: 0.25rem;
    box-shadow: 0 10px 16px -12px rgba(20, 12, 6, 0.35);
}
.secret-mask,
input.secret-mask {
    -webkit-text-security: disc;
}
.boleto-open-line {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.45rem 0.65rem;
    min-width: 0;
    background: transparent;
    border: 0;
    padding: 0;
    cursor: pointer;
}
.boleto-tag {
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
    border-radius: 999px;
    padding: 0.2rem 0.65rem;
    font-size: 0.75rem;
    font-weight: 800;
    letter-spacing: 0.02em;
}
.boleto-tag--pago {
    background: #dcfce7;
    color: #166534;
}
.boleto-tag--pendente {
    background: #fef3c7;
    color: #92400e;
}
.term-tag--assinado {
    background: #dcfce7;
    color: #166534;
    text-transform: uppercase;
}
.term-tag--pendente {
    background: #fef3c7;
    color: #92400e;
    text-transform: uppercase;
}
.term-tag--none {
    background: #f3f4f6;
    color: #4b5563;
    text-transform: uppercase;
}
.portal-term-editions-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}
.portal-term-edition-group {
    margin: 0;
}
.portal-term-edition-card {
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    min-height: 4.5rem;
}
.portal-term-edition-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.45rem 0.6rem;
    min-width: 0;
}
.portal-term-edition-head .portal-hub-label {
    margin: 0;
    min-width: 0;
}
.portal-hub-pending-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-top: 0.35rem;
}
.portal-term-edition-date {
    display: block;
    margin-top: 0.15rem;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--ui-muted);
}
.portal-term-detail-head {
    margin-bottom: 1rem;
    padding: 0.9rem 1rem;
    border-radius: 0.9rem;
    border: 1px solid var(--ui-line);
    background: var(--ui-surface);
}
.portal-term-detail-title-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem 0.75rem;
}
.portal-term-detail-title {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--ui-ink);
    line-height: 1.25;
    overflow-wrap: anywhere;
}
.portal-term-detail-date {
    margin: 0.25rem 0 0;
    font-size: 0.84rem;
    font-weight: 600;
    color: var(--ui-muted);
}
.portal-term-detail-sub {
    margin: 0.35rem 0 0;
    font-size: 0.88rem;
    color: var(--ui-muted);
    line-height: 1.35;
}
.aguardando-assinaturas {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 4.75rem;
    margin: 0.35rem 0 0.75rem;
    padding: 1rem 1.1rem;
    border-radius: 0.9rem;
    border: 2px solid #f59e0b;
    background: #fef3c7;
    color: #92400e;
    font-size: 1.05rem;
    font-weight: 800;
    letter-spacing: 0.01em;
    text-align: center;
}
.contract-signed-warning {
    margin-top: 0.75rem;
    padding: 0.75rem 0.85rem;
    background: #fef3c7;
    color: #78350f;
    border: 1px solid #f59e0b;
    border-radius: 0.5rem;
    font-size: 0.92rem;
    line-height: 1.4;
}
.assinatura-envio-linha {
    margin: 0.45rem 0 0.85rem;
    text-align: center;
    font-size: 0.95rem;
    font-weight: 700;
    color: #92400e;
    line-height: 1.4;
}
.btn-assinatura {
    width: 100%;
    margin-top: 0.35rem;
    white-space: normal;
    text-align: center;
    line-height: 1.25;
}
.contrato-envio-nota {
    margin: 0.35rem 0 0.75rem;
    padding: 0.7rem 0.85rem;
    border-radius: 0.75rem;
    border: 2px solid #f59e0b;
    background: #fef3c7;
    color: #92400e;
    font-size: 0.92rem;
    font-weight: 800;
    text-align: center;
}
.portal-hub-card--legal .portal-hub-icon { background: linear-gradient(160deg, #b45309, #f59e0b); }
.boleto-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    margin-top: 0.85rem;
}

.precadastro-overlay {
    position: fixed;
    inset: 0;
    z-index: 160;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: max(0.75rem, env(safe-area-inset-top)) 0.75rem max(0.75rem, env(safe-area-inset-bottom));
    background: rgba(20, 12, 6, 0.62);
    overflow-y: auto;
}
.precadastro-overlay.hidden { display: none !important; }
.precadastro-sheet {
    width: min(48rem, 100%);
    margin: 0.5rem auto;
    background: #fff;
    border-radius: 1.1rem;
    box-shadow: 0 22px 48px rgba(20, 12, 6, 0.32);
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 1.5rem);
}
.precadastro-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 1.1rem 1.15rem 0.85rem;
    border-bottom: 1px solid #e5e7eb;
}
.precadastro-head h2 {
    margin: 0;
    font-family: 'Outfit', sans-serif;
    font-size: 1.35rem;
    font-weight: 800;
    color: #1f2937;
}
.precadastro-head p {
    margin: 0.35rem 0 0;
    font-size: 0.86rem;
    color: #6b7280;
}
.precadastro-body {
    padding: 1rem 1.15rem 1.25rem;
    overflow-y: auto;
}

.portal-forgot {
    border: 0;
    background: transparent;
    color: var(--portal-olive);
    font-size: 0.86rem;
    font-weight: 700;
    text-decoration: underline;
    text-underline-offset: 3px;
    cursor: pointer;
    padding: 0.25rem;
    align-self: center;
}

.portal-forgot:hover {
    color: var(--portal-brown);
}

.portal-forgot:disabled {
    opacity: 0.65;
    cursor: wait;
}

.portal-install-bar {
    position: sticky;
    bottom: 0;
    z-index: 5;
    margin-top: auto;
    padding: 0.65rem 0 calc(0.35rem + env(safe-area-inset-bottom, 0px));
    background: linear-gradient(180deg, rgba(30, 22, 14, 0) 0%, rgba(30, 22, 14, 0.45) 35%, rgba(30, 22, 14, 0.55) 100%);
}
.portal-install-btn {
    width: 100%;
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: 0.85rem;
    padding: 0.85rem 1rem;
    min-height: 48px;
    font-family: 'Outfit', sans-serif;
    font-size: 0.95rem;
    font-weight: 800;
    color: #facc15;
    background: linear-gradient(180deg, #7f8f5d 0%, var(--portal-olive) 55%, #556239 100%);
    box-shadow: 0 10px 22px rgba(63, 42, 31, 0.28);
    cursor: pointer;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    gap: 0.55rem;
    transition: transform 0.15s ease, filter 0.15s ease;
    visibility: visible !important;
    opacity: 1 !important;
}
.portal-install-btn.hidden {
    /* Nunca esconder no mobile por engano — só some em standalone via JS + display */
}
.portal-install-btn.is-standalone-hidden,
.portal-install-bar.is-standalone-hidden {
    display: none !important;
}
.portal-install-btn:hover {
    filter: brightness(1.05);
    transform: translateY(-1px);
}
.portal-install-btn i {
    color: #fde047;
}
@media (max-width: 899px) {
    .portal-shell--single {
        justify-content: flex-start;
        gap: 1rem;
        padding-bottom: 0.5rem;
        min-height: 100%;
    }
    .portal-hero {
        margin-top: 0.25rem;
    }
    .portal-title--access {
        font-size: clamp(0.98rem, 3.4vw, 1.2rem);
    }
    .portal-install-bar {
        position: sticky;
        bottom: 0;
        margin-top: 0.75rem;
    }
}

.pwa-help-overlay {
    position: fixed;
    inset: 0;
    z-index: 140;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: rgba(20, 12, 6, 0.55);
}
.pwa-help-overlay.hidden { display: none !important; }
.pwa-help-card {
    width: min(28rem, 100%);
    background: #fff;
    border-radius: 1rem;
    padding: 1.1rem 1.15rem 1rem;
    box-shadow: 0 18px 40px rgba(20, 12, 6, 0.28);
}
.pwa-help-card h3 {
    margin: 0 0 0.65rem;
    font-family: 'Outfit', sans-serif;
    font-size: 1.1rem;
    color: #3f2a1f;
}
.pwa-help-body {
    color: #374151;
    font-size: 0.92rem;
    line-height: 1.45;
    margin-bottom: 0.9rem;
}
.pwa-help-body ol {
    margin: 0.5rem 0 0.75rem 1.1rem;
    padding: 0;
}
.pwa-help-body li { margin: 0.25rem 0; }
.pwa-help-note {
    margin: 0.5rem 0 0;
    font-size: 0.82rem;
    color: #6b7280;
}

/* Bloqueio total: iPhone/iPad fora do Safari */
.ios-safari-gate {
    position: fixed;
    inset: 0;
    z-index: 20000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.25rem;
    padding-bottom: calc(1.25rem + env(safe-area-inset-bottom, 0px));
    background: rgba(20, 12, 6, 0.72);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
}
.ios-safari-gate--final {
    background: #3f2a1f;
}
.ios-safari-gate__card {
    width: min(26rem, 100%);
    background: #fff;
    border-radius: 1rem;
    padding: 1.25rem 1.2rem 1.1rem;
    box-shadow: 0 18px 44px rgba(20, 12, 6, 0.35);
    color: #374151;
    font-size: 0.95rem;
    line-height: 1.45;
}
.ios-safari-gate__card h2 {
    margin: 0 0 0.75rem;
    font-family: 'Outfit', sans-serif;
    font-size: 1.2rem;
    color: #3f2a1f;
}
.ios-safari-gate__card ol {
    margin: 0.5rem 0 0.75rem 1.15rem;
    padding: 0;
}
.ios-safari-gate__card li {
    margin: 0.35rem 0;
}
.ios-safari-gate__url {
    display: block;
    margin-top: 0.35rem;
    word-break: break-all;
    font-weight: 700;
    color: #1f2937;
}
.ios-safari-gate__note {
    margin: 0.75rem 0 1rem;
    font-size: 0.85rem;
    color: #6b7280;
}
.ios-safari-gate .btn-block {
    width: 100%;
}
html.ios-safari-blocked #loginScreen,
html.ios-safari-blocked #lojistaPrecadastroOverlay,
html.ios-safari-blocked #app {
    pointer-events: none !important;
    user-select: none;
}

.portal-error {
    font-size: 0.95rem;
    font-weight: 800;
    text-align: center;
    color: #b91c1c;
    background: rgba(254, 226, 226, 0.98);
    border: 1px solid rgba(185, 28, 28, 0.35);
    border-radius: 0.7rem;
    padding: 0.7rem 0.85rem;
}
.portal-error.hidden {
    display: none !important;
}

.portal-trust-line {
    margin: 0.85rem 0 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    color: rgba(255, 250, 242, 0.88);
    font-size: 0.78rem;
    font-weight: 600;
    text-shadow: 0 1px 8px rgba(20, 12, 6, 0.35);
}

.portal-trust-line i {
    color: var(--portal-lime);
}

@keyframes portalRise {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Visualização / impressão embutida (mobile & tablet) */
body.file-preview-open {
    overflow: hidden;
}
.file-preview-overlay {
    position: fixed;
    inset: 0;
    z-index: 120;
    display: flex;
    align-items: stretch;
    justify-content: center;
    padding: env(safe-area-inset-top, 0) env(safe-area-inset-right, 0) env(safe-area-inset-bottom, 0) env(safe-area-inset-left, 0);
    background: rgba(30, 22, 14, 0.55);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}
.file-preview-overlay.hidden {
    display: none !important;
}
.file-preview-sheet {
    width: min(1100px, 100%);
    height: 100%;
    max-height: 100%;
    display: flex;
    flex-direction: column;
    background: #fff;
    box-shadow: 0 20px 50px rgba(20, 12, 6, 0.28);
}
.file-preview-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.75rem 0.9rem;
    border-bottom: 1px solid #e5e7eb;
    background: linear-gradient(180deg, #f7f8f2 0%, #ffffff 100%);
    flex-shrink: 0;
}
.file-preview-title {
    margin: 0;
    font-family: 'Outfit', 'Figtree', sans-serif;
    font-size: 0.98rem;
    font-weight: 800;
    color: #3f2a1f;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.file-preview-actions {
    display: flex;
    gap: 0.45rem;
    flex-shrink: 0;
}
.file-preview-body {
    flex: 1;
    min-height: 0;
    overflow-x: auto;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    touch-action: pan-x pan-y pinch-zoom;
    background: #f3f4f6;
}
/* PDF no celular: páginas desenhadas na própria tela (o leitor embutido do navegador não aparece no Android/iOS). */
.file-preview-pdf-pages {
    padding: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    align-items: center;
    background: #525659;
    min-height: 100%;
}
.file-preview-pdf-pages canvas {
    display: block;
    width: 100%;
    height: auto;
    background: #fff;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
}
.file-preview-pdf-status {
    margin: 2rem 1rem;
    text-align: center;
    color: #f3f4f6;
    font-weight: 700;
}
.file-preview-pdf-status .btn { margin-top: 1rem; }
.file-preview-html {
    padding: 1rem;
    background: #fff;
    min-height: 100%;
    display: inline-block;
    min-width: 100%;
    vertical-align: top;
    color: #1f2937;
    font-size: 12px;
    line-height: 1.35;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
}
/* Coleta QR: no celular o CSS do app esticava tabelas curtas (Visitantes).
   Força largura pelo conteúdo — mesmo padrão do PC para todos os tipos. */
.file-preview-html .access-xlsx .sheet-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
    max-width: 100%;
}
.file-preview-html .access-xlsx table {
    width: max-content !important;
    min-width: max-content !important;
    max-width: none !important;
    table-layout: auto !important;
    border-collapse: collapse;
    font-size: 12px;
}
.file-preview-html .access-xlsx th,
.file-preview-html .access-xlsx td {
    white-space: nowrap !important;
    width: auto !important;
    max-width: 14rem;
    overflow: hidden;
    text-overflow: ellipsis;
    vertical-align: top;
}
.file-preview-html .report-header { margin: 0 0 10px; padding: 0 0 8px; border-bottom: 2px solid #111827; }
.file-preview-html .report-kicker { margin: 0 0 2px; font-size: 10px; letter-spacing: 0.06em; text-transform: uppercase; color: #6b7280; }
.file-preview-html .report-title { margin: 0 0 4px; font-size: 1.15rem; line-height: 1.2; font-weight: 800; color: #111827; }
.file-preview-html .report-subtitle { margin: 0 0 6px; font-size: 0.9rem; color: #374151; }
.file-preview-html .report-meta { width: 100%; border-collapse: collapse; margin: 0 0 8px; }
.file-preview-html .report-meta th { width: 1%; white-space: nowrap; text-align: left; font-weight: 600; color: #4b5563; padding: 1px 10px 1px 0; border: 0; background: transparent; }
.file-preview-html .report-meta td { padding: 1px 0; border: 0; }
.file-preview-html .report-edition-title {
    font-size: 1.05rem; font-weight: 800; margin: 0 0 8px; padding: 0 0 4px;
    border-bottom: 2px solid #111827;
}
.file-preview-html .report-block { margin: 0 0 10px; padding: 8px 10px 10px; border: 1px solid #d1d5db; border-radius: 3px; }
.file-preview-html .report-block-title {
    margin: -8px -10px 8px; padding: 6px 10px; font-size: 0.78rem; font-weight: 800;
    letter-spacing: 0.04em; text-transform: uppercase;
}
.file-preview-html .report-block--summary { background: #f8fafc; border-color: #cbd5e1; }
.file-preview-html .report-block--summary .report-block-title { background: #1f2937; color: #fff; }
.file-preview-html .report-block--overdue { background: #fff7f7; border-color: #f3c4c4; border-left: 5px solid #b91c1c; }
.file-preview-html .report-block--overdue .report-block-title { background: #b91c1c; color: #fff; }
.file-preview-html .report-block--upcoming,
.file-preview-html .report-block--list { background: #f7f8f4; border-color: #c5cdb0; border-left: 5px solid #6d7c4e; }
.file-preview-html .report-block--upcoming .report-block-title,
.file-preview-html .report-block--list .report-block-title { background: #6d7c4e; color: #fff; }
.file-preview-html .report-block--cards { background: #f7f5ee; border-color: #d8ccb8; border-left: 5px solid #5d4037; }
.file-preview-html .report-block--cards .report-block-title { background: #5d4037; color: #fff; }
.file-preview-html .status-paid { color: #15803d; font-weight: 700; }
.file-preview-html .status-pending { color: #b45309; font-weight: 700; }
.file-preview-html .status-cancelled { color: #dc2626; font-weight: 700; }
.file-preview-html .status-frozen { color: #b45309; font-weight: 700; }
.file-preview-html .report-client { margin: 0 0 8px; padding: 6px 8px 8px; background: #fff; border: 1px solid #e5e7eb; }
.file-preview-html .report-block--overdue .report-client { border-left: 3px solid #dc2626; }
.file-preview-html .report-block--upcoming .report-client { border-left: 3px solid #6d7c4e; }
.file-preview-html .report-client-k { margin: 0; font-size: 10px; letter-spacing: 0.06em; text-transform: uppercase; color: #6b7280; }
.file-preview-html .report-client-title { margin: 0 0 4px; font-size: 0.95rem; font-weight: 800; color: #111827; }
.file-preview-html .report-client-sub { margin: 0 0 4px; font-size: 0.85rem; color: #4b5563; }
.file-preview-doc-title {
    margin: 0 0 0.75rem;
    font-size: 1rem;
    font-weight: 800;
    color: #1f2937;
}
.file-preview-html table {
    border-collapse: collapse;
    width: max-content;
    min-width: 100%;
    font-size: 11px;
    background: #fff;
}
.file-preview-html td,
.file-preview-html th {
    border: 1px solid #e5e7eb;
    padding: 4px 6px;
    vertical-align: top;
    white-space: nowrap;
}
.file-preview-html .access-xlsx {
    min-width: min-content;
}
.file-preview-html .access-xlsx .sheet-block {
    min-width: min-content;
}
.file-preview-html .access-xlsx .resumo-grid {
    width: min(100vw - 2rem, 640px);
}
.file-preview-html th {
    background: #f3f4f6;
}
.file-preview-html .report-meta th,
.file-preview-html .report-meta td {
    border: 0;
    background: transparent;
}
.file-preview-pdf {
    width: 100%;
    height: 100%;
    border: 0;
    background: #525659;
}
.file-preview-image {
    display: block;
    max-width: 100%;
    height: auto;
    margin: 1rem auto;
    background: #fff;
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.12);
}

@media print {
    body.file-preview-open .file-preview-header,
    body.file-preview-open .file-preview-overlay {
        background: #fff !important;
        backdrop-filter: none !important;
    }
    body.file-preview-open .file-preview-header { display: none !important; }
    body.file-preview-open .file-preview-overlay {
        position: static;
        padding: 0;
    }
    body.file-preview-open .file-preview-sheet { box-shadow: none; width: 100%; height: auto; }
}

@media (min-width: 900px) {
    .portal-shell--single {
        display: grid;
        grid-template-columns: 1.15fr 0.85fr;
        align-items: center;
        gap: 2.5rem;
        padding: 2rem 1.5rem;
    }
    .portal-login-stage {
        width: 100%;
        justify-self: end;
    }
}

@media (max-width: 899px) {
    .portal-shell--single {
        justify-content: flex-start;
        padding-top: max(1.25rem, env(safe-area-inset-top));
    }
    .portal-login-stage {
        width: 100%;
    }
}

@media (prefers-reduced-motion: reduce) {
    .portal-bg,
    .portal-hero,
    .portal-login-stage {
        animation: none !important;
    }
}

body.mobile-nav-lock {
    overflow: hidden;
}

/* Barras de rolagem personalizadas */
.sidebar-scroll::-webkit-scrollbar, .main-scroll::-webkit-scrollbar { width: 4px; }
.sidebar-scroll::-webkit-scrollbar-thumb, .main-scroll::-webkit-scrollbar-thumb { background: #4a5568; border-radius: 10px; }
.sidebar-scroll::-webkit-scrollbar-track, .main-scroll::-webkit-scrollbar-track { background: #2d3748; }

/* Sidebar base (desktop) */
.app-sidebar {
    width: 20rem; /* w-80 */
    flex-shrink: 0;
}

/* Topbar mobile — oculta no desktop */
.mobile-topbar {
    display: none;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 0.85rem;
    padding-top: calc(0.65rem + env(safe-area-inset-top, 0px));
    background: #1f2937;
    color: #fff;
    position: sticky;
    top: 0;
    z-index: 40;
    border-bottom: 1px solid #374151;
}
.mobile-topbar-title {
    font-weight: 700;
    font-size: 1.05rem;
}
.mobile-menu-btn {
    min-width: 44px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.5rem;
    background: #374151;
    color: #fff;
    font-size: 1.15rem;
}
.mobile-menu-btn:active {
    background: #4b5563;
}

.sidebar-overlay {
    display: none;
}

/* Cores base para os botões da barra lateral */
.sidebar-btn {
    transition: background-color 0.3s, transform 0.2s;
    min-height: 44px;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}
.sidebar-btn:hover {
    transform: scale(1.02);
}

#editionsBtn { background-color: #2dd4bf; } /* Teal */
#clientsBtn { background-color: #60a5fa; } /* Blue */
#attendeesBtn { background-color: #f97316; } /* Orange — destaque Lojistas/Visitantes */
#billingBtn { background-color: #f472b6; } /* Pink */
#reportsBtn { background-color: #a78bfa; } /* Purple */
#sistemaBtn { background-color: #facc15; } /* Yellow */
#eventAccessBtn { background-color: #34d399; color: #064e3b; } /* Emerald — acessos evento */
#logoutBtn { background-color: #b91c1c; color: #fff; } /* Sair — vermelho de encerramento */

#editionsBtn:hover { background-color: #14b8a6; }
#clientsBtn:hover { background-color: #3b82f6; }
#attendeesBtn:hover { background-color: #ea580c; }
#billingBtn:hover { background-color: #ec4899; }
#reportsBtn:hover { background-color: #8b5cf6; }
#sistemaBtn:hover { background-color: #eab308; }
#eventAccessBtn:hover { background-color: #10b981; color: #fff; }
#logoutBtn:hover { background-color: #991b1b; color: #fff; }

/* Estilo do botão ativo - mais escuro e com borda */
.sidebar-btn-active {
    background-color: #0d9488 !important;
    box-shadow: inset 0 2px 4px 0 rgba(0, 0, 0, 0.2);
}
#clientsBtn.sidebar-btn-active { background-color: #2563eb !important; }
#attendeesBtn.sidebar-btn-active { background-color: #c2410c !important; }
#billingBtn.sidebar-btn-active { background-color: #db2777 !important; }
#reportsBtn.sidebar-btn-active { background-color: #7c3aed !important; }
#sistemaBtn.sidebar-btn-active { background-color: #ca8a04 !important; }
#eventAccessBtn.sidebar-btn-active { background-color: #059669 !important; color: #fff !important; }
#logoutBtn.sidebar-btn-active { background-color: #7f1d1d !important; color: #fff !important; }

/* Busca padronizada (ícone + padding para não sobrepor o placeholder) */
.ui-search-wrap {
    position: relative;
}
.ui-search-wrap > .ui-search-icon {
    position: absolute;
    left: 0.9rem;
    top: 50%;
    transform: translateY(-50%);
    color: #9ca3af;
    pointer-events: none;
    z-index: 1;
    font-size: 0.95rem;
}
.ui-search-wrap > .ui-input,
.ui-search-wrap > input[type="text"],
.ui-search-wrap > input[type="search"] {
    padding-left: 2.75rem !important;
}

/* Portais (cliente/lojista/visitante): sem menu lateral — esconde hamburger */
#app.portal-mode .mobile-topbar {
    display: none !important;
}

/* --- Layout celular / tablet --- */
@media (max-width: 1023px) {
    #app {
        position: relative;
    }

    .mobile-topbar {
        display: flex;
    }

    .app-sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        width: min(20rem, 88vw);
        z-index: 70;
        transform: translateX(-105%);
        transition: transform 0.25s ease;
        padding-bottom: env(safe-area-inset-bottom, 0px);
        box-shadow: 4px 0 24px rgba(0,0,0,0.35);
    }

    #app.sidebar-open .app-sidebar {
        transform: translateX(0);
    }

    .sidebar-overlay {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.55);
        z-index: 65;
        -webkit-tap-highlight-color: transparent;
    }

    .mobile-sidebar-title {
        padding-top: calc(0.5rem + env(safe-area-inset-top, 0px));
    }

    #mainContent {
        width: 100%;
        max-width: 100vw;
    }

    #pageContent {
        padding-bottom: env(safe-area-inset-bottom, 0px);
    }

    .portal-hub-card {
        grid-template-columns: auto minmax(0, 1fr);
        align-items: start;
    }
    .portal-hub-cta {
        grid-column: 2;
        justify-self: start;
        margin-top: 0.35rem;
        white-space: normal;
    }
    .portal-hub-label,
    .portal-hub-desc {
        overflow-wrap: anywhere;
    }
    /* Formulários e edição: a tela inteira rola, o conteúdo não fica cortado */
    .app-modal:not(#genericModal):not(#viewContractModal):not(#viewTermModal) {
        align-items: flex-start !important;
        justify-content: flex-start !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch;
        padding: 0.75rem 0.5rem calc(1.5rem + env(safe-area-inset-bottom, 0px)) !important;
    }
    .app-modal > .app-modal-card,
    .app-modal > div {
        width: calc(100% - 0.25rem) !important;
        max-width: 100% !important;
        height: auto !important;
        max-height: none !important;
        overflow: visible !important;
        margin: 0.25rem auto 1.25rem !important;
    }
    .app-modal > div > .modal-sticky-head,
    .app-modal > .app-modal-card > .modal-sticky-head {
        position: sticky !important;
        top: 0 !important;
        z-index: 8;
        background: #fff;
    }
    #contractModal > div > .modal-sticky-head {
        flex-direction: column;
        align-items: stretch;
    }
    #contractModal > div > .modal-sticky-head .form-actions-bar {
        width: 100%;
        justify-content: stretch;
    }
    #contractModal > div > .modal-sticky-head .form-actions-bar .btn {
        flex: 1 1 8rem;
        min-height: 44px;
    }
    #contractForm .grid-cols-2 {
        grid-template-columns: 1fr;
    }
    .app-modal > div > .overflow-y-auto,
    .app-modal > .app-modal-card > .overflow-y-auto,
    #adminPermissionsModal form {
        overflow: visible !important;
        max-height: none !important;
    }
    .app-modal > div > .flex,
    .app-modal > .app-modal-card > .flex {
        flex-wrap: wrap;
    }
    #termEditorModal > .app-modal-card,
    #contractTemplateModal > .app-modal-card,
    #templatePreviewModal > .app-modal-card {
        min-height: 75dvh;
    }
    .form-actions-bar {
        width: 100%;
        justify-content: flex-start;
    }

    #lojistasTableContainer > div,
    #visitantesTableContainer > div {
        flex-wrap: wrap;
        row-gap: 0.35rem;
    }

    #toastContainer {
        left: 1rem !important;
        right: 1rem !important;
        bottom: calc(1rem + env(safe-area-inset-bottom, 0px)) !important;
    }
}

/* Tablet deitado: todos os modais do app precisam rolar a tela inteira */
@media (min-width: 1024px) and (max-width: 1400px) {
    .app-modal {
        align-items: flex-start !important;
        justify-content: center !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch;
        padding: 0.75rem 0.5rem calc(1.5rem + env(safe-area-inset-bottom, 0px)) !important;
    }
    .app-modal > .app-modal-card,
    .app-modal > div {
        height: auto !important;
        max-height: none !important;
        overflow: visible !important;
    }
    .app-modal > .app-modal-card > .overflow-y-auto,
    .app-modal > .app-modal-card > form.overflow-y-auto,
    .app-modal > div > .overflow-y-auto {
        overflow: visible !important;
        max-height: none !important;
    }
}

/* Toasts (Notificações) */
.toast {
    padding: 1rem 1.5rem;
    border-radius: 0.5rem;
    color: white;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s ease-out;
    max-width: min(24rem, calc(100vw - 2rem));
    pointer-events: auto;
}
.toast.show {
    opacity: 1;
    transform: translateY(0);
}
.toast-success { background-color: #10B981; }
.toast-error { background-color: #EF4444; }
.toast-warning {
    background-color: #9A3412;
    max-width: min(28rem, calc(100vw - 2rem));
    line-height: 1.45;
}

/* QR reader video fills container on mobile */
#qrReader video,
#qrReader canvas {
    max-width: 100% !important;
    border-radius: 0.5rem;
}

/* Modo câmera QR: cabe na tela sem rolar (admin + portal expositor) */
body.qr-scan-active .qr-scan-hide-when-active {
    display: none !important;
}
body.qr-scan-active .qr-scanner-panel {
    margin-bottom: 0.5rem;
}
body.qr-scan-active .qr-reader-box,
body.qr-scan-active #qrReader {
    max-width: min(100%, 20rem);
    max-height: min(42dvh, 16.5rem);
}
body.qr-scan-active #qrReader video,
body.qr-scan-active #qrReader canvas {
    max-height: min(42dvh, 16.5rem) !important;
    width: 100% !important;
    object-fit: cover;
}
body.qr-scan-active .qr-scan-hint {
    display: none;
}
body.qr-scan-active .qr-scan-page-head .page-title {
    font-size: 1.15rem;
    line-height: 1.25;
    margin-bottom: 0.25rem;
}
body.qr-scan-active .qr-scan-page-head .btn-back {
    margin-bottom: 0.35rem;
}
body.qr-scan-active .portal-editor-scroll {
    overflow: hidden;
}
@media (max-height: 700px) {
    body.qr-scan-active .qr-reader-box,
    body.qr-scan-active #qrReader {
        max-height: min(36dvh, 14rem);
    }
    body.qr-scan-active #qrReader video,
    body.qr-scan-active #qrReader canvas {
        max-height: min(36dvh, 14rem) !important;
    }
    body.qr-scan-active #qrScanStatus {
        font-size: 0.8rem;
        min-height: 1.5rem;
    }
}

/* Estilos de Impressão */
@media print {
    body * {
        visibility: hidden;
    }
    #print-area, #print-area * {
        visibility: visible;
    }
    #print-area {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
    }
    .mobile-topbar, .app-sidebar, .sidebar-overlay {
        display: none !important;
    }
}

/* ========== PWA install banner ========== */
.pwa-install-banner {
    position: fixed;
    left: 50%;
    bottom: max(1rem, env(safe-area-inset-bottom));
    transform: translateX(-50%);
    z-index: 120;
    width: min(26rem, calc(100% - 1.5rem));
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
    border-radius: 1rem;
    background: rgba(255, 252, 246, 0.96);
    border: 1px solid rgba(63, 42, 31, 0.14);
    box-shadow: 0 16px 40px rgba(30, 20, 12, 0.28);
    animation: portalRise 0.35s ease both;
}
.pwa-install-copy {
    flex: 1 1 12rem;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}
.pwa-install-copy strong {
    font-family: 'Outfit', 'Figtree', sans-serif;
    font-size: 0.95rem;
    color: #3f2a1f;
}
.pwa-install-copy span {
    font-size: 0.8rem;
    color: #5c5348;
    line-height: 1.35;
}
.pwa-install-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    align-items: center;
}
.pwa-install-btn {
    border: 0;
    border-radius: 0.7rem;
    padding: 0.55rem 0.9rem;
    font-weight: 800;
    font-family: 'Outfit', 'Figtree', sans-serif;
    font-size: 0.85rem;
    color: #3f2a1f;
    background: linear-gradient(180deg, #d6ef55 0%, #c6e03a 55%, #9fbc1f 100%);
    cursor: pointer;
}
.pwa-install-dismiss {
    border: 0;
    background: transparent;
    color: #6d7c4e;
    font-size: 0.8rem;
    font-weight: 700;
    text-decoration: underline;
    text-underline-offset: 2px;
    cursor: pointer;
    padding: 0.4rem 0.5rem;
}
@media (display-mode: standalone) {
    .pwa-install-banner { display: none !important; }

    /* Evita tarja clara / metade da tela (body cinza + 100vh errado no PWA) */
    html, body {
        height: 100%;
        min-height: 100%;
        min-height: 100dvh;
        min-height: -webkit-fill-available;
        background: #3f2a1f !important;
    }
    .portal-screen {
        height: 100%;
        height: 100dvh;
        height: -webkit-fill-available;
        min-height: 100dvh;
        min-height: -webkit-fill-available;
        top: 0;
        right: 0;
        bottom: 0;
        left: 0;
    }
    .portal-bg,
    .portal-veil,
    .portal-grain {
        top: calc(-1 * env(safe-area-inset-top, 0px));
        right: calc(-1 * env(safe-area-inset-right, 0px));
        bottom: calc(-1 * env(safe-area-inset-bottom, 0px));
        left: calc(-1 * env(safe-area-inset-left, 0px));
    }
    #app.h-screen,
    #app {
        min-height: 100dvh;
        min-height: -webkit-fill-available;
        height: 100dvh;
        height: -webkit-fill-available;
        background: #f3f4f6;
    }
    .mobile-topbar {
        padding-top: calc(0.65rem + env(safe-area-inset-top, 0px));
    }
}
html.is-pwa-standalone,
html.is-pwa-standalone body {
    height: 100%;
    min-height: 100dvh;
    min-height: -webkit-fill-available;
    background: #3f2a1f !important;
}
html.is-pwa-standalone .portal-screen {
    height: 100dvh;
    height: -webkit-fill-available;
    min-height: 100dvh;
    min-height: -webkit-fill-available;
}
html.is-pwa-standalone .portal-bg,
html.is-pwa-standalone .portal-veil,
html.is-pwa-standalone .portal-grain {
    top: calc(-1 * env(safe-area-inset-top, 0px));
    right: calc(-1 * env(safe-area-inset-right, 0px));
    bottom: calc(-1 * env(safe-area-inset-bottom, 0px));
    left: calc(-1 * env(safe-area-inset-left, 0px));
}
html.is-pwa-standalone #app {
    min-height: 100dvh;
    min-height: -webkit-fill-available;
    height: 100dvh;
    height: -webkit-fill-available;
    background: #f3f4f6;
}

.audit-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 0.75rem;
}
.audit-stat {
    background: #fff;
    border: 1px solid var(--ui-line);
    border-radius: var(--radius-lg);
    padding: 1rem 1.1rem;
    box-shadow: var(--shadow-card);
}
.audit-stat strong {
    display: block;
    font-family: 'Outfit', 'Figtree', sans-serif;
    font-size: 1.7rem;
    line-height: 1.1;
    color: var(--ui-ink);
}
.audit-stat span {
    display: block;
    margin-top: 0.25rem;
    color: var(--ui-muted);
    font-size: 0.85rem;
}
.audit-stat--safe { border-left: 4px solid #d97706; }
.audit-stat--review { border-left: 4px solid #dc2626; }
.audit-stat--ok { border-left: 4px solid #16a34a; }
.audit-info-card {
    background: #f8faf5;
    border: 1px solid rgba(109, 124, 78, 0.35);
    border-radius: var(--radius-lg);
    padding: 1.1rem 1.25rem;
}
.audit-info-card h3 {
    margin: 0 0 0.5rem;
    font-family: 'Outfit', 'Figtree', sans-serif;
    font-size: 1.05rem;
    color: var(--brand-brown);
}
.audit-info-card ul {
    margin: 0;
    padding-left: 1.1rem;
    color: #374151;
    font-size: 0.92rem;
    line-height: 1.45;
}
.audit-scan-meta {
    margin: 0.75rem 0 0;
    font-size: 0.8rem;
    color: var(--ui-muted);
}
.audit-section-title {
    margin: 0 0 0.25rem;
    font-family: 'Outfit', 'Figtree', sans-serif;
    font-size: 1.15rem;
    color: var(--ui-ink);
}
.audit-section-lead {
    margin: 0 0 0.85rem;
    color: var(--ui-muted);
    font-size: 0.92rem;
}
.audit-empty {
    background: #ecfdf3;
    color: #166534;
    font-weight: 600;
    padding: 0.85rem 1rem;
    border-radius: var(--radius-md);
}
.audit-block {
    background: #fff;
    border: 1px solid var(--ui-line);
    border-radius: var(--radius-lg);
    padding: 1rem 1.1rem 0.85rem;
    margin-bottom: 0.85rem;
    box-shadow: var(--shadow-card);
}
.audit-block--safe { border-left: 4px solid #d97706; }
.audit-block--review { border-left: 4px solid #dc2626; }
.audit-block--fix { border-left: 4px solid var(--brand-olive); }
.audit-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    margin: 0.85rem 0 0.35rem;
}
.audit-badge {
    display: inline-flex;
    align-items: center;
    width: fit-content;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.01em;
    line-height: 1.3;
}
.audit-badge--lixo { background: #ffedd5; color: #9a3412; }
.audit-badge--conferir { background: #fef3c7; color: #92400e; }
.audit-badge--corrigir { background: #dbeafe; color: #1e40af; }
.audit-block-head h3 {
    margin: 0 0 0.35rem;
    font-family: 'Outfit', 'Figtree', sans-serif;
    font-size: 1.02rem;
    color: var(--ui-ink);
}
.audit-block-head p {
    margin: 0;
    color: var(--ui-muted);
    font-size: 0.88rem;
    line-height: 1.4;
}
.audit-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.6rem;
    padding: 0.1rem 0.45rem;
    margin-left: 0.35rem;
    border-radius: 999px;
    background: #f3f4f6;
    font-size: 0.8rem;
    font-weight: 800;
    color: #374151;
}
.audit-note {
    margin: 0.45rem 0 0 !important;
    color: #b45309 !important;
    font-weight: 600;
}
.audit-block-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    margin: 0.75rem 0 0.6rem;
}
.audit-select-all-wrap {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: #374151;
    margin-right: auto;
}
.audit-item-list {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}
.audit-item {
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
    padding: 0.7rem 0.8rem;
    border: 1px solid var(--ui-line);
    border-radius: 0.7rem;
    cursor: pointer;
}
.audit-item:hover { background: #fafafa; }
.audit-item--readonly { cursor: default; }
.audit-item-body {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    min-width: 0;
    flex: 1;
}
.audit-item-title {
    display: block;
    font-weight: 700;
    color: var(--ui-ink);
    font-size: 0.92rem;
}
.audit-item-meta {
    display: block;
    color: var(--ui-muted);
    font-size: 0.8rem;
    line-height: 1.35;
}
.audit-item-refs {
    display: block;
    margin-top: 0.1rem;
    color: #6b7280;
    font-size: 0.75rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    word-break: break-all;
}

.perm-intro {
    margin: 0 0 0.85rem;
    font-size: 0.88rem;
    color: var(--ui-muted);
    line-height: 1.4;
}
.perm-preset-label {
    margin: 0 0 0.4rem;
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--ui-muted);
}
.perm-preset-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-bottom: 0.9rem;
}
.perm-preset-btn {
    border: 1px solid rgba(109, 124, 78, 0.4);
    background: #f4f7ec;
    color: var(--brand-brown);
    border-radius: 999px;
    padding: 0.35rem 0.75rem;
    font-size: 0.78rem;
    font-weight: 700;
    cursor: pointer;
}
.perm-preset-btn:hover { background: #e7eed8; }
.perm-fields { display: flex; flex-direction: column; gap: 0.7rem; }
.perm-group {
    margin: 0;
    padding: 0.75rem 0.85rem;
    border: 1px solid var(--ui-line);
    border-radius: 0.75rem;
}
.perm-group legend {
    padding: 0 0.35rem;
    font-family: 'Outfit', 'Figtree', sans-serif;
    font-weight: 800;
    font-size: 0.88rem;
    color: var(--ui-ink);
}
.perm-hint {
    margin: 0 0 0.5rem;
    font-size: 0.78rem;
    color: var(--ui-muted);
    line-height: 1.35;
}
.perm-keys { display: flex; flex-direction: column; gap: 0.35rem; }
.perm-check {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    color: #374151;
    cursor: pointer;
}
.admin-chip-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    margin-top: 0.4rem;
}
.admin-chip {
    display: inline-flex;
    padding: 0.12rem 0.45rem;
    border-radius: 999px;
    background: #eef4df;
    color: #3f2a1f;
    font-size: 0.7rem;
    font-weight: 700;
}
.admin-chip--master { background: #d6ef55; }
.admin-chip--empty { background: #f3f4f6; color: #6b7280; }
.admins-row-master {
    background: linear-gradient(90deg, #f4f9d6 0%, #ffffff 58%);
    box-shadow: inset 4px 0 0 #7a9e12;
}
.field-password-wrap {
    position: relative;
    display: block;
}
.field-password-wrap input {
    display: block;
    width: 100%;
    padding-right: 2.75rem;
    box-sizing: border-box;
}
.field-password-wrap input::-ms-reveal,
.field-password-wrap input::-ms-clear {
    display: none;
}
.field-pass-toggle {
    position: absolute;
    right: 0.15rem;
    top: 50%;
    transform: translateY(-50%);
    width: 2.25rem;
    height: 2.25rem;
    border: 0;
    border-radius: 0.4rem;
    background: transparent;
    color: #4b5563;
    cursor: pointer;
    display: grid;
    place-items: center;
    z-index: 2;
    padding: 0;
    touch-action: manipulation;
}
.field-pass-toggle:hover,
.field-pass-toggle:active {
    background: rgba(75, 85, 99, 0.12);
    color: #111827;
}

.master-admin-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0.5rem;
}
.master-admin-actions .btn {
    min-height: 44px;
}
.admin-master-flag {
    display: inline-block;
    margin-left: 0.35rem;
    padding: 0.08rem 0.4rem;
    border-radius: 999px;
    background: #3f2a1f;
    color: #d6ef55;
    font-size: 0.62rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    vertical-align: middle;
}
.admin-pending {
    display: inline-block;
    margin-left: 0.4rem;
    padding: 0.1rem 0.45rem;
    border-radius: 999px;
    background: #fef3c7;
    color: #92400e;
    font-size: 0.68rem;
    font-weight: 800;
    vertical-align: middle;
}

.portal-login-email-hint {
    display: inline;
    color: #dc2626;
    font-weight: 700;
    font-size: 0.7rem;
    margin-left: 0.35rem;
    line-height: 1.35;
}

/* Z-Indexes dos Modais — advertências sempre acima de qualquer caixa */
#genericModal {
    z-index: 10000 !important;
    padding: 1.25rem;
    overflow-y: auto;
    align-items: center;
    justify-content: center;
}
#genericModal > .generic-modal-card,
#genericModal > div {
    position: relative;
    z-index: 1;
    max-height: min(88dvh, 88vh);
    overflow-y: auto;
    width: min(32rem, calc(100% - 1.5rem));
}
#genericModal.cadastro-saved-open {
    padding:
        max(1rem, env(safe-area-inset-top))
        max(0.75rem, env(safe-area-inset-right))
        max(1rem, env(safe-area-inset-bottom))
        max(0.75rem, env(safe-area-inset-left));
}
#genericModal.cadastro-saved-open #genericModalActions {
    justify-content: stretch;
}
#genericModal.cadastro-saved-open #genericModalActions .btn {
    width: 100%;
    min-height: 48px;
}
.app-modal {
    z-index: 50;
}
#extraDatesModal,
#templatePreviewModal {
    z-index: 80;
}
#clientModal, #contractModal, #editionListModal, #editionFormModal, #termEditorModal, #contractTemplateModal, #installmentsPreviewModal, #editionSelectionModal, #paymentModal, #cardActionModal, #editInstallmentModal, #viewContractModal, #viewTermModal, #inviteClientModal, #inviteAttendeeModal, #addAdminModal, #masterAdminModal, #inviteAdminModal, #adminPermissionsModal, #shareLinkModal, #deleteOptionsModal, #lojistaModal, #visitanteModal {
    z-index: 50;
}

/* Overlay global de processamento — acima de todos os modais */
.app-busy-overlay {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.25rem;
    background: rgba(20, 12, 6, 0.48);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
}
.app-busy-overlay.hidden {
    display: none !important;
}
.app-busy-card {
    width: min(22rem, 100%);
    background: #fff;
    border-radius: 1rem;
    padding: 1.35rem 1.4rem 1.2rem;
    text-align: center;
    box-shadow: 0 18px 40px rgba(20, 12, 6, 0.28);
    border: 1px solid rgba(63, 42, 31, 0.08);
}
.app-busy-icon {
    font-size: 1.85rem;
    color: #3f2a1f;
    margin-bottom: 0.7rem;
}
.app-busy-title {
    margin: 0;
    font-family: 'Outfit', sans-serif;
    font-size: 1.05rem;
    font-weight: 700;
    color: #3f2a1f;
}
.app-busy-text {
    margin: 0.35rem 0 0;
    color: #4b5563;
    font-size: 0.92rem;
    line-height: 1.4;
}
body.app-busy {
    overflow: hidden;
}
#toastContainer {
    /* Acima do genericModal (10000): feedback de “Copiar link” etc. precisa aparecer. */
    z-index: 10050;
}

#clientModal,
#lojistaModal,
#visitanteModal,
#contractModal {
    align-items: flex-start;
    padding-top: 1.25rem;
    padding-bottom: 1.25rem;
    overflow-y: auto;
}

.report-builder {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}
.report-field label,
.report-step > label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: #374151;
    margin-bottom: 0.35rem;
}
.report-step {
    position: relative;
    z-index: 1;
}
.report-step.is-open {
    z-index: 2;
}
.report-step-panel {
    margin-top: 0.55rem;
    padding: 0.85rem;
    border: 1px solid #d1d5db;
    border-radius: 0.75rem;
    background: #fff;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
    position: relative;
    z-index: 1;
}
.report-mode-option,
.report-field-option {
    display: flex;
    align-items: stretch;
    gap: 0.65rem;
    padding: 0.7rem 0.75rem;
    border: 1px solid #e5e7eb;
    border-radius: 0.7rem;
    cursor: pointer;
    background: #fff;
}
.report-field-option {
    cursor: default;
    align-items: center;
}
.report-field-option-main {
    display: flex;
    align-items: flex-start;
    gap: 0.65rem;
    flex: 1;
    min-width: 0;
    cursor: pointer;
}
.report-field-reorder {
    display: inline-flex;
    flex-direction: column;
    flex-shrink: 0;
    border: 1px solid #d1d5db;
    border-radius: 0.5rem;
    overflow: hidden;
    background: #f9fafb;
}
.report-field-move {
    width: 2.75rem;
    min-height: 1.75rem;
    display: grid;
    place-items: center;
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
    color: #374151;
    cursor: pointer;
    touch-action: manipulation;
}
.report-field-move + .report-field-move {
    border-top: 1px solid #d1d5db;
}
.report-field-move:disabled {
    opacity: 0.35;
    cursor: default;
}
.report-field-move:focus-visible {
    outline: 2px solid #0d9488;
    outline-offset: -2px;
}
/* Campos dinâmicos (Sistema): mesmas setas laterais dos relatórios */
.dynamic-fields-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}
.field-item {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.55rem 0.65rem;
    border: 1px solid #e5e7eb;
    border-radius: 0.7rem;
    background: #fff;
}
.field-item-input {
    flex: 1 1 auto;
    min-width: 0;
    width: 100%;
    min-height: 44px;
    margin: 0;
    padding: 0.55rem 0.7rem;
    border: 1px solid #d1d5db;
    border-radius: 0.5rem;
    font-size: 0.95rem;
    line-height: 1.3;
    background: #fff;
}
.field-item-input:focus {
    outline: 2px solid #0d9488;
    outline-offset: 1px;
    border-color: #0d9488;
}
.field-item-actions {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    flex-shrink: 0;
}
@media (max-width: 640px) {
    .field-item {
        align-items: stretch;
        gap: 0.5rem;
    }
    .field-item-actions {
        flex-direction: column;
        justify-content: center;
    }
    .field-item .report-field-move {
        width: 2.75rem;
        min-height: 2rem;
    }
    .report-builder .max-w-xl {
        max-width: 100%;
    }
    .report-step-panel {
        max-width: 100%;
        padding: 0.7rem;
    }
    .report-field-option,
    .report-mode-option {
        padding: 0.75rem 0.7rem;
        min-height: 2.75rem;
    }
    .report-field-option-main {
        align-items: center;
    }
    .report-field-move {
        min-height: 2rem;
        width: 2.75rem;
    }
    #chartsFiltersBlock .btn,
    #directoryFiltersBlock .btn,
    #financialFiltersBlock .btn {
        min-height: 2.75rem;
        touch-action: manipulation;
    }
}
.report-mode-option:hover,
.report-field-option:hover {
    border-color: #99f6e4;
    background: #f0fdfa;
}
.report-mode-option:has(input:checked),
.report-field-option:has(input:checked) {
    border-color: #0d9488;
    background: #ccfbf1;
    box-shadow: inset 0 0 0 1px #0d9488;
}
.report-field-option input,
.report-mode-option input {
    width: 1.05rem;
    height: 1.05rem;
    margin-top: 0.1rem;
    flex-shrink: 0;
}

.boleto-scale {
    position: fixed;
    inset: 0;
    z-index: 80;
    display: flex;
    align-items: stretch;
    justify-content: center;
    padding: 0.75rem;
    background: rgba(20, 12, 6, 0.48);
}
.boleto-scale.hidden { display: none !important; }
.boleto-scale__sheet {
    display: flex;
    flex-direction: column;
    width: min(52rem, 100%);
    max-height: 100%;
    margin: auto;
    background: #fff;
    border-radius: 1rem;
    overflow: hidden;
}
.boleto-scale__head,
.boleto-scale__foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
    background: #fff;
    flex-shrink: 0;
}
.boleto-scale__head { border-bottom: 1px solid #e5e7eb; position: relative; z-index: 2; }
.boleto-scale__head-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 0.5rem; }
.boleto-scale__foot {
    justify-content: flex-end;
    position: sticky;
    bottom: 0;
    z-index: 3;
    border-top: 1px solid #e5e7eb;
    box-shadow: 0 -10px 18px rgba(20, 12, 6, 0.12);
}
.boleto-scale__list {
    flex: 1;
    overflow-y: auto;
    padding: 0.25rem 1rem 1rem;
}
.boleto-scale__client {
    margin-top: 0.9rem;
    padding: 0.85rem;
    border: 1px solid #e5e7eb;
    border-radius: 0.85rem;
    background: #fafafa;
}
.boleto-scale__client-head,
.boleto-scale__parcel {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
}
.boleto-scale__client-head { margin-bottom: 0.65rem; }
.boleto-scale__parcel {
    align-items: center;
    flex-wrap: wrap;
    margin-top: 0.45rem;
    padding: 0.55rem 0.65rem;
    border-radius: 0.65rem;
    background: #fff;
}
.boleto-scale__client-head input,
.boleto-scale__parcel input {
    width: 1.25rem;
    height: 1.25rem;
    margin-top: 0.15rem;
    flex-shrink: 0;
}
.boleto-scale__tag {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    padding: 0.15rem 0.45rem;
    border-radius: 999px;
}
.boleto-scale__tag--open { background: #fef3c7; color: #92400e; }
.boleto-scale__tag--late { background: #fee2e2; color: #991b1b; }
.boleto-scale__tag--issued { background: #dcfce7; color: #166534; }

/* Assinatura digital simples do termo (#termo= e portal) */
.term-sign-host {
    position: fixed;
    inset: 0;
    z-index: 90;
    overflow: auto;
    background:
        radial-gradient(ellipse 80% 50% at 20% -10%, rgba(214, 239, 85, 0.28), transparent 55%),
        linear-gradient(165deg, #f4f6ef 0%, #e8ebe1 45%, #dde3d2 100%);
}
.term-sign-host.hidden { display: none !important; }
.term-sign-shell {
    min-height: 100%;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: max(1rem, env(safe-area-inset-top)) 1rem max(2.5rem, calc(1.5rem + env(safe-area-inset-bottom, 0px)));
}
.term-sign-card {
    width: min(40rem, 100%);
    background: #fff;
    border-radius: 1rem;
    padding: 1.25rem 1.2rem 1.4rem;
    box-shadow: 0 18px 40px rgba(20, 12, 6, 0.16);
    border: 1px solid rgba(63, 42, 31, 0.08);
}
.term-sign-brand {
    margin: 0;
    font-family: 'Outfit', sans-serif;
    font-weight: 800;
    font-size: 0.95rem;
    color: #3f2a1f;
    letter-spacing: 0.02em;
}
.term-sign-title {
    margin: 0.35rem 0 0.25rem;
    font-family: 'Outfit', sans-serif;
    font-size: 1.45rem;
    font-weight: 800;
    color: #1f2937;
}
.term-sign-sub {
    margin: 0 0 0.85rem;
    color: #4b5563;
    font-size: 0.95rem;
    line-height: 1.4;
}
.term-sign-pdf-wrap { width: 100%; }
.term-sign-pdf-frame {
    width: 100%;
    max-height: min(48vh, 400px);
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    border: 1px solid #e5e7eb;
    border-radius: 0.65rem;
    background: #f9fafb;
}
.term-sign-pdf {
    display: block;
    width: 100%;
    height: min(46vh, 380px);
    min-height: 220px;
    border: 0;
    background: #f9fafb;
}
.term-sign-pad-wrap {
    border: 1px dashed #9ca3af;
    border-radius: 0.75rem;
    background: #fff;
    overflow: hidden;
    touch-action: none;
}
.term-sign-canvas {
    display: block;
    width: 100%;
    height: 160px;
    touch-action: none;
    cursor: crosshair;
}
.term-sign-inline .term-sign-canvas { height: 150px; }
/* Portal/celular: botão Confirmar visível, fora da safe-area / barra inferior */
.term-sign-inline {
    padding-bottom: calc(4.5rem + env(safe-area-inset-bottom, 0px));
}
.term-sign-submit {
    min-height: 48px;
    margin-top: 0.85rem;
    position: sticky;
    bottom: calc(0.85rem + env(safe-area-inset-bottom, 0px));
    z-index: 6;
    box-shadow: 0 6px 18px rgba(20, 12, 6, 0.18);
}
.term-sign-card .term-sign-submit {
    margin-bottom: 0.25rem;
}

/* Box de links pendentes de novo cadastro (Clientes / Lojistas) */
.pending-invites-box {
    background: #fffbeb;
    border: 1px solid #fcd34d;
    border-radius: 0.75rem;
    padding: 0.85rem 1rem;
    box-shadow: 0 1px 3px rgba(120, 53, 15, 0.06);
}
.pending-invites-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.35rem 0.75rem;
    margin-bottom: 0.65rem;
}
.pending-invites-title-wrap {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.pending-invites-dot {
    width: 0.55rem;
    height: 0.55rem;
    border-radius: 9999px;
    background: #d97706;
    flex-shrink: 0;
}
.pending-invites-title {
    font-size: 0.92rem;
    font-weight: 700;
    color: #78350f;
    margin: 0;
}
.pending-invites-sub {
    font-size: 0.76rem;
    color: #92400e;
}
.pending-invites-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.pending-invite-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.65rem 1rem;
    background: #ffffff;
    border: 1px solid #fde68a;
    border-radius: 0.6rem;
    padding: 0.65rem 0.8rem;
}
.pending-invite-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-width: 0;
    flex: 1 1 240px;
}
.pending-invite-contacts {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem 0.5rem;
    font-size: 0.88rem;
    color: #1f2937;
}
.pending-invite-email {
    font-weight: 600;
    word-break: break-word;
}
.pending-invite-sep {
    color: #9ca3af;
}
.pending-invite-phone {
    color: #374151;
    white-space: nowrap;
}
.pending-invite-dates {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem 0.6rem;
    font-size: 0.76rem;
    color: #6b7280;
}
.pending-invite-exp-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.1rem 0.45rem;
    border-radius: 9999px;
    background: #fef3c7;
    color: #92400e;
    font-weight: 600;
}
.pending-invite-exp-badge--expired {
    background: #fee2e2;
    color: #991b1b;
}
.pending-invite-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.45rem;
    flex-shrink: 0;
}
@media (max-width: 640px) {
    .pending-invites-box {
        padding: 0.75rem;
    }
    .pending-invite-actions {
        width: 100%;
    }
    .pending-invite-actions .btn {
        flex: 1 1 auto;
        justify-content: center;
    }
}



/* Janela de termos: cada edição é um botão colorido pelo estado do termo (lilás / laranja / verde) */
.term-edition-btn {
    display: flex;
    width: 100%;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
    padding: 0.75rem 1rem;
    min-height: 52px;
    text-align: left;
    white-space: normal;
    line-height: 1.25;
}
.term-edition-btn-name {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 0.95rem;
    overflow-wrap: anywhere;
}
.term-edition-btn-status {
    flex: 0 1 auto;
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.5rem;
    font-size: 0.78rem;
    font-weight: 600;
    text-align: right;
    max-width: 55%;
}
@media (max-width: 480px) {
    .term-edition-btn {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.25rem;
    }
    .term-edition-btn-status {
        max-width: 100%;
        justify-content: space-between;
        width: 100%;
        text-align: left;
    }
}

/* ===== Celular e tablet (grupo H) ===== */
.check-option {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    min-height: 2.75rem;
    padding: 0.2rem 0;
    cursor: pointer;
}
.check-option input[type="checkbox"] {
    width: 1.25rem;
    height: 1.25rem;
    flex-shrink: 0;
}
.js-toggle-password {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2.75rem;
    min-height: 2.75rem;
    right: 0 !important;
}
.relative > input.pr-10[type="password"],
.relative > input.pr-10[type="text"] {
    padding-right: 3rem;
}
.touch-hint {
    position: fixed;
    z-index: 100000;
    max-width: min(18rem, calc(100vw - 1rem));
    padding: 0.4rem 0.7rem;
    border-radius: 0.5rem;
    background: #1f2937;
    color: #fff;
    font-size: 0.8rem;
    line-height: 1.2;
    text-align: center;
    pointer-events: none;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25);
}
/* Telas de toque: alvo mínimo de 44px (sem depender de hover) */
@media (pointer: coarse) {
    .btn-sm,
    .directory-page .btn-back,
    .directory-page .page-sticky-head .btn,
    .directory-page-lock .btn {
        min-height: 44px;
    }
    .btn-icon {
        width: 2.75rem;
        height: 2.75rem;
        -webkit-touch-callout: none;
        -webkit-user-select: none;
        user-select: none;
    }
    button[title],
    a[title] {
        -webkit-touch-callout: none;
    }
}

/* Tarja de seleção dos Relatórios: verde quando já há item escolhido (mesmo visual das opções marcadas). */
.report-step .btn-neutral.is-filled,
.report-step .btn-neutral.is-filled:hover {
    color: #134e4a;
    background: #ccfbf1;
    box-shadow: inset 0 0 0 1px #0d9488, 0 4px 10px rgba(13, 148, 136, 0.18);
}

/* Datas e busca dos Relatórios: mesmo verde das tarjas quando há valor preenchido. */
#reportStartDate.is-filled,
#reportEndDate.is-filled,
#directorySearchInput.is-filled {
    color: #134e4a;
    background-color: #ccfbf1;
    border-color: #0d9488;
    box-shadow: 0 0 0 1px #0d9488 inset;
}

/* Cabeçalho de listas (Lojistas/Visitantes): "Novo" e "Enviar cadastro" lado a lado também no celular. */
.directory-head-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}
@media (max-width: 1024px) {
    .directory-page .directory-head-actions {
        width: 100%;
        flex-wrap: nowrap;
        gap: 0.4rem;
    }
    .directory-page .directory-head-actions .btn {
        flex: 1 1 0;
        min-width: 0;
        padding: 0.3rem 0.4rem;
        font-size: 0.72rem;
        line-height: 1.15;
        text-align: center;
        white-space: normal;
    }
}

/* iPhone/iPad: campos com fonte menor que 16 px dão zoom automático ao tocar. */
@media (pointer: coarse) {
    input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]):not([type="color"]):not([type="hidden"]),
    select,
    textarea {
        font-size: 16px;
    }
}
