html, body {
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
}

/* ── Splash de arranque ───────────────────────────────────────────────────────
   Único HTML visível enquanto o circuito Blazor Server não liga (prerender:false).
   Removido por finlam.hideSplash(), chamado no primeiro render de cada layout. */
/* Mesmo fundo e mesmo vidro do login (AuthenticationLayout) para a transição
   splash → login ser contínua. O vermelho fica como cor de reserva até a imagem chegar. */
#app-splash {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: #F3123C url('/images/login-bg-desktop.webp') center / cover no-repeat;
    transition: opacity 0.3s ease-out;
    /* Rede de segurança só-CSS: se o circuito nunca ligar e hideSplash() não for
       chamado, o splash sai sozinho em vez de trancar o ecrã. */
    animation: app-splash-failsafe 0.3s linear 15s forwards;
}

#app-splash::before {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(245, 247, 250, 0.12);
}

@keyframes app-splash-failsafe {
    to { opacity: 0; visibility: hidden; pointer-events: none; }
}

.app-splash-card {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 26px;
    padding: 42px 56px;
    border-radius: 15px;
    background: rgba(255, 255, 255, 0.55);
    border: 1px solid rgba(255, 255, 255, 0.65);
    box-shadow: 0 18px 50px rgba(8, 40, 80, .18), inset 0 1px 0 rgba(255, 255, 255, .8);
    backdrop-filter: blur(22px) saturate(170%);
    -webkit-backdrop-filter: blur(22px) saturate(170%);
}

#app-splash img {
    width: 96px;
    height: 96px;
    filter: drop-shadow(0 8px 24px rgba(243, 18, 60, 0.22));
}

.app-splash-bar {
    position: relative;
    width: 168px;
    height: 3px;
    border-radius: 2px;
    overflow: hidden;
    background: rgba(0, 0, 0, 0.12);
}

.app-splash-bar::after {
    content: '';
    position: absolute;
    inset: 0;
    width: 40%;
    border-radius: 2px;
    background: #F3123C;
    animation: app-splash-slide 1.1s ease-in-out infinite;
}

/* Retrato: imagem vertical com o avião no topo e o cartão em baixo, como no login. */
@media (max-width: 768px) {
    #app-splash {
        background-image: url('/images/login-bg-mobile.webp');
        background-position: center top;
        align-items: flex-end;
        padding: 16px;
    }

    .app-splash-card {
        width: 100%;
        max-width: 430px;
        padding: 34px 24px;
        border-radius: 18px;
    }
}

/* Sem variante escura de propósito: o modo Auto do login decide pela hora, que o CSS
   não conhece — seguir prefers-color-scheme aqui daria um salto escuro→claro de dia. */

@keyframes app-splash-slide {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(250%); }
}

#app-splash.hidden {
    opacity: 0;
    pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
    .app-splash-bar::after { animation: none; width: 100%; }
    .appbar-logo { animation: none; }
}

/* ---- Layout / app bar ---- */
.finlam-main { padding: 6rem 2rem !important; }

.appbar-logo {
    height: 22px;
    cursor: pointer;
    animation: appbar-logo-float 4s ease-in-out infinite;
}

@keyframes appbar-logo-float {
    50% { transform: translateY(-2px); }
}

/* ---- KPI tile das listagens (Comercial: Venda, Factura, Recibo, Antecipado, Caixa; Financeiro: Documento, Aviso/Nota, Fornecedor) ----
   Compacto em qualquer ecrã: ícone à esquerda, label sobre o valor.
   O markup é plano (ícone, label, valor) — a grelha empilha texto sem wrapper. */
.kpi-tile {
    display: grid;
    grid-template-columns: auto 1fr;
    column-gap: .6rem;
    align-items: center;
    padding: .5rem .75rem;
    border: 1px solid var(--mud-palette-lines-default);
    border-radius: 12px;
    height: 100%;
}

