html {
    min-height: 100%;
    background: var(--bg-main);
}

body {
    min-height: 100dvh;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

body.is-navigating::after {
    content: "";
    position: fixed;
    inset: 0 auto auto 0;
    z-index: 9999;
    width: 42vw;
    height: 3px;
    border-radius: 0 999px 999px 0;
    background: var(--gradient-primary);
    box-shadow: var(--glow-primary);
    animation: marcai-pwa-progress 1.1s ease-in-out infinite;
}

form.is-submitting button[type="submit"] {
    opacity: .72;
    pointer-events: none;
}

.is-offline-blocked {
    position: relative;
    opacity: .76;
}

form.is-offline-blocked,
.is-offline-blocked.card,
.is-offline-blocked.section {
    outline: 2px solid rgba(245, 158, 11, .36);
    outline-offset: 3px;
}

.pwa-action-button {
    position: fixed;
    right: max(16px, env(safe-area-inset-right));
    bottom: max(18px, env(safe-area-inset-bottom));
    z-index: 9997;
    display: none;
    align-items: center;
    gap: 8px;
    min-height: 44px;
    padding: 9px 12px 9px 9px;
    border: 1px solid rgba(255, 255, 255, .16);
    border-radius: var(--radius-full);
    color: #fff;
    background: linear-gradient(135deg, rgba(109, 61, 245, .96), rgba(255, 77, 141, .94));
    box-shadow: 0 18px 42px rgba(79, 29, 255, .26);
    cursor: pointer;
}

.pwa-action-button span {
    display: grid;
    min-width: 28px;
    height: 28px;
    place-items: center;
    border-radius: var(--radius-full);
    background: rgba(255, 255, 255, .18);
    padding: 0 6px;
    font-size: 11px;
    font-weight: 950;
    line-height: 1;
}

.pwa-action-button strong {
    font-size: 13px;
    font-weight: 950;
}

html:not(.is-pwa-standalone) .pwa-action-button,
.pwa-action-button#marcai-pwa-update {
    display: inline-flex;
}

.is-offline .pwa-action-button {
    bottom: max(62px, calc(env(safe-area-inset-bottom) + 62px));
}

.is-pwa-standalone body {
    overscroll-behavior-y: contain;
    user-select: none;
}

.is-pwa-standalone input,
.is-pwa-standalone textarea,
.is-pwa-standalone [contenteditable="true"] {
    user-select: text;
}

.is-pwa-standalone .app-shell {
    min-height: 100dvh;
}

.is-pwa-standalone .topbar,
.is-pwa-standalone .sidebar {
    padding-top: max(18px, env(safe-area-inset-top));
}

.is-pwa-standalone .content,
.is-pwa-standalone .portal-shell,
.is-pwa-standalone .auth-shell {
    padding-bottom: max(34px, env(safe-area-inset-bottom));
}

.is-pwa-standalone .topbar {
    min-height: calc(76px + env(safe-area-inset-top));
}

.is-offline::before {
    content: "Sem conexao";
    position: fixed;
    right: max(14px, env(safe-area-inset-right));
    bottom: max(14px, env(safe-area-inset-bottom));
    z-index: 9998;
    display: inline-flex;
    align-items: center;
    min-height: 34px;
    padding: 8px 12px;
    border: 1px solid rgba(245, 158, 11, .28);
    border-radius: var(--radius-full);
    background: rgba(17, 24, 39, .9);
    color: #fff;
    font-size: 12px;
    font-weight: 900;
    box-shadow: var(--shadow-lg);
    backdrop-filter: blur(14px);
}

.offline-shell {
    display: grid;
    min-height: 100dvh;
    place-items: center;
    padding: max(24px, env(safe-area-inset-top)) 18px max(24px, env(safe-area-inset-bottom));
    background:
        radial-gradient(circle at 22% 10%, rgba(109, 61, 245, .24), transparent 30%),
        radial-gradient(circle at 82% 78%, rgba(255, 77, 141, .2), transparent 32%),
        #0B1020;
}

.offline-card {
    display: grid;
    width: min(100%, 460px);
    gap: 14px;
    justify-items: start;
    padding: 24px;
    border: 1px solid rgba(255, 255, 255, .14);
    border-radius: 22px;
    background: rgba(255, 255, 255, .94);
    box-shadow: 0 24px 70px rgba(0, 0, 0, .28);
}

.offline-card img {
    height: 42px;
    width: auto;
}

.offline-card span {
    color: var(--accent-pink);
    font-size: 12px;
    font-weight: 950;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.offline-card h1 {
    margin: 0;
    font-size: clamp(34px, 9vw, 54px);
    line-height: 1;
}

.offline-card p {
    margin: 0 0 8px;
    color: var(--text-secondary);
    line-height: 1.6;
    font-weight: 750;
}

.pwa-browser-check {
    display: grid;
    gap: 14px;
    align-items: start;
}

.pwa-install-sheet[hidden] {
    display: none;
}

.pwa-install-sheet {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: grid;
    place-items: end center;
    padding: 16px;
}

.pwa-install-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(11, 16, 32, .54);
    backdrop-filter: blur(6px);
}

