html, body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background: #F6F7F9;
    -webkit-tap-highlight-color: transparent;
    overscroll-behavior-y: none;
}

/* Ecrã de arranque (antes do Blazor montar) */
.app-loading {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 18px;
    background: #F5F5F5;
    color: #6D6D6D;
    font-size: 14px;
}
.app-loading img { width: 200px; height: auto; }
.app-loading-bar {
    width: 140px; height: 4px; border-radius: 4px;
    background: linear-gradient(90deg, #F3123C 0%, #f3123c55 50%, #F3123C 100%);
    background-size: 200% 100%;
    animation: app-loading-slide 1.1s ease-in-out infinite;
}
@keyframes app-loading-slide {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

#blazor-error-ui {
    background: #ffe9ec;
    color: #b3092a;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    display: none;
    left: 0;
    padding: 0.8rem 1.2rem;
    position: fixed;
    width: 100%;
    z-index: 10000;
}
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 1rem; top: 0.6rem; }

/* ---- App shell (internet banking, mobile-first) ---- */
:root {
    --lam-red: #F3123C;
    --bottom-nav-h: 62px;
}

/* O conteúdo deixa espaço para a bottom nav no mobile + safe area */
.portal-content {
    padding: 16px 16px calc(var(--bottom-nav-h) + env(safe-area-inset-bottom) + 16px) 16px;
    max-width: 760px;
    margin: 0 auto;
    width: 100%;
    box-sizing: border-box;
    animation: page-in .25s ease-out;
}
@keyframes page-in {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
    .portal-content { animation: none; }
}

/* Cartões: contorno subtil + elevação suave no hover (desktop) */
.portal-content .mud-paper {
    border: 1px solid rgba(0,0,0,0.05);
    transition: box-shadow .18s ease, transform .18s ease;
}
@media (hover: hover) {
    .portal-content .mud-paper:hover {
        box-shadow: 0 6px 18px rgba(0,0,0,0.07);
        transform: translateY(-1px);
    }
}

/* Navegação secundária (tabs) — só desktop; mobile usa a bottom nav */
.top-nav { display: none; }

/* Barra de filtros (Facturas/Pagamentos) — mobile-first, quebra em linhas */
.filter-bar { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: flex-end; }
.filter-bar .flt-search { flex: 1 1 100%; }
.filter-bar .flt-select { flex: 1 1 140px; }

/* Realce lateral por estado nos cartões */
.status-accent { border-left: 4px solid var(--accent, #e0e0e0); }

/* Bottom navigation — só mobile */
.bottom-nav {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    height: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: #fff;
    border-top: 1px solid rgba(0,0,0,0.08);
    box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
    display: flex;
    justify-content: space-around;
    align-items: stretch;
    z-index: 1200;
}
.bottom-nav a {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-height: 44px;
    text-decoration: none;
    color: #9E9E9E;
    font-size: 11px;
    font-weight: 500;
    transition: color .15s ease;
}
.bottom-nav a.active { color: var(--lam-red); }
.bottom-nav a .mud-icon-root { font-size: 24px; }

/* Cartão estilo banking */
.balance-card {
    position: relative;
    overflow: hidden;
    background: linear-gradient(135deg, #F3123C 0%, #c50e31 100%);
    color: #fff;
    border-radius: 16px;
    padding: 22px 20px;
    box-shadow: 0 8px 20px rgba(243,18,60,0.25);
}
/* Brilho decorativo no canto do cartão */
.balance-card::after {
    content: "";
    position: absolute;
    top: -60px; right: -60px;
    width: 180px; height: 180px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255,255,255,0.18) 0%, rgba(255,255,255,0) 70%);
    pointer-events: none;
}
.balance-card .label { opacity: .85; font-size: 12px; text-transform: uppercase; letter-spacing: .5px; }
.balance-card .value { font-size: 30px; font-weight: 700; margin-top: 4px; letter-spacing: -.5px; }

/* Bottom nav com desfoque (estilo app nativa) */
.bottom-nav {
    background: rgba(255,255,255,0.92);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
}

/* Desktop: esconde bottom nav, dá largura (960px = breakpoint Md do MudBlazor) */
@media (min-width: 960px) {
    .bottom-nav { display: none; }
    .portal-content { padding: 24px 32px; max-width: 1120px; }

    /* Listas em grelha de 2 colunas no desktop */
    .list-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: start; }
    .list-grid > .mud-paper { margin-bottom: 0 !important; } /* anula mb-2 no desktop */

    /* Tabs de navegação, fixas por baixo do appbar */
    .top-nav {
        display: block;
        position: sticky;
        top: var(--mud-appbar-height, 48px);
        z-index: 20;
        background: rgba(255,255,255,0.88);
        -webkit-backdrop-filter: blur(12px);
        backdrop-filter: blur(12px);
        border-bottom: 1px solid rgba(0,0,0,0.06);
    }
    .top-nav-inner {
        max-width: 1120px;
        margin: 0 auto;
        padding: 0 32px;
        display: flex;
        align-items: center;
        gap: 24px;
    }
    .top-nav-inner a {
        padding: 13px 2px 11px;
        text-decoration: none;
        color: #616161;
        font-size: 14px;
        font-weight: 500;
        border-bottom: 2px solid transparent;
        transition: color .15s ease, border-color .15s ease;
    }
    .top-nav-inner a:hover { color: #212121; }
    .top-nav-inner a.active {
        color: var(--lam-red);
        border-bottom-color: var(--lam-red);
        font-weight: 600;
    }
    .top-nav-cta { margin-left: auto; }

    .filter-bar .flt-search { flex: 2 1 260px; }
    .filter-bar .flt-select { flex: 0 1 180px; }

    /* Elementos que só fazem sentido no mobile (ex.: CTA duplicado do TopNav) */
    .only-mobile { display: none !important; }
}
