:root {
    --tp-primary: #4f46e5;
    --tp-primary-dark: #4338ca;
    --tp-primary-soft: #eef2ff;
    --tp-dark: #0f172a;
    --tp-dark-2: #1e293b;
    --tp-text: #1e293b;
    --tp-muted: #64748b;
    --tp-border: #e2e8f0;
    --tp-bg: #f8fafc;
    --tp-success: #22c55e;
    --tp-danger: #ef4444;
    --tp-warning: #f59e0b;
    --tp-info: #0ea5e9;
    --tp-sidebar-w: 260px;
}

* { box-sizing: border-box; }

/* ---------------- Previews de marca (Configuracoes) ---------------- */
.tp-logo-preview {
    width: 72px; height: 72px; border-radius: 12px;
    border: 1px dashed var(--tp-border);
    display: grid; place-items: center; overflow: hidden;
    background: var(--tp-bg); flex-shrink: 0;
}
.tp-logo-preview img { max-width: 100%; max-height: 100%; object-fit: contain; }
.tp-logo-preview .tp-logo { width: 44px; height: 44px; border-radius: 10px; font-size: 1.25rem; }
.tp-favicon-preview {
    width: 48px; height: 48px; border-radius: 10px;
    border: 1px dashed var(--tp-border);
    display: grid; place-items: center; overflow: hidden;
    background: var(--tp-bg); flex-shrink: 0; font-size: 1.4rem;
}
.tp-favicon-preview img { max-width: 32px; max-height: 32px; object-fit: contain; }
.tp-brand-preview {
    border-radius: 12px; padding: 1.25rem;
    display: flex; align-items: center; gap: .7rem;
    color: #fff; font-size: 1.05rem;
}
.tp-preview-logo {
    width: 40px; height: 40px; border-radius: 10px;
    background: rgba(255,255,255,.2);
    display: grid; place-items: center; overflow: hidden;
    font-weight: 800; color: #fff; flex-shrink: 0;
}
.tp-preview-logo img { width: 100%; height: 100%; object-fit: contain; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--tp-bg);
    color: var(--tp-text);
    margin: 0;
}

