/* ============================================
   ESTILOS GLOBAIS
   ============================================ */
* { scrollbar-width: thin; }

/* Ícones Lucide seguem o font-size do elemento, igual o Font Awesome fazia,
   então nenhuma classe de tamanho (text-sm/text-lg/text-xl...) precisa mudar. */
/* Reserva espaço mesmo antes do Lucide converter o atributo em SVG,
   evitando botões com área clicável zerada caso a CDN demore/falhe */
[data-lucide] {
    display: inline-block;
    min-width: 1em;
    min-height: 1em;
}

svg.lucide {
    display: inline-block;
    width: 1em;
    height: 1em;
    stroke-width: 2;
    vertical-align: -0.125em;
    flex-shrink: 0;
    pointer-events: none;
}

.whatsapp-icon {
    display: inline-block;
    width: 1.1em;
    height: 1.1em;
    vertical-align: -0.15em;
    flex-shrink: 0;
}

/* iOS Safari usa um motor de scroll diferente do Chrome/Android — sem isso,
   áreas com overflow-y-auto podem "travar" o toque em vez de rolar suave */
.overflow-y-auto, .overflow-y-scroll {
    -webkit-overflow-scrolling: touch;
}
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--brand, #888); border-radius: 10px; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    transition: background-color 0.3s ease, color 0.3s ease;
    margin: 0;
    overflow-x: hidden;
}


.theme-dark {
    --bg-primary: #0a0a0a;
    --bg-secondary: #141414;
    --bg-card: #161616;
    --bg-input: #1c1c1c;
    --border-color: #2a2a2a;
    --text-primary: #f5f5f5;
    --text-secondary: #a3a3a3;
    --text-muted: #6b6b6b;
    --shadow: 0 4px 24px rgba(0,0,0,0.5);
    --hover-bg: rgba(255, 255, 255, 0.06);
    --active-bg: rgba(255, 255, 255, 0.1);
    --brand: #ffffff;
    --brand-light: #d4d4d4;
    --brand-dark: #e5e5e5;
    --brand-contrast: #0a0a0a;
    --brand-tint-20: rgba(255, 255, 255, 0.16);
    --brand-tint-30: rgba(255, 255, 255, 0.24);
    --glow: 0 0 24px rgba(255, 255, 255, 0.08);
}

.theme-light {
    --bg-primary: #f2f2f0;
    --bg-secondary: #ffffff;
    --bg-card: #ffffff;
    --bg-input: #f5f5f4;
    --border-color: #e8e8e6;
    --text-primary: #111111;
    --text-secondary: #6b6b6b;
    --text-muted: #a3a3a3;
    --shadow: 0 1px 2px rgba(0,0,0,0.04), 0 8px 24px rgba(0,0,0,0.05);
    --hover-bg: rgba(0, 0, 0, 0.04);
    --active-bg: rgba(0, 0, 0, 0.06);
    --brand: #111111;
    --brand-light: #404040;
    --brand-dark: #000000;
    --brand-contrast: #ffffff;
    --brand-tint-20: rgba(17, 17, 17, 0.1);
    --brand-tint-30: rgba(17, 17, 17, 0.16);
    --glow: 0 0 24px rgba(0, 0, 0, 0.06);
}

.theme-dark body { background: var(--bg-primary); color: var(--text-primary); }
.theme-light body { background: var(--bg-primary); color: var(--text-primary); }

.bg-primary { background: var(--bg-primary); }
.bg-secondary { background: var(--bg-secondary); }
.bg-card { background: var(--bg-card); }
.border-theme { border-color: var(--border-color); }
.text-secondary { color: var(--text-secondary); }
.text-muted { color: var(--text-muted); }
.shadow-theme { box-shadow: var(--shadow); transition: box-shadow 0.2s ease, transform 0.2s ease; }
.shadow-glow { box-shadow: var(--glow); }
.hover-bg { transition: background 0.2s; }
.hover-bg:hover { background: var(--hover-bg); }

.brand { color: var(--brand); }
.bg-brand { background: var(--brand); color: var(--brand-contrast); }
.bg-brand:hover { background: var(--brand-dark); }
.border-brand { border-color: var(--brand); }

/* Badges de ícone coloridos — usados nos cabeçalhos de seção e cards do dashboard,
   substituindo os emojis por um visual consistente com o resto do app */
