/* =====================================================================
   Portal do Fornecedor — identidade "área de trabalho" (azul-marinho; o vermelho LAM
   fica só no logo e na acção principal).
   ponytail: o portal do cliente tem um app.css irmão com os MESMOS nomes de classes
   e tokens com outros valores (vermelho, top nav). Mudar uma regra estrutural aqui =
   mudar lá também. Se surgir um terceiro portal, mover para uma RCL.
   ===================================================================== */

/* ---- Fonte (auto-hospedada: a CSP só permite font-src 'self') ---- */
@font-face { font-family: "Inter"; font-style: normal; font-weight: 300 400; font-display: swap; src: url("../fonts/inter-regular.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 500 600; font-display: swap; src: url("../fonts/inter-medium.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 700 900; font-display: swap; src: url("../fonts/inter-bold.woff2") format("woff2"); }

/* ---- Tokens ---- */
:root {
    /* Identidade do portal */
    --brand: #1E2A4A;
    --brand-dark: #121A30;
    --brand-rgb: 30, 42, 74;
    --brand-tint: rgba(30, 42, 74, .08);
    --accent: #F3123C;
    --accent-rgb: 243, 18, 60;
    --accent-bg: linear-gradient(140deg, #F3123C 0%, #B80D2E 100%);
    --hero-bg: radial-gradient(120% 140% at 100% 0%, #3D5290 0%, rgba(61,82,144,0) 55%), linear-gradient(140deg, #2A3A66 0%, #1E2A4A 55%, #121A30 100%);
    /* Grelha fina: o motivo estruturado do fornecedor (o cliente tem "blobs" de luz) */
    --grid-lines: linear-gradient(rgba(255,255,255,.06) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.06) 1px, transparent 1px);
    --side-w: 264px;

    /* Comuns aos dois portais */
    --ink: #1F2430;
    --muted: #6B7280;
    --line: rgba(15, 23, 42, .07);
    --bg: #F4F5F8;
    --surface: #FFFFFF;
    --ok: #16A34A;
    --warn: #D97706;
    --bad: #DC2626;
    --info: #2563EB;
    --radius: 14px;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, .04), 0 1px 3px rgba(15, 23, 42, .04);
    --shadow-md: 0 10px 28px rgba(15, 23, 42, .08);
    --ease: cubic-bezier(.2, .8, .2, 1);
    --bottom-nav-h: 64px;
}

html, body {
    margin: 0;
    padding: 0;
    font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--ink);
    -webkit-tap-highlight-color: transparent;
    -webkit-font-smoothing: antialiased;
    overscroll-behavior-y: none;
    scroll-behavior: smooth;
}

/* ---- 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: var(--hero-bg);
    color: rgba(255, 255, 255, .85);
    font-size: 14px;
}
.app-loading img { width: 190px; height: auto; animation: float-y 2.4s ease-in-out infinite; }
.app-loading-bar {
    width: 140px; height: 4px; border-radius: 4px;
    background: linear-gradient(90deg, rgba(255,255,255,.25) 0%, #fff 50%, rgba(255,255,255,.25) 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,.2);
    display: none; left: 0; padding: .8rem 1.2rem; position: fixed; width: 100%; z-index: 10000;
}
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 1rem; top: .6rem; }

/* ---- Utilitários ---- */
.muted { color: var(--muted); }
.amount { font-variant-numeric: tabular-nums; font-weight: 700; white-space: nowrap; }
.amount--ok { color: var(--ok); }
.amount--bad { color: var(--bad); }
.d-block { display: block; }