.kpi-tile .kpi-icon {
    grid-row: span 3; /* 3.ª linha opcional: hint (caption) */
    width: 32px;
    height: 32px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.kpi-tile .mud-typography-overline { line-height: 1.2; }
.kpi-tile .mud-typography-h6 { font-size: 1.05rem; line-height: 1.2; }
.kpi-tile .mud-typography-caption { line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---- Escolha entre poucas opções ----
   Substitui MudSelect quando há 2-3 hipóteses fixas: no telemóvel o select abre
   o teclado e a lista fica tapada. Botões resolvem e mostram tudo de uma vez. */
.opt-toggle { display: flex; flex-direction: column; gap: .25rem; justify-content: center; }
.opt-toggle__row { display: flex; gap: .4rem; }

.opt-toggle__btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    padding: .45rem .7rem;
    border: 1px solid var(--mud-palette-lines-default);
    border-radius: 10px;
    cursor: pointer;
    font-size: .85rem;
    font-weight: 600;
    white-space: nowrap;
    transition: border-color .15s ease, background .15s ease;
}

.opt-toggle__btn:hover { border-color: var(--mud-palette-primary); }

.opt-toggle__btn--sel {
    border-color: var(--mud-palette-primary);
    background: rgba(243,18,60,.08);
    color: var(--mud-palette-primary);
}

.opt-toggle__btn--off { opacity: .45; pointer-events: none; }

@media (max-width: 599.98px) {
    .finlam-main { padding: 5rem .75rem 1.25rem !important; }

    .appbar-logo { height: 18px; }

    /* Botão do escritório: só o código (MPMKK), sem ícones. */
    .appbar-office .mud-button-icon-start,
    .appbar-office .mud-button-icon-end { display: none; }
    .appbar-office { padding: 6px 8px; min-width: 0; }

    /* Menu do utilizador: só o ícone de conta (nome e seta escondidos). */
    .appbar-user-btn .mud-button-root { font-size: 0; padding: 6px 8px; min-width: 0; }
    .appbar-user-btn .mud-button-icon-end { display: none; }
    .appbar-user-btn .mud-button-icon-start { margin: 0; }

    /* Menus/popovers nunca saem do ecrã; o do utilizador encosta à direita. */
    .mud-popover { max-width: calc(100vw - 16px); }
    .appbar-user-pop { left: auto !important; right: 8px !important; }

    /* Grelhas MudGrid compactas em toda a app: gutters -> 12px (spacing 3 e o default 6). */
    .mud-grid.mud-grid-spacing-xs-3, .mud-grid.mud-grid-spacing-xs-6 {
        width: calc(100% + 12px); margin-left: -6px; margin-top: -6px;
    }
    .mud-grid.mud-grid-spacing-xs-3 > .mud-grid-item,
    .mud-grid.mud-grid-spacing-xs-6 > .mud-grid-item { padding-left: 6px; padding-top: 6px; }

    /* Painéis de filtros das listagens (vd-filtros, fa-filtros, …): 2 colunas compactas,
       tabs de âmbito e pesquisa a toda a largura. */
    .mud-paper[class*="-filtros"] { padding: .6rem; gap: .5rem; }
    .mud-paper[class*="-filtros"] > * { flex: 1 1 calc(50% - .25rem); width: auto; min-width: 0; }
    .mud-paper[class*="-filtros"] > [role="tablist"] { flex: 1 1 100%; }
    .mud-paper[class*="-filtros"] > [role="tablist"] > * { flex: 1; text-align: center; }
    .mud-paper[class*="-filtros"] [class*="__search"],
    .mud-paper[class*="-filtros"] > .opt-toggle { flex: 1 1 100%; }

    /* KPI tiles ainda mais baixos no telemóvel. */
    .kpi-tile { padding: .4rem .55rem; column-gap: .45rem; }
    .kpi-tile .kpi-icon { width: 28px; height: 28px; }
    .kpi-tile .mud-typography-h6 { font-size: .95rem; }
    .kpi-tile .mud-typography-caption { display: none; }

    /* Tabelas empilhadas (Breakpoint.Sm) compactas. */
    .mud-table-dense .mud-table-cell { padding: 5px 10px; font-size: .8rem; }

    /* Diálogos Small/Medium/Large ocupam o ecrã inteiro (mobile first);
       ExtraSmall (confirmações) continua flutuante. */
    .mud-dialog-width-sm, .mud-dialog-width-md, .mud-dialog-width-lg, .mud-dialog-width-xl {
        width: 100vw !important; max-width: 100vw !important;
        height: 100dvh; max-height: 100dvh !important;
        margin: 0; border-radius: 0;
    }
    .mud-dialog-width-sm .mud-dialog-content, .mud-dialog-width-md .mud-dialog-content,
    .mud-dialog-width-lg .mud-dialog-content, .mud-dialog-width-xl .mud-dialog-content {
        flex: 1 1 auto; max-height: none;
    }
}

a, .btn-link {
    color: #006bb7;
}

.btn-primary {
    color: #fff;
    background-color: #1b6ec2;
    border-color: #1861ac;
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
  box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
}

.content {
    padding-top: 1.1rem;
}

h1:focus {
    outline: none;
}

.valid.modified:not([type=checkbox]) {
    outline: 1px solid #26b050;
}

.invalid {
    outline: 1px solid #e50000;
}

.validation-message {
    color: #e50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jMzNyAyNTkuMzEzIDY5LjYxMDIgMjU5LjMzMiA2OS44NjA4IDI1OS4zNzEgNzAuMDg4N0wyNjEuNzk1IDg0LjAxNjEgMjY1LjM4IDg0LjAxNjEgMjY3LjgyMSA2OS43NDc1QzI2Ny44NiA2OS43MzA5IDI2Ny44NzkgNjkuNTg3NyAyNjcuODc5IDY5LjMxNzkgMjY3Ljg3OSA2Ny4xMTgyIDI2Ni40NDggNjYuMDE4MyAyNjMuNTg2IDY2LjAxODNaTTI2My41NzYgODYuMDU0N0MyNjEuMDQ5IDg2LjA1NDcgMjU5Ljc4NiA4Ny4zMDA1IDI1OS43ODYgODkuNzkyMSAyNTkuNzg2IDkyLjI4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #b32121;
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
}

    .blazor-error-boundary::after {
        content: "An error has occurred."
    }

.darker-border-checkbox.form-check-input {
    border-color: #929292;
}

.form-floating > .form-control-plaintext::placeholder, .form-floating > .form-control::placeholder {
    color: var(--bs-secondary-color);
    text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder, .form-floating > .form-control:focus::placeholder {
    text-align: start;
}

/* ===========================================================================
   Modal de reconexão (Blazor Server) — branding LAM.
   Global (não scoped) para garantir que aplica ao <dialog> gerido pelo runtime.
   =========================================================================== */

.components-reconnect-first-attempt-visible,
.components-reconnect-repeated-attempt-visible,
.components-reconnect-failed-visible,
.components-pause-visible,
.components-resume-failed-visible,
.components-rejoining-animation {
    display: none;
}

#components-reconnect-modal.components-reconnect-show .components-reconnect-first-attempt-visible,
#components-reconnect-modal.components-reconnect-show .components-rejoining-animation,
#components-reconnect-modal.components-reconnect-paused .components-pause-visible,
#components-reconnect-modal.components-reconnect-resume-failed .components-resume-failed-visible,
#components-reconnect-modal.components-reconnect-retrying .components-reconnect-repeated-attempt-visible,
#components-reconnect-modal.components-reconnect-retrying .components-rejoining-animation,
#components-reconnect-modal.components-reconnect-failed .components-reconnect-failed-visible {
    display: block;
}

#components-reconnect-modal {
    position: fixed;
    inset: 0;
    max-width: 22rem;
    width: calc(100% - 2rem);
    margin: auto;
    padding: 2rem 2.25rem;
    border: 0;
    border-top: 4px solid #F3123C;
    border-radius: 0.75rem;
    /* Segue a paleta MudBlazor activa (claro/escuro); fallback para pré-render. */
    background-color: var(--mud-palette-surface, #ffffff);
    color: var(--mud-palette-text-primary, #1a1a1a);
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.28);
    opacity: 0;
    transition: display 0.4s allow-discrete, overlay 0.4s allow-discrete;
    animation: components-reconnect-modal-fadeOutOpacity 0.4s both;
}

#components-reconnect-modal[open] {
    animation: components-reconnect-modal-slideUp 0.9s cubic-bezier(.05, .89, .25, 1.02),
               components-reconnect-modal-fadeInOpacity 0.4s ease-in-out;
    animation-fill-mode: both;
}