/* ---------------- Sidebar ---------------- */
.tp-sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: var(--tp-sidebar-w);
    background: var(--tp-dark);
    color: #cbd5e1;
    display: flex;
    flex-direction: column;
    z-index: 1040;
    transition: transform .25s ease;
    overflow-y: auto;
}
.tp-sidebar .tp-brand {
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: 1.25rem 1.25rem;
    color: #fff;
    font-weight: 700;
    font-size: 1.15rem;
    border-bottom: 1px solid rgba(255,255,255,.06);
}
.tp-brand .tp-logo {
    width: 34px; height: 34px;
    border-radius: 9px;
    background: linear-gradient(135deg, var(--tp-primary), #8b5cf6);
    display: grid; place-items: center;
    color: #fff; font-weight: 800;
}
.tp-nav { padding: .75rem; flex: 1; }
.tp-nav .tp-group-title {
    font-size: .68rem;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: #64748b;
    padding: 1rem .75rem .35rem;
    font-weight: 600;
}
.tp-nav a {
    display: flex;
    align-items: center;
    gap: .7rem;
    padding: .6rem .75rem;
    border-radius: 9px;
    color: #cbd5e1;
    text-decoration: none;
    font-size: .9rem;
    font-weight: 500;
    margin-bottom: 2px;
    transition: all .15s;
}
.tp-nav a i { font-size: 1.1rem; width: 20px; text-align: center; }
.tp-nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.tp-nav a.active {
    background: var(--tp-primary);
    color: #fff;
    box-shadow: 0 4px 12px rgba(79,70,229,.4);
}

/* ---------------- Topbar + conteudo ---------------- */
.tp-main {
    margin-left: var(--tp-sidebar-w);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}
.tp-topbar {
    background: #fff;
    border-bottom: 1px solid var(--tp-border);
    padding: .85rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 1030;
}
.tp-content { padding: 1.5rem; flex: 1; }
.tp-page-title { font-weight: 700; font-size: 1.4rem; margin: 0; }
.tp-page-sub { color: var(--tp-muted); font-size: .9rem; margin: 0; }

.tp-avatar {
    width: 38px; height: 38px;
    border-radius: 50%;
    background: var(--tp-primary-soft);
    color: var(--tp-primary);
    display: grid; place-items: center;
    font-weight: 700;
}

/* ---------------- Cards ---------------- */
.card {
    border: 1px solid var(--tp-border);
    border-radius: 14px;
    box-shadow: 0 1px 3px rgba(15,23,42,.04);
}
.card-header {
    background: #fff;
    border-bottom: 1px solid var(--tp-border);
    font-weight: 600;
    border-radius: 14px 14px 0 0 !important;
}

.tp-stat {
    background: #fff;
    border: 1px solid var(--tp-border);
    border-radius: 14px;
    padding: 1.25rem;
    height: 100%;
}
.tp-stat .tp-stat-icon {
    width: 46px; height: 46px;
    border-radius: 11px;
    display: grid; place-items: center;
    font-size: 1.35rem;
    margin-bottom: .85rem;
}
.tp-stat .tp-stat-value { font-size: 1.65rem; font-weight: 700; line-height: 1.1; }
.tp-stat .tp-stat-label { color: var(--tp-muted); font-size: .85rem; }
.tp-stat .tp-trend { font-size: .8rem; font-weight: 600; }
.tp-trend.up { color: var(--tp-success); }
.tp-trend.down { color: var(--tp-danger); }

.bg-soft-primary { background: var(--tp-primary-soft); color: var(--tp-primary); }
.bg-soft-success { background: #dcfce7; color: #16a34a; }
.bg-soft-warning { background: #fef3c7; color: #d97706; }
.bg-soft-danger { background: #fee2e2; color: #dc2626; }
.bg-soft-info { background: #e0f2fe; color: #0284c7; }

/* Badges de plataforma */
.tp-plat { display: inline-flex; align-items: center; gap: .35rem; font-weight: 600; font-size: .8rem; padding: .25rem .6rem; border-radius: 7px; }
.tp-plat.meta { background: #e7f0ff; color: #1877f2; }
.tp-plat.google { background: #fdeceb; color: #ea4335; }
.tp-plat.tiktok { background: #f1f1f2; color: #010101; }
.tp-plat.linkedin { background: #e6f2f8; color: #0a66c2; }
.tp-plat.ga4 { background: #fef0e6; color: #e8710a; }

/* ---------------- Botoes ---------------- */
.btn-primary {
    background: var(--tp-primary);
    border-color: var(--tp-primary);
}
.btn-primary:hover { background: var(--tp-primary-dark); border-color: var(--tp-primary-dark); }
.btn { border-radius: 9px; font-weight: 500; }

/* ---------------- Auth ---------------- */
.tp-auth {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1fr 1fr;
}
.tp-auth-visual {
    position: relative;
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 45%, #0f172a 100%);
    background-size: 200% 200%;
    animation: tp-gradient 14s ease infinite;
    color: #fff;
    padding: 3rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    overflow: hidden;
}
@keyframes tp-gradient {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}
/* Orbes luminosos de fundo */
.tp-auth-visual::before,
.tp-auth-visual::after {
    content: "";
    position: absolute;
    border-radius: 50%;
    filter: blur(70px);
    opacity: .5;
    pointer-events: none;
}
.tp-auth-visual::before {
    width: 340px; height: 340px;
    background: radial-gradient(circle, #a78bfa, transparent 70%);
    top: -80px; right: -60px;
    animation: tp-float-slow 12s ease-in-out infinite;
}
.tp-auth-visual::after {
    width: 300px; height: 300px;
    background: radial-gradient(circle, #22d3ee, transparent 70%);
    bottom: -90px; left: -70px;
    animation: tp-float-slow 15s ease-in-out infinite reverse;
}
/* Grade de pontos sutil */
.tp-auth-visual > * { position: relative; z-index: 2; }

/* Conteudo de texto */
.tp-auth-copy { max-width: 460px; }

/* Cena 3D com perspectiva */
.tp-scene {
    perspective: 1400px;
    margin-top: 2rem;
    display: flex;
    justify-content: center;
    min-height: 260px;
}
.tp-scene-inner {
    position: relative;
    width: 100%;
    max-width: 440px;
    transform-style: preserve-3d;
    animation: tp-scene-rotate 9s ease-in-out infinite alternate;
}
@keyframes tp-scene-rotate {
    from { transform: rotateY(-16deg) rotateX(8deg); }
    to   { transform: rotateY(6deg) rotateX(2deg); }
}
/* Card principal com o preview do dashboard */
.tp-dash-card {
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 30px 60px -15px rgba(0,0,0,.55), 0 0 0 1px rgba(255,255,255,.08);
    transform: translateZ(40px);
    background: #0f172a;
}
.tp-dash-card img { display: block; width: 100%; height: auto; }

/* Cards de metrica flutuantes */
.tp-float-card {
    position: absolute;
    background: rgba(255,255,255,.95);
    color: var(--tp-dark);
    border-radius: 13px;
    padding: .7rem .9rem;
    box-shadow: 0 18px 40px -12px rgba(0,0,0,.5);
    display: flex;
    align-items: center;
    gap: .6rem;
    font-weight: 600;
    backdrop-filter: blur(6px);
}
.tp-float-card .tp-fc-icon {
    width: 34px; height: 34px; border-radius: 9px;
    display: grid; place-items: center; font-size: 1.05rem; color: #fff;
}
.tp-float-card small { display: block; font-weight: 500; color: var(--tp-muted); font-size: .68rem; }
.tp-float-card .tp-fc-value { font-size: 1.05rem; line-height: 1.1; }

.tp-fc-1 { top: -26px; left: -34px; transform: translateZ(90px); animation: tp-float-a 6s ease-in-out infinite; }
.tp-fc-2 { bottom: 26px; right: -40px; transform: translateZ(120px); animation: tp-float-b 7s ease-in-out infinite; }
.tp-fc-3 { bottom: -30px; left: 30px; transform: translateZ(70px); animation: tp-float-a 8s ease-in-out infinite .5s; }

@keyframes tp-float-a { 0%,100% { margin-top: 0; } 50% { margin-top: -14px; } }
@keyframes tp-float-b { 0%,100% { margin-top: 0; } 50% { margin-top: 16px; } }
@keyframes tp-float-slow { 0%,100% { transform: translate(0,0) scale(1); } 50% { transform: translate(20px,30px) scale(1.08); } }

/* Logos das plataformas */
.tp-plats-row { display: flex; gap: .6rem; flex-wrap: wrap; margin-top: 1.75rem; }
.tp-plat-chip {
    width: 44px; height: 44px; border-radius: 12px;
    display: grid; place-items: center;
    background: rgba(255,255,255,.12);
    border: 1px solid rgba(255,255,255,.18);
    font-size: 1.3rem; color: #fff;
    backdrop-filter: blur(4px);
    animation: tp-chip-pop 5s ease-in-out infinite;
}
.tp-plat-chip:nth-child(2) { animation-delay: .4s; }
.tp-plat-chip:nth-child(3) { animation-delay: .8s; }
.tp-plat-chip:nth-child(4) { animation-delay: 1.2s; }
.tp-plat-chip:nth-child(5) { animation-delay: 1.6s; }
@keyframes tp-chip-pop { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }

/* Entrada suave dos elementos */
.tp-reveal { opacity: 0; transform: translateY(16px); animation: tp-reveal-in .8s ease forwards; }
.tp-reveal.d1 { animation-delay: .1s; }
.tp-reveal.d2 { animation-delay: .25s; }
.tp-reveal.d3 { animation-delay: .4s; }
.tp-reveal.d4 { animation-delay: .55s; }
@keyframes tp-reveal-in { to { opacity: 1; transform: translateY(0); } }

@media (prefers-reduced-motion: reduce) {
    .tp-auth-visual, .tp-scene-inner, .tp-float-card, .tp-plat-chip,
    .tp-auth-visual::before, .tp-auth-visual::after, .tp-reveal {
        animation: none !important;
    }
    .tp-reveal { opacity: 1; transform: none; }
}

.tp-auth-form { display: grid; place-items: center; padding: 2rem; }
.tp-auth-form .tp-auth-box { width: 100%; max-width: 400px; }

/* ---------------- Form builder ---------------- */
.tp-field-item {
    background: #fff;
    border: 1px solid var(--tp-border);
    border-radius: 10px;
    padding: .85rem 1rem;
    margin-bottom: .6rem;
    cursor: grab;
}
.tp-field-item.dragging { opacity: .5; }

/* ---------------- Responsivo ---------------- */
@media (max-width: 991.98px) {
    .tp-sidebar { transform: translateX(-100%); }
    .tp-sidebar.aberta { transform: translateX(0); }
    .tp-main { margin-left: 0; }
    .tp-auth { grid-template-columns: 1fr; }
    .tp-auth-visual { display: none; }
}

.tp-overlay {
    position: fixed; inset: 0;
    background: rgba(15,23,42,.5);
    z-index: 1035;
    display: none;
}
.tp-overlay.ativo { display: block; }