.tone-brand   { --tone: var(--brand); --tone-bg: var(--brand-tint); }
.tone-ok      { --tone: var(--ok);    --tone-bg: rgba(22, 163, 74, .10); }
.tone-bad     { --tone: var(--bad);   --tone-bg: rgba(220, 38, 38, .10); }
.tone-warn    { --tone: var(--warn);  --tone-bg: rgba(217, 119, 6, .12); }
.tone-info    { --tone: var(--info);  --tone-bg: rgba(37, 99, 235, .10); }
.tone-neutral { --tone: #475569;      --tone-bg: rgba(71, 85, 105, .08); }

/* ---- Shell ---- */
.portal-appbar.mud-appbar {
    border-bottom: 1px solid var(--line);
    -webkit-backdrop-filter: saturate(1.4) blur(14px);
    backdrop-filter: saturate(1.4) blur(14px);
}
.appbar-logo { height: 26px; width: auto; display: block; }
.appbar-title { margin-left: 12px; padding-left: 12px; border-left: 1px solid var(--line); color: var(--muted); font-size: 14px; font-weight: 500; }

.portal-content {
    padding: 16px 16px calc(var(--bottom-nav-h) + env(safe-area-inset-bottom) + 24px) 16px;
    max-width: 760px;
    margin: 0 auto;
    width: 100%;
    box-sizing: border-box;
    animation: page-in .35s var(--ease);
}

/* Entrada escalonada dos blocos da página */
.stagger > * { animation: rise .5s var(--ease) both; }
.stagger > *:nth-child(1) { animation-delay: 0ms; }
.stagger > *:nth-child(2) { animation-delay: 50ms; }
.stagger > *:nth-child(3) { animation-delay: 100ms; }
.stagger > *:nth-child(4) { animation-delay: 150ms; }
.stagger > *:nth-child(5) { animation-delay: 200ms; }
.stagger > *:nth-child(6) { animation-delay: 250ms; }
.stagger > *:nth-child(7) { animation-delay: 300ms; }
.stagger > *:nth-child(n+8) { animation-delay: 350ms; }

/* ---- Cabeçalho de página ---- */
.page-header { display: flex; align-items: center; gap: 12px; margin: 4px 0 18px; }
.page-header-icon {
    flex: 0 0 44px; height: 44px; border-radius: 14px;
    display: grid; place-items: center;
    background: var(--brand-tint); color: var(--brand);
}
.page-title { font-size: 20px; font-weight: 700; letter-spacing: -.01em; line-height: 1.2; margin: 0; }
.page-sub { font-size: 13px; color: var(--muted); margin-top: 2px; }
.page-actions { margin-left: auto; display: flex; gap: 8px; flex-shrink: 0; }

.section-head { display: flex; align-items: center; justify-content: space-between; margin: 26px 2px 10px; }
.section-title { font-size: 15px; font-weight: 700; color: var(--ink); margin: 0; }
.section-link { color: var(--brand); font-size: 13px; font-weight: 600; text-decoration: none; }
.section-link:hover { text-decoration: underline; }

/* ---- Cartões ---- */
.card {
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--line);
    box-shadow: var(--shadow-sm);
    padding: 16px;
}
.portal-content .mud-paper { border: 1px solid var(--line); }