.pwa-install-panel {
    position: relative;
    z-index: 1;
    display: grid;
    width: min(100%, 440px);
    gap: 12px;
    padding: 22px;
    border: 1px solid rgba(255, 255, 255, .22);
    border-radius: 24px;
    background: rgba(255, 255, 255, .96);
    box-shadow: 0 24px 74px rgba(15, 23, 42, .28);
}

.pwa-install-close {
    position: absolute;
    top: 12px;
    right: 12px;
    display: grid;
    width: 34px;
    height: 34px;
    place-items: center;
    border: 0;
    border-radius: var(--radius-full);
    color: var(--text-secondary);
    background: var(--bg-secondary);
    cursor: pointer;
    font-weight: 950;
}

.pwa-install-panel img {
    width: auto;
    height: 38px;
}

.pwa-install-panel > span {
    width: fit-content;
    color: var(--accent-pink);
    font-size: 12px;
    font-weight: 950;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.pwa-install-panel h2 {
    margin: 0;
    padding-right: 28px;
    font-size: clamp(28px, 8vw, 40px);
    line-height: 1.04;
}

.pwa-install-panel p {
    margin: 0;
    color: var(--text-secondary);
    line-height: 1.55;
    font-weight: 750;
}

.pwa-install-panel ol {
    display: grid;
    gap: 9px;
    margin: 4px 0;
    padding-left: 22px;
}

.pwa-install-panel li {
    color: var(--text-primary);
    font-weight: 850;
    line-height: 1.35;
}

.pwa-tabbar {
    position: fixed;
    right: 10px;
    bottom: max(10px, env(safe-area-inset-bottom));
    left: 10px;
    z-index: 120;
    display: none;
    grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
    gap: 4px;
    min-height: 62px;
    padding: 8px;
    border: 1px solid var(--ops-line, rgba(15, 23, 42, .08));
    border-radius: 18px;
    background: rgba(255, 255, 255, .94);
    box-shadow: 0 14px 34px rgba(18, 24, 38, .14);
    backdrop-filter: blur(18px);
}

.pwa-tabbar a {
    position: relative;
    display: grid;
    min-width: 0;
    min-height: 46px;
    place-items: center;
    align-content: center;
    gap: 3px;
    border-radius: 14px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 11px;
    font-weight: 900;
    line-height: 1.05;
}

.pwa-tabbar a:hover,
.pwa-tabbar a.is-active {
    color: var(--primary);
    background: var(--purple-extra-light, color-mix(in srgb, var(--primary) 10%, #fff));
}

.pwa-tabbar a.is-alert:not(.is-active) {
    color: var(--accent-pink);
}

.pwa-tabbar i {
    width: 20px;
    height: 20px;
}

.pwa-tabbar span {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pwa-tabbar-badge {
    position: absolute;
    top: 5px;
    right: 12px;
    display: inline-grid;
    min-width: 17px;
    height: 17px;
    padding: 0 5px;
    place-items: center;
    border-radius: 999px;
    background: var(--accent-pink);
    color: #fff;
    font-size: 10px;
    font-weight: 950;
    line-height: 1;
}

@media (display-mode: standalone) {
    a[target="_blank"] {
        touch-action: manipulation;
    }
}

@media (max-width: 640px) {
    .pwa-action-button {
        right: max(12px, env(safe-area-inset-right));
    }

    .app-body .pwa-tabbar {
        display: grid;
    }

    .app-body .content {
        padding-bottom: max(104px, calc(env(safe-area-inset-bottom) + 104px));
    }

    .app-body .pwa-action-button {
        bottom: max(88px, calc(env(safe-area-inset-bottom) + 88px));
    }

    .app-body.is-offline::before {
        bottom: max(88px, calc(env(safe-area-inset-bottom) + 88px));
    }

    .app-body.is-offline .pwa-action-button {
        bottom: max(132px, calc(env(safe-area-inset-bottom) + 132px));
    }

    .is-pwa-standalone .topbar {
        margin-top: max(8px, env(safe-area-inset-top));
    }

    .is-pwa-standalone .content {
        width: 100%;
    }

    .offline-card {
        border-radius: 18px;
    }

    .pwa-install-sheet {
        padding: 10px;
        padding-bottom: max(10px, env(safe-area-inset-bottom));
    }

    .pwa-install-panel {
        border-radius: 22px;
    }
}

@keyframes marcai-pwa-progress {
    0% {
        transform: translateX(-44vw);
    }

    55% {
        transform: translateX(70vw);
    }

    100% {
        transform: translateX(100vw);
    }
}