#components-reconnect-modal::backdrop {
    background-color: rgba(20, 20, 20, 0.55);
    backdrop-filter: blur(2px);
    animation: components-reconnect-modal-fadeInOpacity 0.4s ease-in-out;
}

.components-reconnect-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.1rem;
    text-align: center;
}

.components-reconnect-brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    line-height: 1;
}

.components-reconnect-brand__logo {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: block;
}

.components-reconnect-brand__sub {
    margin-top: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.18em;
    color: var(--mud-palette-text-secondary, #8a8a8a);
}

#components-reconnect-modal p {
    margin: 0;
    font-size: 0.95rem;
    line-height: 1.45;
    color: var(--mud-palette-text-primary, #333);
}

#components-reconnect-modal button {
    border: 0;
    background-color: #F3123C;
    color: #fff;
    font-weight: 600;
    font-size: 0.9rem;
    padding: 0.55rem 1.6rem;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

#components-reconnect-modal button:hover {
    background-color: #c40e30;
}

#components-reconnect-modal button:active {
    background-color: #a50b28;
}

@keyframes components-reconnect-modal-slideUp {
    0% { transform: translateY(24px) scale(0.97); }
    100% { transform: translateY(0) scale(1); }
}

@keyframes components-reconnect-modal-fadeInOpacity {
    0% { opacity: 0; }
    100% { opacity: 1; }
}