/* Linha de lista (facturas, recibos, movimentos…) */
.row-card {
    display: flex; align-items: center; gap: 12px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 10px 12px;
    margin-bottom: 8px;
    box-shadow: var(--shadow-sm);
    transition: transform .2s var(--ease), box-shadow .2s var(--ease), border-color .2s var(--ease), background-color .2s var(--ease);
}
/* Linha com detalhe expansível (pagamentos) */
.row-card--stack { flex-direction: column; align-items: stretch; gap: 0; }
.row-line { display: flex; align-items: center; gap: 12px; min-width: 0; }
.row-detail { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line); }
.row-detail-item { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; font-size: 13px; }
.row-card.clickable { cursor: pointer; user-select: none; }
.row-card:active { transform: scale(.985); }
@media (hover: hover) {
    .row-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
}
.row-card.is-selected {
    border-color: rgba(var(--brand-rgb), .55);
    background: linear-gradient(var(--brand-tint), var(--brand-tint)), var(--surface);
    box-shadow: 0 0 0 3px var(--brand-tint);
}
.row-icon {
    flex: 0 0 38px; height: 38px; border-radius: 10px;
    display: grid; place-items: center;
    background: var(--tone-bg, var(--brand-tint)); color: var(--tone, var(--brand));
}
.row-icon .mud-icon-root { font-size: 20px; }
.row-main { flex: 1; min-width: 0; }
.row-title { font-size: 14px; font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-sub { font-size: 12px; color: var(--muted); display: block; margin-top: 1px; }
.row-end { display: flex; align-items: center; gap: 6px; flex-shrink: 0; text-align: right; }
.row-end-stack { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }

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

/* Etiqueta de estado */
.pill {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 2px 8px; border-radius: 999px;
    font-size: 11px; font-weight: 600; line-height: 18px; white-space: nowrap;
    background: var(--tone-bg); color: var(--tone);
    animation: fade-in .4s var(--ease) both;
}
.pill .mud-icon-root { font-size: 14px; }

.group-label {
    font-size: 11px; font-weight: 700; color: var(--muted);
    text-transform: uppercase; letter-spacing: .08em;
    margin: 18px 4px 8px;
}

/* ---- Estado vazio ---- */
.empty {
    text-align: center;
    padding: 32px 16px;
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px dashed rgba(15, 23, 42, .12);
}
.empty-icon {
    width: 64px; height: 64px; margin: 0 auto 12px; border-radius: 50%;
    display: grid; place-items: center;
    background: var(--tone-bg); color: var(--tone);
    animation: pop .5s var(--ease) both;
}
.empty-icon .mud-icon-root { font-size: 30px; }
.empty-text { color: var(--muted); font-size: 14px; max-width: 320px; margin: 0 auto; }

/* ---- KPIs ----
   Mobile: linhas horizontais (ícone · rótulo · valor à direita) — em 2 colunas de 390px
   os valores em MZN não cabem. Desktop: tiles verticais. */
.kpi-grid { display: grid; grid-template-columns: 1fr; gap: 8px; }
.kpi {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 12px 14px;
    display: grid; grid-template-columns: 38px 1fr auto; column-gap: 12px; align-items: center;
    min-width: 0;
    transition: transform .2s var(--ease), box-shadow .2s var(--ease);
}
@media (hover: hover) { .kpi:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); } }
.kpi-icon {
    grid-row: 1 / span 2;
    width: 38px; height: 38px; border-radius: 12px;
    display: grid; place-items: center;
    background: var(--tone-bg); color: var(--tone);
}
.kpi-icon .mud-icon-root { font-size: 20px; }
.kpi-label { grid-column: 2; font-size: 13px; color: var(--muted); font-weight: 500; }
.kpi-label:nth-last-child(2) { grid-row: 1 / span 2; } /* sem nota: rótulo centrado */
.kpi-caption { grid-column: 2; font-size: 12px; color: var(--muted); }
.kpi-value { grid-column: 3; grid-row: 1 / span 2; font-size: 16px; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; white-space: nowrap; text-align: right; min-width: 80px; }
.kpi.tone-bad .kpi-value.is-alert { color: var(--bad); }
.kpi.tone-ok .kpi-value { color: var(--ok); }