.icon-badge {
    width: 40px; height: 40px; border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.icon-badge-sm { width: 30px; height: 30px; border-radius: 9px; }
.icon-badge svg { width: 18px; height: 18px; }
.icon-badge-sm svg { width: 15px; height: 15px; }
.icon-badge-neutral { background: var(--hover-bg); color: var(--brand); }
.icon-badge-green { background: rgba(34, 197, 94, 0.12); color: #22c55e; }
.icon-badge-yellow { background: rgba(234, 179, 8, 0.12); color: #eab308; }
.icon-badge-blue { background: rgba(59, 130, 246, 0.12); color: #3b82f6; }
.icon-badge-red { background: rgba(239, 68, 68, 0.12); color: #ef4444; }
.icon-badge-invert { background: rgba(255, 255, 255, 0.16); color: var(--brand-contrast); }

/* Card "hero" invertido (destaque em preto/branco), estilo do dashboard de referência */
.kpi-hero { background: var(--brand); color: var(--brand-contrast); }
.kpi-hero .text-secondary, .kpi-hero span[style*="text-secondary"] { color: rgba(255,255,255,0.6) !important; }
.kpi-hero p, .kpi-hero h3 { color: var(--brand-contrast) !important; }
.theme-light .kpi-hero { color: #fff; }
.theme-dark .kpi-hero { color: #0a0a0a; }
.kpi-hero .kpi-muted { opacity: 0.65; }

.section-title { display: flex; align-items: center; gap: 10px; }
.rounded-xl { border-radius: 20px !important; }
.rounded-lg { border-radius: 16px !important; }
.rounded-md { border-radius: 12px !important; }
.rounded-2xl { border-radius: 26px !important; }

/* leve elevação ao passar o mouse nos cards principais (dashboard, chips, etc.) */
.bg-card.shadow-theme:hover, .shadow-theme.hover-bg:hover {
    box-shadow: 0 2px 4px rgba(0,0,0,0.05), 0 12px 28px rgba(0,0,0,0.08);
}
.theme-dark .bg-card.shadow-theme:hover, .theme-dark .shadow-theme.hover-bg:hover {
    box-shadow: 0 4px 28px rgba(0,0,0,0.6);
}

.sidebar-item {
    transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
    cursor: pointer;
    border-left: 3px solid transparent;
    color: var(--text-secondary);
    position: relative;
    width: 100%;
    background: transparent;
    border-top: none;
    border-right: none;
    border-bottom: none;
    text-align: left;
    font: inherit;
    appearance: none;
    -webkit-appearance: none;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}
.sidebar-item:hover {
    background: var(--hover-bg);
    color: var(--text-primary);
}
.theme-dark .theme-icon-light { display: none; }
.theme-light .theme-icon-dark { display: none; }

.sidebar-item.active {
    background: var(--active-bg);
    color: var(--brand);
    border-left-color: var(--brand);
}
.sidebar-item .icon { width: 20px; height: 20px; text-align: center; flex-shrink: 0; }
.sidebar-item .badge-new {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 8px;
    background: var(--brand);
    color: #fff;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.toast { animation: slideInRight 0.4s ease; }
@keyframes slideInRight {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}
@keyframes fadeOutRight {
    to { opacity: 0; transform: translateX(100%); }
}

.spinner {
    border: 3px solid var(--border-color);
    border-top: 3px solid var(--brand);
    border-radius: 50%;
    width: 24px;
    height: 24px;
    animation: spin 0.8s linear infinite;
    display: inline-block;
}
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.pulse-dot { animation: pulse 2s infinite; }
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

.tab-content { display: none; }
.tab-content.active { display: block; animation: fadeIn 0.3s ease; }
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.step-dot {
    width: 36px; height: 36px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 14px;
    background: var(--bg-input); color: var(--text-muted);
    border: 2px solid var(--border-color);
    transition: background 0.3s ease, color 0.3s ease, border-color 0.3s ease; flex-shrink: 0;
}
.step-dot.active {
    background: var(--brand); border-color: var(--brand); color: var(--brand-contrast);
    box-shadow: 0 0 0 4px var(--active-bg);
}
.step-dot.completed {
    background: #22c55e; border-color: #22c55e; color: #fff;
}
.step-line {
    flex: 1; height: 2px; background: var(--border-color);
    min-width: 20px; transition: background 0.3s;
}
.step-line.completed { background: #22c55e; }

.input-theme {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 10px 14px;
    border-radius: 10px;
    width: 100%;
    transition: border-color 0.2s, box-shadow 0.2s;
    outline: none;
}
.input-theme:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px var(--active-bg);
}
.input-theme::placeholder { color: var(--text-muted); }

.modal-overlay {
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(4px);
    opacity: 0;
    transition: opacity 0.3s ease;
}
.modal-overlay.show { opacity: 1; }
.modal-content {
    transform: scale(0.9) translateY(20px);
    transition: transform 0.3s ease, opacity 0.3s ease;
    opacity: 0;
}
.modal-overlay.show .modal-content {
    transform: scale(1) translateY(0);
    opacity: 1;
}

#loginPage {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.2);
}
#loginPage.hidden { display: none; }

#mainApp {
    display: none;
    min-height: 100vh;
    position: relative;
    z-index: auto;
}
#mainApp.show { display: flex; }

/* Overlay fora do fluxo; no mobile cobre só o conteúdo, nunca a sidebar */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1040;
    pointer-events: auto;
}
.mobile-menu-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--text-secondary);
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    position: relative;
    z-index: 1060;
}
.toast-stack {
    position: fixed;
    z-index: 9999;
    max-width: min(22rem, calc(100vw - 24px));
    width: auto;
    pointer-events: none;
}
.toast-stack > * { pointer-events: auto; }
.toast-stack-top { top: 12px; right: 12px; }
.toast-stack-bottom { bottom: 12px; right: 12px; }

#loginPage .brand-icon {
    color: #ffffff;
    font-size: 3.2rem;
    filter: drop-shadow(0 0 30px rgba(255, 255, 255, 0.12));
}

#loginPage .input-group input {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #fff;
    transition: background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

#loginPage .input-group input:focus {
    border-color: rgba(255, 255, 255, 0.4);
    background: rgba(255, 255, 255, 0.09);
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.08);
    outline: none;
}