@keyframes components-reconnect-modal-fadeOutOpacity {
    0% { opacity: 1; }
    100% { opacity: 0; }
}

.components-rejoining-animation {
    position: relative;
    width: 64px;
    height: 64px;
}

.components-rejoining-animation div {
    position: absolute;
    border: 3px solid #F3123C;
    opacity: 1;
    border-radius: 50%;
    animation: components-rejoining-animation 1.5s cubic-bezier(0, 0.2, 0.8, 1) infinite;
}

.components-rejoining-animation div:nth-child(2) {
    animation-delay: -0.5s;
}

@keyframes components-rejoining-animation {
    0%   { top: 32px; left: 32px; width: 0; height: 0; opacity: 0; }
    4.9% { top: 32px; left: 32px; width: 0; height: 0; opacity: 0; }
    5%   { top: 32px; left: 32px; width: 0; height: 0; opacity: 1; }
    100% { top: 0; left: 0; width: 64px; height: 64px; opacity: 0; }
}

/* ===========================================================================
   NavMenu — bloco de marca / módulo. Global (não scoped) para garantir
   alinhamento em linha; o CSS isolado não estava a aplicar no runtime.
   =========================================================================== */

.finlam-nav-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.85rem 0.9rem;
    margin: 0.6rem 0.6rem 0.4rem 0.6rem;
    border-radius: 12px;
    cursor: pointer;
    transition: background .15s ease;
}

.finlam-nav-brand:hover {
    background: rgba(243, 18, 60, 0.06);
}

.finlam-nav-brand__icon {
    width: 44px;
    height: 44px;
    min-width: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(243, 18, 60, 0.10);
    color: var(--mud-palette-primary);
}