/* ---- Hero (Home) ---- */
.hero {
    position: relative;
    overflow: hidden;
    color: #fff;
    background: var(--hero-bg);
    margin: -16px -16px 18px;
    padding: 20px 20px 22px;
    border-radius: 0 0 22px 22px;
    box-shadow: 0 14px 30px rgba(var(--brand-rgb), .28);
    isolation: isolate;
}
/* Linha vermelha LAM: a assinatura de marca no navy */
.brand-line { display: block; width: 36px; height: 3px; border-radius: 3px; background: var(--accent); margin: 10px 0 0; }
/* Grelha a deslizar devagar + diagonal de luz */
.hero::before {
    content: ""; position: absolute; inset: -28px; z-index: -1; pointer-events: none;
    background-image: var(--grid-lines); background-size: 28px 28px;
    -webkit-mask-image: linear-gradient(110deg, transparent 20%, #000 75%); mask-image: linear-gradient(110deg, transparent 20%, #000 75%);
    animation: grid-slide 24s linear infinite;
}
.hero::after {
    content: ""; position: absolute; z-index: -1; pointer-events: none;
    width: 140%; height: 120px; left: -20%; top: 30%;
    background: linear-gradient(90deg, rgba(255,255,255,0), rgba(255,255,255,.07), rgba(255,255,255,0));
    transform: rotate(-12deg);
    animation: sheen 9s ease-in-out infinite;
}
.hero-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.hero-greet { font-size: 14px; opacity: .9; }
.hero-name { font-size: 18px; font-weight: 700; line-height: 1.25; letter-spacing: -.01em; }
.hero-label { margin-top: 18px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .1em; opacity: .8; }
.hero-amount { font-size: clamp(28px, 8vw, 38px); font-weight: 700; letter-spacing: -.02em; line-height: 1.15; font-variant-numeric: tabular-nums; margin: 2px 0 10px; }
.hero-chip {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 5px 11px; border-radius: 999px;
    background: rgba(255, 255, 255, .16);
    border: 1px solid rgba(255, 255, 255, .2);
    font-size: 12px; font-weight: 500;
    -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
.hero-chip .mud-icon-root { font-size: 15px; }
.hero .mud-skeleton { background-color: rgba(255, 255, 255, .22); }


/* Funil de estados das facturas */
.funnel { position: relative; display: grid; grid-template-columns: repeat(3, 1fr); margin-top: 22px; }
.funnel::before {
    content: ""; position: absolute; top: 21px; left: 16.66%; right: 16.66%; height: 2px;
    background: linear-gradient(90deg, rgba(255,255,255,.35), rgba(74,222,128,.7));
    transform-origin: left center; animation: grow-x 1.1s .25s var(--ease) both;
}
.funnel-step { position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; color: #fff; text-decoration: none; animation: rise .5s var(--ease) both; }
.funnel-step:nth-child(2) { animation-delay: 120ms; }
.funnel-step:nth-child(3) { animation-delay: 240ms; }
.funnel-dot {
    width: 44px; height: 44px; border-radius: 50%;
    display: grid; place-items: center;
    background: #24335A; border: 1px solid rgba(255,255,255,.28);
    font-size: 16px; font-weight: 700; font-variant-numeric: tabular-nums;
    transition: transform .25s var(--ease);
}
.funnel-step--paid .funnel-dot { background: var(--ok); border-color: transparent; box-shadow: 0 6px 16px rgba(22,163,74,.4); }
@media (hover: hover) { .funnel-step:hover .funnel-dot { transform: translateY(-3px); } }
.funnel-label { font-size: 12px; opacity: .85; }
.funnel-rejected {
    display: inline-flex; align-items: center; gap: 6px; margin-top: 16px;
    padding: 4px 10px; border-radius: 999px;
    background: rgba(243, 18, 60, .2); color: #FFC2CE;
    font-size: 12px; font-weight: 600; text-decoration: none;
    animation: fade-in .5s .4s var(--ease) both;
}
.funnel-rejected .mud-icon-root { font-size: 15px; }

/* ---- Filtros ---- */
.filter-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin-bottom: 16px; box-shadow: var(--shadow-sm); }
.filter-bar { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; }
.filter-bar .flt-search { flex: 1 1 100%; }
.filter-bar .flt-select { flex: 1 1 140px; }
.filter-bar .flt-date { flex: 1 1 140px; min-width: 0; }
.filter-bar .flt-action { flex: 1 1 100%; }

/* ---- Formulário em passos (submeter factura) ---- */
.step { display: flex; align-items: center; gap: 10px; margin: 22px 2px 12px; font-size: 15px; font-weight: 700; }
.step:first-child { margin-top: 0; }
.step-num {
    width: 26px; height: 26px; border-radius: 50%;
    display: grid; place-items: center;
    background: var(--brand); color: #fff;
    font-size: 13px; font-weight: 700;
    box-shadow: 0 4px 10px rgba(var(--brand-rgb), .3);
}

/* ---- Cartão bancário ---- */
.bank-card {
    position: relative; overflow: hidden; isolation: isolate;
    border-radius: 20px; padding: 22px;
    color: #fff;
    background: radial-gradient(120% 120% at 100% 0%, rgba(61,82,144,.9) 0%, rgba(61,82,144,0) 60%), linear-gradient(135deg, #0F1626 0%, #1E2A4A 60%, #2A3A66 100%);
    box-shadow: 0 16px 34px rgba(18, 26, 48, .35);
}
.bank-card::after { content: ""; position: absolute; z-index: -1; width: 240px; height: 240px; right: -90px; bottom: -120px; border-radius: 50%; border: 36px solid rgba(255,255,255,.06); }
.bank-card-chip { width: 40px; height: 30px; border-radius: 7px; background: linear-gradient(135deg, #F7D774, #C9A23A); margin-bottom: 18px; box-shadow: inset 0 0 0 1px rgba(0,0,0,.15); }
.bank-card-label { font-size: 11px; text-transform: uppercase; letter-spacing: .12em; opacity: .75; }
.bank-card-nib { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: clamp(14px, 4.1vw, 22px); letter-spacing: .05em; word-break: break-all; margin: 4px 0 18px; }
.bank-card-meta { font-size: 12px; opacity: .8; display: flex; flex-wrap: wrap; gap: 4px 14px; }
.bank-grid { display: grid; gap: 12px; }

/* ---- Upload ---- */
.dropzone {
    width: 100%; box-sizing: border-box;
    display: flex; flex-direction: column; align-items: center; gap: 6px;
    padding: 22px 16px;
    border: 2px dashed rgba(15, 23, 42, .15);
    border-radius: var(--radius);
    background: #FAFBFC;
    font: inherit; color: var(--ink); cursor: pointer;
    transition: border-color .2s var(--ease), background-color .2s var(--ease), transform .2s var(--ease);
}
.dropzone:hover { border-color: var(--brand); background: var(--brand-tint); }
.dropzone:active { transform: scale(.99); }
.dropzone .mud-icon-root { font-size: 30px; color: var(--brand); }
.dropzone.has-file { border-style: solid; border-color: var(--ok); background: rgba(22, 163, 74, .06); }
.dropzone.has-file .mud-icon-root { color: var(--ok); }
.dropzone-title { font-weight: 600; font-size: 14px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dropzone-sub { font-size: 12px; color: var(--muted); }
.upload-nativo { display: none !important; }

/* ---- Perfil ---- */
.profile-card {
    position: relative; overflow: hidden; isolation: isolate;
    display: flex; align-items: center; gap: 14px;
    padding: 20px; margin-bottom: 16px;
    border-radius: 20px;
    background: var(--hero-bg); color: #fff;
    box-shadow: 0 14px 30px rgba(var(--brand-rgb), .25);
}
.profile-card::before { content: ""; position: absolute; z-index: -1; width: 200px; height: 200px; top: -90px; right: -50px; border-radius: 50%; background: radial-gradient(circle, rgba(255,255,255,.25), rgba(255,255,255,0) 70%); animation: drift-a 14s ease-in-out infinite alternate; }
.avatar {
    flex: 0 0 56px; height: 56px; border-radius: 50%;
    display: grid; place-items: center;
    background: rgba(255, 255, 255, .2); border: 2px solid rgba(255, 255, 255, .35);
    font-size: 20px; font-weight: 700; letter-spacing: .02em;
    animation: pop .5s var(--ease) both;
}
.info-list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); margin-bottom: 16px; overflow: hidden; }
.info-row { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.info-row:last-child { border-bottom: 0; }
.info-row .mud-icon-root { color: var(--muted); }
.info-label { font-size: 12px; color: var(--muted); }
.info-value { font-size: 14px; font-weight: 500; word-break: break-word; }

/* ---- Navegação inferior (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: rgba(255, 255, 255, .9);
    -webkit-backdrop-filter: saturate(1.4) blur(14px);
    backdrop-filter: saturate(1.4) blur(14px);
    border-top: 1px solid var(--line);
    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: 3px; min-height: 44px;
    text-decoration: none; color: #8A909C;
    font-size: 11px; font-weight: 500;
    transition: color .2s var(--ease);
}
.nav-ico { width: 56px; height: 30px; border-radius: 999px; display: grid; place-items: center; transition: background-color .3s var(--ease), transform .3s var(--ease); }
.nav-ico .mud-icon-root { font-size: 23px; }
.bottom-nav a.active { color: var(--brand); font-weight: 600; }
.bottom-nav a.active .nav-ico { background: var(--brand-tint); }
.bottom-nav a.active .nav-ico .mud-icon-root { animation: icon-pop .4s var(--ease); }
.bottom-nav a:active .nav-ico { transform: scale(.9); }
/* Acção central em destaque (Pagar) */
.bottom-nav a.nav-fab .nav-ico {
    width: 54px; height: 54px; border-radius: 50%;
    margin-top: -24px;
    background: var(--accent-bg); color: #fff;
    box-shadow: 0 8px 20px rgba(var(--accent-rgb), .4), 0 0 0 4px var(--bg);
}
.bottom-nav a.nav-fab .nav-ico .mud-icon-root { font-size: 26px; }
.bottom-nav a.nav-fab.active .nav-ico { background: var(--accent-bg); }

/* ---- Login / activação ---- */
.auth-shell { min-height: 100vh; min-height: 100dvh; background: var(--bg); display: flex; flex-direction: column; }
.auth-brand {
    position: relative; overflow: hidden; isolation: isolate;
    color: #fff;
    background: var(--hero-bg);
    padding: calc(28px + env(safe-area-inset-top)) 24px 84px;
}
.auth-grid {
    position: absolute; inset: -40px; z-index: -1; pointer-events: none;
    background-image: var(--grid-lines); background-size: 32px 32px;
    -webkit-mask-image: radial-gradient(120% 90% at 80% 10%, #000 30%, transparent 75%); mask-image: radial-gradient(120% 90% at 80% 10%, #000 30%, transparent 75%);
    animation: grid-slide 30s linear infinite;
}
.auth-diag { position: absolute; z-index: -1; pointer-events: none; width: 160%; height: 2px; left: -30%; background: linear-gradient(90deg, transparent, rgba(255,255,255,.18), transparent); transform: rotate(-24deg); animation: diag 12s ease-in-out infinite; }
.auth-diag-1 { top: 30%; }
.auth-diag-2 { top: 62%; animation-delay: -6s; background: linear-gradient(90deg, transparent, rgba(243,18,60,.55), transparent); }
.auth-wave { position: absolute; left: 0; right: 0; bottom: -1px; width: 100%; height: 48px; z-index: -1; display: block; }
.auth-wave path { fill: var(--bg); }
.auth-logo { width: 150px; height: auto; display: block; }
.auth-portal { margin-top: 14px; font-size: 12px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; opacity: .85; }
.auth-tagline { margin: 6px 0 0; font-size: 22px; font-weight: 700; line-height: 1.25; letter-spacing: -.01em; max-width: 420px; }
.auth-features, .auth-illu { display: none; }
.auth-main { flex: 1; position: relative; z-index: 1; margin-top: -56px; padding: 0 16px calc(24px + env(safe-area-inset-bottom)); }
.auth-card {
    max-width: 400px; margin: 0 auto;
    background: var(--surface);
    border-radius: 22px;
    box-shadow: 0 24px 60px rgba(15, 23, 42, .12);
    padding: 28px 24px;
    animation: rise .55s var(--ease) both;
}
.auth-card-top { display: flex; justify-content: flex-end; margin: -8px -6px 8px 0; }
.auth-title { font-size: 22px; font-weight: 700; letter-spacing: -.01em; margin: 0 0 4px; }
.auth-sub { font-size: 14px; color: var(--muted); margin: 0 0 20px; }
.auth-links { margin-top: 18px; text-align: center; }
.shake { animation: shake .42s var(--ease); }

/* Ilustração: documento com visto (só desktop) */
.illu-doc { width: 230px; height: auto; display: block; filter: drop-shadow(0 30px 50px rgba(5, 10, 25, .45)); animation: float-doc 7s ease-in-out infinite; }
.illu-doc .doc-check { transform-origin: 176px 196px; animation: pop .6s .5s var(--ease) both; }
.illu-doc .doc-line { transform-origin: left center; animation: grow-x .7s var(--ease) both; }
.illu-doc .doc-line:nth-of-type(2) { animation-delay: .1s; }
.illu-doc .doc-line:nth-of-type(3) { animation-delay: .2s; }
.illu-doc .doc-line:nth-of-type(4) { animation-delay: .3s; }

/* ---- Navegação lateral (desktop) ---- */
.side-nav { display: none; }

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

    .list-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-items: start; }
    .list-grid > .row-card { margin-bottom: 0; }


    .hero { margin: 0 0 22px; border-radius: 20px; padding: 26px 30px; }
    .hero-split { display: grid; grid-template-columns: 1fr minmax(320px, 420px); gap: 32px; align-items: end; }
    .hero-amount { font-size: 40px; }
    .funnel { margin-top: 0; }

    /* Sidebar navy fixa; appbar e conteúdo começam à direita dela */
    .side-nav {
        display: flex; flex-direction: column; gap: 20px;
        position: fixed; top: 0; bottom: 0; left: 0; width: var(--side-w); z-index: 1300;
        padding: 24px 16px 18px; box-sizing: border-box;
        background: linear-gradient(180deg, #1E2A4A 0%, #121A30 100%); color: #fff;
        overflow: hidden; isolation: isolate;
    }
    .side-nav::before {
        content: ""; position: absolute; inset: -32px; z-index: -1; pointer-events: none;
        background-image: var(--grid-lines); background-size: 32px 32px;
        -webkit-mask-image: linear-gradient(180deg, #000 0%, transparent 45%); mask-image: linear-gradient(180deg, #000 0%, transparent 45%);
        animation: grid-slide 30s linear infinite;
    }
    .side-brand { padding: 0 8px; }
    .side-brand img { height: 26px; width: auto; display: block; }
    .side-portal { display: block; margin-top: 10px; font-size: 11px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; opacity: .7; }
    .side-cta.mud-button-root { background: var(--accent-bg); color: #fff; box-shadow: 0 8px 18px rgba(var(--accent-rgb), .35); justify-content: flex-start; padding: 10px 16px; }
    .side-links { display: flex; flex-direction: column; gap: 4px; }
    .side-links a {
        position: relative; display: flex; align-items: center; gap: 12px;
        padding: 10px 14px; border-radius: 10px;
        color: rgba(255,255,255,.72); text-decoration: none; font-size: 14px; font-weight: 500;
        transition: background-color .25s var(--ease), color .2s var(--ease);
    }
    .side-links a .mud-icon-root { font-size: 20px; }
    .side-links a:hover { background: rgba(255,255,255,.06); color: #fff; }
    .side-links a.active { background: rgba(255,255,255,.1); color: #fff; font-weight: 600; }
    .side-links a.active::before { content: ""; position: absolute; left: 0; top: 9px; bottom: 9px; width: 3px; border-radius: 3px; background: var(--accent); transform-origin: center; animation: bar-in .35s var(--ease) both; }
    .side-links a.active .mud-icon-root { animation: icon-pop .4s var(--ease); }
    .side-foot { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 12px 8px 0; border-top: 1px solid rgba(255,255,255,.1); }
    .side-avatar { flex: 0 0 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: rgba(255,255,255,.14); font-size: 13px; font-weight: 700; }
    .side-user { flex: 1; min-width: 0; font-size: 13px; line-height: 1.3; }
    .side-user span { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .side-user .muted { color: rgba(255,255,255,.6); font-size: 12px; }
    .side-foot .mud-icon-button { color: rgba(255,255,255,.7); }

    /* Só com sessão (a sidebar vive num AuthorizeView): a 404 anónima não fica com faixa vazia */
    .side-nav ~ .portal-appbar.mud-appbar { left: var(--side-w); width: auto; right: 0; }
    .side-nav ~ .mud-main-content { padding-left: var(--side-w); }
    .side-nav ~ .portal-appbar .appbar-logo-link { display: none; }

    .kpi-grid { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
    .kpi { padding: 18px; display: flex; flex-direction: column; align-items: stretch; gap: 6px; }
    .kpi-icon { margin-bottom: 4px; }
    .kpi-value { font-size: 20px; text-align: left; overflow: hidden; text-overflow: ellipsis; }


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

    .page-title { font-size: 24px; }
    .form-narrow { max-width: 760px; }
    .only-mobile { display: none !important; }


    /* Login em ecrã dividido */
    .auth-shell { flex-direction: row; }
    .auth-brand {
        flex: 0 0 55%;
        background: linear-gradient(160deg, #24335A 0%, #1E2A4A 45%, #0F1626 100%);
        display: flex; flex-direction: column;
        padding: 48px 56px;
        min-height: 100vh; box-sizing: border-box;
    }
    .auth-wave { display: none; }
    .auth-logo { width: 170px; }
    .auth-portal { margin-top: auto; }
    .auth-tagline { font-size: 34px; margin-top: 10px; }
    .auth-illu { display: block; position: relative; margin: 40px 0 32px 24px; }
    .auth-features { display: grid; gap: 14px; list-style: none; padding: 0; margin: 0 0 8px; }
    .auth-features li { display: flex; align-items: center; gap: 12px; font-size: 15px; animation: rise .6s var(--ease) both; }
    .auth-features li:nth-child(2) { animation-delay: 80ms; }
    .auth-features li:nth-child(3) { animation-delay: 160ms; }
    .feat-ico { flex: 0 0 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; background: rgba(255,255,255,.15); border: 1px solid rgba(255,255,255,.2); }
    .feat-ico .mud-icon-root { font-size: 20px; }
    .auth-main { margin-top: 0; display: flex; align-items: center; justify-content: center; padding: 32px; }
    .auth-card { width: 100%; box-shadow: var(--shadow-md); }
}

/* ---- Animações ---- */
@keyframes page-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { 0% { opacity: 0; transform: scale(.6); } 60% { opacity: 1; transform: scale(1.08); } 100% { transform: scale(1); } }
@keyframes icon-pop { 0% { transform: scale(1); } 45% { transform: scale(1.18); } 100% { transform: scale(1); } }
@keyframes grow-x { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes drift-a { from { transform: translate(0, 0) scale(1); } to { transform: translate(-40px, 30px) scale(1.15); } }
@keyframes drift-b { from { transform: translate(0, 0) scale(1); } to { transform: translate(50px, -20px) scale(.9); } }
@keyframes float-y { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@keyframes float-doc { 0%, 100% { transform: rotate(4deg) translateY(0); } 50% { transform: rotate(2deg) translateY(-12px); } }
@keyframes grid-slide { from { transform: translate(0, 0); } to { transform: translate(28px, 28px); } }
@keyframes sheen { 0%, 100% { transform: translateX(-30%) rotate(-12deg); opacity: 0; } 50% { transform: translateX(30%) rotate(-12deg); opacity: 1; } }
@keyframes diag { 0%, 100% { transform: translateX(-12%) rotate(-24deg); opacity: .2; } 50% { transform: translateX(12%) rotate(-24deg); opacity: 1; } }
@keyframes bar-in { from { transform: scaleY(0); } to { transform: scaleY(1); } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-6px); } 40% { transform: translateX(6px); } 60% { transform: translateX(-4px); } 80% { transform: translateX(4px); } }

/* Acessibilidade: quem pede menos movimento não vê nenhuma animação */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        animation-delay: 0ms !important;
        transition-duration: .01ms !important;
        scroll-behavior: auto !important;
    }
}