#loginPage .input-group input::placeholder { color: rgba(255, 255, 255, 0.3); }
#loginPage label { color: rgba(255, 255, 255, 0.5); font-size: 13px; font-weight: 500; letter-spacing: 0.3px; }
#loginPage h1 { font-size: 26px; font-weight: 700; color: #fff; letter-spacing: -0.5px; }
#loginPage .subtitle { color: rgba(255, 255, 255, 0.4); font-size: 13px; letter-spacing: 0.5px; }
#loginPage .glow-line { width: 60px; height: 2px; background: linear-gradient(90deg, transparent, rgba(255,255,255,0.7), transparent); margin: 16px auto 0; border-radius: 2px; }
#loginPage a { color: rgba(255, 255, 255, 0.55); }
#loginPage a:hover { color: #fff; }

.btn-cyber {
    position: relative;
    width: 100%;
    height: 48px;
    background-color: var(--brand, #000);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--brand-contrast, #fff);
    border: none;
    padding: 12px;
    gap: 12px;
    border-radius: 14px;
    cursor: pointer;
    font-weight: 600;
    transition: transform 0.15s ease, opacity 0.15s ease, box-shadow 0.15s ease;
    overflow: hidden;
    will-change: transform;
}

.btn-cyber:hover { transform: translateY(-1px); box-shadow: 0 8px 20px rgba(0,0,0,0.18); opacity: 0.92; }
.btn-cyber:active { transform: translateY(0); opacity: 0.85; }

.btn-cyber-secondary {
    position: relative;
    width: 100%;
    height: 48px;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    padding: 12px;
    gap: 12px;
    border-radius: 14px;
    cursor: pointer;
    font-weight: 600;
    transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.btn-cyber-secondary:hover {
    background: var(--hover-bg);
    border-color: var(--brand);
    color: var(--text-primary);
}

/* no tema escuro, a borda cinza-escura padrão fica pouco visível — reforça o contraste */
.theme-dark .btn-cyber-secondary {
    border-color: rgba(255, 255, 255, 0.18);
    color: var(--text-primary);
}
.theme-dark .btn-cyber-secondary:hover {
    border-color: #fff;
    background: rgba(255, 255, 255, 0.08);
}

.chat-action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    background: var(--bg-input);
    color: var(--text-secondary);
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.chat-action-btn:hover {
    background: var(--hover-bg);
    color: var(--text-primary);
    border-color: var(--brand);
}
.chat-action-warn:hover { color: #eab308; border-color: #eab308; }
.chat-action-danger:hover { color: #ef4444; border-color: #ef4444; }
#chatContactActions:not(.hidden) { display: flex; }
#btnClearAllChats:not(.hidden) { display: inline-flex; }

.quick-reply-picker {
    position: absolute;
    left: 0;
    right: 0;
    bottom: calc(100% + 6px);
    z-index: 40;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: var(--shadow);
    padding: 8px;
    max-height: 260px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.quick-reply-picker.hidden { display: none; }
.quick-reply-picker-list {
    overflow-y: auto;
    max-height: 200px;
}
.quick-reply-item {
    width: 100%;
    text-align: left;
    padding: 8px 10px;
    border-radius: 8px;
    border: 0;
    background: transparent;
    cursor: pointer;
    color: var(--text-primary);
}
.quick-reply-item:hover { background: var(--hover-bg); }
.quick-reply-item .qr-title { font-size: 13px; font-weight: 600; }
.quick-reply-item .qr-preview { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

.funil-step-preview {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: var(--bg-input);
}
.funil-step-preview .step-num {
    width: 22px;
    height: 22px;
    border-radius: 999px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    background: var(--brand);
    color: #fff;
    flex-shrink: 0;
}

.chat-bubble {
    max-width: 80%;
    padding: 10px 16px;
    border-radius: 12px;
    margin-bottom: 6px;
    word-wrap: break-word;
}
.chat-bubble.sent {
    background: var(--brand); color: #fff;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}
.chat-bubble.received {
    background: var(--bg-input);
    color: var(--text-primary);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}
.chat-bubble .time { font-size: 10px; opacity: 0.7; margin-top: 4px; display: block; }
.chat-bubble .badge-ai { font-size: 8px; background: #8b5cf6; color: #fff; padding: 2px 8px; border-radius: 10px; margin-top: 4px; display: inline-block; }

.quick-reply-btn {
    transition: background 0.2s, color 0.2s, border-color 0.2s; cursor: pointer;
    background: var(--bg-input); border: 1px solid var(--border-color);
    color: var(--text-secondary); padding: 6px 14px;
    border-radius: 20px; font-size: 12px; white-space: nowrap;
}
.quick-reply-btn:hover {
    background: var(--brand); color: #fff; border-color: var(--brand);
}

.media-preview { max-width: 200px; max-height: 150px; border-radius: 8px; object-fit: cover; }

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 12px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
}
.status-badge.active { background: rgba(34, 197, 94, 0.15); color: #22c55e; }
.status-badge.paused { background: rgba(234, 179, 8, 0.15); color: #eab308; }
.status-badge.completed { background: rgba(59, 130, 246, 0.15); color: #3b82f6; }
.status-badge.pending { background: rgba(148, 163, 184, 0.15); color: #94a3b8; }
.status-badge.failed { background: rgba(239, 68, 68, 0.15); color: #ef4444; }

.plano-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 10px;
    font-weight: 600;
}
.plano-badge.starter { background: rgba(59, 130, 246, 0.15); color: #3b82f6; }
.plano-badge.enterprise { background: rgba(168, 85, 247, 0.15); color: #a855f7; }
.plano-badge.obsidian { background: rgba(234, 179, 8, 0.15); color: #eab308; }

.progress-bar { height: 4px; background: var(--border-color); border-radius: 2px; overflow: hidden; }
.progress-bar .fill { height: 100%; border-radius: 2px; transition: width 0.5s ease; }
.progress-bar .fill.green { background: #22c55e; }
.progress-bar .fill.yellow { background: #eab308; }
.progress-bar .fill.red { background: #ef4444; }
.progress-bar .fill.purple { background: var(--brand); }

.chat-shell {
    display: grid;
    grid-template-columns: minmax(240px, 320px) 1fr;
    gap: 16px;
    height: calc(100dvh - 148px);
    min-height: 420px;
}
.chat-sidebar, .chat-thread {
    min-height: 0;
    height: 100%;
}
.chat-instances-list { max-height: 160px; flex: 0 0 auto; }
.chat-sidebar-list { max-height: none; flex: 1; }
.chat-sidebar { display: flex; flex-direction: column; min-height: 0; }
.chat-composer {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: nowrap;
}
.chat-composer .input-theme { min-width: 0; }
.chat-ptt-btn { color: var(--brand); border-color: var(--brand); }
.chat-ptt-preview {
    margin-top: 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 10px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    font-size: 12px;
    color: var(--text-secondary);
}
.chat-ptt-preview.hidden { display: none; }
.chat-messages-audio { font-size: 13px; }

@media (max-width: 980px) {
    .chat-shell {
        grid-template-columns: 1fr;
        height: calc(100dvh - 118px);
        min-height: 360px;
    }
    .chat-shell.chat-conversation-open .chat-sidebar { display: none; }
    .chat-shell:not(.chat-conversation-open) .chat-thread { display: none; }
    .chat-composer { flex-wrap: wrap; }
    .chat-composer .input-theme { flex: 1 1 100%; order: -1; }
}

@media (max-width: 768px) {
    /* left em vez de transform: no iOS o transform cria stacking e o overlay
       engolia os toques das abas (só funcionava no "modo PC"). */
    .sidebar-mobile {
        position: fixed;
        top: 0;
        left: -110%;
        height: 100%;
        height: 100dvh;
        width: min(280px, 86vw);
        transform: none;
        -webkit-transform: none;
        transition: left 0.25s ease;
        z-index: 1050;
        background: var(--bg-secondary);
        border-right: 1px solid var(--border-color);
        padding-top: env(safe-area-inset-top);
        padding-bottom: env(safe-area-inset-bottom);
    }
    .sidebar-mobile.open {
        left: 0;
        transform: none;
        -webkit-transform: none;
    }
    .sidebar-overlay {
        left: min(280px, 86vw);
    }
    .sidebar-overlay.open { display: block; }
    .mobile-menu-btn { display: inline-flex; }
    .header-desktop-only { display: none !important; }
    header.bg-card { padding-left: 12px; padding-right: 12px; gap: 8px; }
    #pageTitle { font-size: 16px; }
    .border-glow-card { padding: 32px 24px; margin: 20px; max-width: 100%; }
    .sidebar-item { min-height: 44px; }
}

@media (max-width: 480px) {
    .border-glow-card { padding: 24px 16px; margin: 12px; }
    #loginPage .brand-icon { font-size: 2.5rem; }
    #loginPage h1 { font-size: 20px; }
}

@keyframes typingPulse {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 1; }
}

.typing-indicator {
    display: inline-flex;
    gap: 4px;
    padding: 8px 12px;
    background: var(--bg-input);
    border-radius: 12px;
}
.typing-indicator span {
    width: 8px;
    height: 8px;
    background: var(--text-muted);
    border-radius: 50%;
    animation: typingPulse 1.2s ease-in-out infinite;
}
.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

.fade-in { animation: fadeInUp 0.4s ease forwards; }
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.number-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 16px;
    font-size: 12px;
    font-weight: 500;
    margin: 2px;
}
.number-tag.valid { background: rgba(34, 197, 94, 0.15); color: #22c55e; border: 1px solid rgba(34, 197, 94, 0.2); }
.number-tag.invalid { background: rgba(239, 68, 68, 0.15); color: #ef4444; border: 1px solid rgba(239, 68, 68, 0.2); }
.number-tag.pending { background: rgba(234, 179, 8, 0.15); color: #eab308; border: 1px solid rgba(234, 179, 8, 0.2); }

.instance-card {
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
    border: 1px solid var(--border-color);
}
.instance-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--glow);
    border-color: var(--brand);
}
.status-dot, .instance-card .status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}
.status-dot.online, .instance-card .status-dot.online { background: #22c55e; }
.status-dot.offline, .instance-card .status-dot.offline { background: #ef4444; }
.status-dot.connecting, .instance-card .status-dot.connecting { background: #eab308; animation: pulse 1.5s infinite; }

/* girar ícones tipo loader (substitui o antigo fa-spin do Font Awesome) */
.spin-icon { animation: spin-icon-rotate 1s linear infinite; display: inline-block; }
@keyframes spin-icon-rotate { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

.latency-bar {
    height: 3px;
    border-radius: 2px;
    background: var(--border-color);
    overflow: hidden;
    margin-top: 4px;
}
.latency-bar .fill {
    height: 100%;
    border-radius: 2px;
    transition: width 0.5s ease;
}
.latency-bar .fill.low { background: #22c55e; }
.latency-bar .fill.medium { background: #eab308; }
.latency-bar .fill.high { background: #ef4444; }

.notification-bell {
    position: relative;
    cursor: pointer;
}
.notification-bell .badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #ef4444;
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}
.notification-bell .badge.hidden { display: none; }
.notification-bell.pulse { animation: bellPulse 2s ease-in-out infinite; }

@keyframes bellPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.notifications-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    width: 320px;
    max-height: 400px;
    overflow-y: auto;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: var(--shadow);
    padding: 8px 0;
    z-index: 999;
    display: none;
}
.notifications-dropdown.open { display: block; }
.notifications-dropdown .notif-item {
    padding: 10px 16px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: background 0.2s;
}
.notifications-dropdown .notif-item:hover { background: var(--hover-bg); }
.notifications-dropdown .notif-item .time { font-size: 10px; color: var(--text-muted); }

/* ============================================
   ESTILOS DA NOVA TELA DE LOGIN (DECRYPTED + DITHER + BORDER GLOW) - OTIMIZADOS
   ============================================ */

#intro-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #000;
    z-index: 10;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    transition: opacity 0.8s ease;
    cursor: pointer;
}

.intro-text {
    font-size: clamp(24px, 6vw, 48px);
    font-weight: 800;
    letter-spacing: 4px;
    text-align: center;
    text-transform: uppercase;
}

.intro-hint {
    position: absolute;
    bottom: 40px;
    font-size: 12px;
    color: #666;
    letter-spacing: 1px;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 1; }
}

#dither-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    opacity: 0;
    transition: opacity 1.2s ease;
    pointer-events: none;
}

.ui-layer {
    position: fixed;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    padding: 24px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 1.2s ease;
}

/* BORDER GLOW CARD - com desempenho otimizado */
.border-glow-card {
    --edge-proximity: 0;
    --cursor-angle: 45deg;
    --edge-sensitivity: 30;
    --color-sensitivity: calc(var(--edge-sensitivity) + 20);
    --border-radius: 28px;
    --glow-padding: 40px;
    --cone-spread: 25;

    position: relative;
    width: 100%;
    max-width: 360px;
    padding: 32px 24px;
    border-radius: var(--border-radius);
    isolation: isolate;
    transform: translate3d(0, 20px, 0.01px);
    display: grid;
    border: 1px solid rgb(255 255 255 / 15%);
    background: var(--card-bg, #120F17);
    overflow: visible;
    pointer-events: auto;
    transition: transform 1.2s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s;
    contain: layout paint;
    box-shadow:
        rgba(0, 0, 0, 0.1) 0px 1px 2px,
        rgba(0, 0, 0, 0.1) 0px 2px 4px,
        rgba(0, 0, 0, 0.1) 0px 4px 8px,
        rgba(0, 0, 0, 0.1) 0px 8px 16px,
        rgba(0, 0, 0, 0.1) 0px 16px 32px,
        rgba(0, 0, 0, 0.1) 0px 32px 64px;
}

.border-glow-card::before,
.border-glow-card::after,
.border-glow-card > .edge-light {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    transition: opacity 0.25s ease-out;
    z-index: -1;
}

.border-glow-card:not(:hover):not(.sweep-active)::before,
.border-glow-card:not(:hover):not(.sweep-active)::after,
.border-glow-card:not(:hover):not(.sweep-active) > .edge-light {
    opacity: 0;
    transition: opacity 0.75s ease-in-out;
}

.border-glow-card::before {
    border: 1px solid transparent;
    background:
        linear-gradient(var(--card-bg, #120F17) 0 100%) padding-box,
        linear-gradient(rgb(255 255 255 / 0%) 0% 100%) border-box,
        var(--gradient-one) border-box,
        var(--gradient-two) border-box,
        var(--gradient-three) border-box,
        var(--gradient-four) border-box,
        var(--gradient-five) border-box,
        var(--gradient-six) border-box,
        var(--gradient-seven) border-box,
        var(--gradient-base) border-box;

    opacity: calc((var(--edge-proximity) - var(--color-sensitivity)) / (100 - var(--color-sensitivity)));

    mask-image:
        conic-gradient(
          from var(--cursor-angle) at center,
          black calc(var(--cone-spread) * 1%),
          transparent calc((var(--cone-spread) + 15) * 1%),
          transparent calc((100 - var(--cone-spread) - 15) * 1%),
          black calc((100 - var(--cone-spread)) * 1%)
        );
}

.border-glow-card::after {
    border: 1px solid transparent;
    background:
        var(--gradient-one) padding-box,
        var(--gradient-two) padding-box,
        var(--gradient-three) padding-box,
        var(--gradient-four) padding-box,
        var(--gradient-five) padding-box,
        var(--gradient-six) padding-box,
        var(--gradient-seven) padding-box,
        var(--gradient-base) padding-box;

    mask-image:
        linear-gradient(to bottom, black, black),
        radial-gradient(ellipse at 50% 50%, black 40%, transparent 65%),
        radial-gradient(ellipse at 66% 66%, black 5%, transparent 40%),
        radial-gradient(ellipse at 33% 33%, black 5%, transparent 40%),
        radial-gradient(ellipse at 66% 33%, black 5%, transparent 40%),
        radial-gradient(ellipse at 33% 66%, black 5%, transparent 40%),
        conic-gradient(from var(--cursor-angle) at center, transparent 5%, black 15%, black 85%, transparent 95%);

    mask-composite: subtract, add, add, add, add, add;
    opacity: calc(0.5 * (var(--edge-proximity) - var(--color-sensitivity)) / (100 - var(--color-sensitivity)));
    mix-blend-mode: soft-light;
}

.border-glow-card > .edge-light {
    inset: calc(var(--glow-padding) * -1);
    pointer-events: none;
    z-index: 1;

    mask-image:
        conic-gradient(
          from var(--cursor-angle) at center, black 2.5%, transparent 10%, transparent 90%, black 97.5%
        );

    opacity: calc((var(--edge-proximity) - var(--edge-sensitivity)) / (100 - var(--edge-sensitivity)));
    mix-blend-mode: plus-lighter;
}

.border-glow-card > .edge-light::before {
    content: "";
    position: absolute;
    inset: var(--glow-padding);
    border-radius: inherit;
    box-shadow:
        inset 0 0 0 1px var(--glow-color-0),
        inset 0 0 1px 0 var(--glow-color-60),
        inset 0 0 3px 0 var(--glow-color-50),
        inset 0 0 6px 0 var(--glow-color-40),
        inset 0 0 15px 0 var(--glow-color-30),
        inset 0 0 25px 2px var(--glow-color-20),
        inset 0 0 50px 2px var(--glow-color-10),
        0 0 1px 0 var(--glow-color-60),
        0 0 3px 0 var(--glow-color-50),
        0 0 6px 0 var(--glow-color-40),
        0 0 15px 0 var(--glow-color-30),
        0 0 25px 2px var(--glow-color-20),
        0 0 50px 2px var(--glow-color-10);
}

.border-glow-inner {
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 2;
}

.border-glow-inner .badge {
    display: inline-block;
    background: #fff;
    color: #000;
    font-size: 10px;
    font-weight: bold;
    padding: 4px 10px;
    border-radius: 12px;
    margin-bottom: 16px;
    letter-spacing: 1px;
    width: fit-content;
}

.border-glow-inner h2 {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 8px;
    letter-spacing: -0.5px;
    line-height: 1.2;
    color: #fff;
}

.border-glow-inner p {
    font-size: 15px;
    color: #a0a0a0;
    margin-bottom: 24px;
}

.border-glow-inner .input-group {
    margin-bottom: 16px;
}

.border-glow-inner .input-group input {
    width: 100%;
    padding: 14px 16px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    color: #fff;
    font-size: 15px;
    outline: none;
    transition: background 0.2s ease, border-color 0.2s ease;
}

.border-glow-inner .input-group input:focus {
    border-color: rgba(255, 255, 255, 0.5);
    background: rgba(255, 255, 255, 0.1);
}

.border-glow-inner .actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

.border-glow-inner .btn {
    flex: 1;
    padding: 14px;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    transition: opacity 0.2s ease;
    border: none;
}

.border-glow-inner .btn-primary {
    background: #fff;
    color: #000;
}

.border-glow-inner .btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.border-glow-inner .btn:active {
    opacity: 0.7;
}

.encrypted { color: #444; }
.revealed { color: #fff; }