.finlam-nav-brand__text {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.finlam-nav-brand__name {
    font-weight: 700;
    color: var(--mud-palette-text-primary);
    margin: 0;
}

.finlam-nav-brand__sub {
    opacity: 0.5;
    letter-spacing: .04em;
    margin: 0;
}

.finlam-nav-brand__chevron {
    opacity: 0.35;
    flex-shrink: 0;
}

.finlam-nav-section {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: var(--mud-palette-text-secondary);
    opacity: 0.6;
    padding: 0.4rem 1.1rem 0.3rem 1.1rem;
    margin-top: 0.6rem;
}

.finlam-navmenu {
    padding: 0.25rem 0.5rem 1.25rem 0.5rem;
}

.finlam-navmenu .mud-nav-link {
    min-height: 42px;
    padding-top: 0.45rem;
    padding-bottom: 0.45rem;
}

.finlam-navmenu .mud-nav-group > button {
    min-height: 42px;
}

.finlam-nav-empty {
    padding: 0.5rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
/* ---- Banner de diálogos ----------------------------------------------
   Todos os diálogos levam a banda da marca no título, sem tocar no markup
   de cada um: o TitleContent existente (ícone + texto + chip) herda as
   cores daqui. Dialogs sem TitleContent usam o título do ShowAsync e ficam
   igualmente com a banda. */
/* O título já traz border-top-*-radius do MudBlazor: a banda respeita os
   cantos sem precisar de overflow no contentor. */
.mud-dialog .mud-dialog-title {
    background: linear-gradient(135deg, #F3123C 0%, #B20E2D 100%);
    color: #fff;
    padding: 14px 20px;
    margin-bottom: 0;
}

/* Ícones do título (Color.Primary/Error nos componentes) e botões de acção
   — incluindo o X de fechar — passam a branco sobre a banda. O !important é
   obrigatório: as classes de cor do MudBlazor (.mud-primary-text e irmãs) já
   o usam, e um ícone Primary sobre a banda vermelha ficava invisível. */
.mud-dialog .mud-dialog-title .mud-icon-root { color: #fff !important; }
.mud-dialog .mud-dialog-title .mud-icon-button { color: rgba(255,255,255,.9) !important; }
.mud-dialog .mud-dialog-title .mud-typography-caption,
.mud-dialog .mud-dialog-title .mud-secondary-text { color: rgba(255,255,255,.82) !important; }

/* Chips de estado: pill branco, texto e ícone escuros — as cores normais
   (warning/info) não contrastam sobre branco nem sobre a banda. As cores são
   hex fixos e não variáveis da palete: o pill é claro nos dois temas, e em dark
   as variáveis clareiam (--mud-palette-text-primary fica quase branco, o que
   apagava por completo o chip Default, ex. "EM ABERTO"). */
.mud-dialog .mud-dialog-title .mud-chip { background: rgba(255,255,255,.92) !important; }
.mud-dialog .mud-dialog-title .mud-chip .mud-icon-root { color: inherit !important; }
.mud-dialog .mud-dialog-title .mud-chip.mud-chip-color-warning { color: #c77700 !important; }
.mud-dialog .mud-dialog-title .mud-chip.mud-chip-color-success { color: #0a8f3c !important; }
.mud-dialog .mud-dialog-title .mud-chip.mud-chip-color-info { color: #0b79d0 !important; }
.mud-dialog .mud-dialog-title .mud-chip.mud-chip-color-error { color: #b00020 !important; }
.mud-dialog .mud-dialog-title .mud-chip.mud-chip-color-primary { color: #B20E2D !important; }
.mud-dialog .mud-dialog-title .mud-chip.mud-chip-color-default { color: #37474F !important; }

/* Sino: notificações por ler (MainLayout). */
.sino-lista { max-width: 360px; max-height: 70vh; overflow-y: auto; }
.sino-item { display: flex; flex-direction: column; gap: 2px; white-space: normal; line-height: 1.3; }
.sino-item span { font-size: .8rem; color: var(--mud-palette-text-secondary); }
.sino-item small { font-size: .7rem; color: var(--mud-palette-text-disabled); }

/* MudBlazor 9.5 copia o Style do MudDatePicker/MudTimePicker (ex.: max-width:170px, width:160px)
   para o papel do calendário e corta-o. O calendário fica com a largura própria. */
.mud-picker-popover-paper { width: auto !important; max-width: none !important; }
