/* ============================================
   Automação de Planilhas — Lucari Digital
   Design System & Styles
   ============================================ */

/* --- Design Tokens --- */
:root {
    --bg-primary: #0a0b0f;
    --bg-secondary: #111318;
    --bg-elevated: #16181e;
    --bg-surface: rgba(255, 255, 255, 0.03);

    --border-subtle: rgba(255, 255, 255, 0.06);
    --border-default: rgba(255, 255, 255, 0.1);
    --border-active: rgba(255, 255, 255, 0.2);

    --text-primary: #f0f0f5;
    --text-secondary: #8b8d98;
    --text-tertiary: #5c5e6a;
    --text-inverse: #0a0b0f;

    --accent-primary: #6366f1;
    --accent-primary-hover: #818cf8;
    --accent-primary-subtle: rgba(99, 102, 241, 0.12);
    --accent-primary-glow: rgba(99, 102, 241, 0.3);

    --accent-green: #22c55e;
    --accent-green-subtle: rgba(34, 197, 94, 0.12);
    --accent-green-glow: rgba(34, 197, 94, 0.3);

    --accent-orange: #f59e0b;
    --accent-orange-subtle: rgba(245, 158, 11, 0.12);

    --accent-red: #ef4444;
    --accent-red-subtle: rgba(239, 68, 68, 0.12);

    --accent-cyan: #06b6d4;
    --accent-google: #4285f4;
    --accent-google-subtle: rgba(66, 133, 244, 0.12);
    --accent-google-glow: rgba(66, 133, 244, 0.3);
    --accent-cyan-subtle: rgba(6, 182, 212, 0.12);

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 30px var(--accent-primary-glow);

    --sidebar-width: 260px;
    --header-height: 60px;

    --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
    --transition-fast: 150ms var(--ease-out);
    --transition-normal: 250ms var(--ease-out);
    --transition-slow: 400ms var(--ease-out);
}

/* --- Reset & Base --- */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    overflow-x: hidden;
    min-height: 100vh;
}

/* --- Ambient Background --- */
.ambient-bg {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
}

.orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(100px);
    opacity: 0.4;
}

.orb-1 {
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(99, 102, 241, 0.2) 0%, transparent 70%);
    top: -200px;
    right: -100px;
    animation: float-orb 20s ease-in-out infinite;
}

.orb-2 {
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(6, 182, 212, 0.15) 0%, transparent 70%);
    bottom: -150px;
    left: -100px;
    animation: float-orb 25s ease-in-out infinite reverse;
}

.orb-3 {
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, rgba(99, 102, 241, 0.1) 0%, transparent 70%);
    top: 50%;
    left: 40%;
    animation: float-orb 30s ease-in-out infinite;
}

@keyframes float-orb {

    0%,
    100% {
        transform: translate(0, 0) scale(1);
    }

    25% {
        transform: translate(30px, -20px) scale(1.05);
    }

    50% {
        transform: translate(-20px, 30px) scale(0.95);
    }

    75% {
        transform: translate(20px, 20px) scale(1.02);
    }
}

/* --- Sidebar --- */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    z-index: 200;
    transition: transform var(--transition-normal);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 24px 20px;
    border-bottom: 1px solid var(--border-subtle);
}

.brand-icon {
    width: 42px;
    height: 42px;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, var(--accent-primary), #4f46e5);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    flex-shrink: 0;
    box-shadow: 0 4px 12px var(--accent-primary-glow);
}

.brand-text h1 {
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text-primary);
    line-height: 1.2;
}

.brand-text span {
    font-size: 0.72rem;
    color: var(--text-secondary);
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: var(--transition-fast);
    position: relative;
}

.nav-item:hover {
    color: var(--text-primary);
    background: var(--bg-surface);
}

.nav-item.active {
    color: var(--accent-primary-hover);
    background: var(--accent-primary-subtle);
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 20px;
    border-radius: 0 4px 4px 0;
    background: var(--accent-primary);
}

.nav-group-label {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-tertiary);
    padding: 16px 14px 6px;
    margin-top: 8px;
}

.nav-group-label:first-child {
    margin-top: 0;
    padding-top: 4px;
}

.nav-app-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
    position: absolute;
    left: 4px;
    top: 50%;
    transform: translateY(-50%);
}

.dot-automacao { background: var(--accent-cyan); }
.dot-sdr { background: var(--accent-green); }
.dot-calc { background: var(--accent-primary); }
.dot-relatorio { background: var(--accent-orange); }
.dot-keywords { background: var(--accent-google); }

.nav-app-automacao,
.nav-app-keywords,
.nav-app-sdr,
.nav-app-calc,
.nav-app-relatorio {
    padding-left: 20px;
}


/* Tintim submenu group */
.nav-group-parent {
    position: relative;
}

.nav-app-tintim {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    border-radius: 8px;
    transition: all 0.15s ease;
    cursor: pointer;
    position: relative;
}

.nav-app-tintim:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.nav-app-tintim.open {
    color: var(--text-primary);
}

.nav-chevron {
    margin-left: auto;
    transition: transform 0.2s ease;
    opacity: 0.4;
    flex-shrink: 0;
}

.nav-app-tintim.open .nav-chevron {
    transform: rotate(180deg);
    opacity: 0.7;
}

.nav-submenu {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.2s ease;
}

.nav-submenu.open {
    max-height: 200px;
}

.nav-sub-item {
    padding-left: 34px !important;
    font-size: 12.5px !important;
}

.nav-sub-item .nav-app-dot {
    left: 20px;
}
.sidebar-footer {
    padding: 16px 16px 20px;
    border-top: 1px solid var(--border-subtle);
}

.sidebar-status-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-radius: var(--radius-md);
    background: var(--bg-surface);
}

.sidebar-status-label {
    font-size: 0.72rem;
    color: var(--text-tertiary);
    margin-left: auto;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
    background: var(--text-tertiary);
}

.status-dot.online {
    background: var(--accent-green);
    box-shadow: 0 0 8px var(--accent-green-glow);
    animation: pulse-dot 2.5s ease-in-out infinite;
}

.status-dot.offline {
    background: var(--accent-red);
    box-shadow: 0 0 8px rgba(239, 68, 68, 0.3);
}

.status-dot.warning {
    background: #F59E0B;
    box-shadow: 0 0 8px rgba(245, 158, 11, 0.3);
    animation: pulse-dot 2.5s ease-in-out infinite;
}

.server-status {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-md);
    background: var(--bg-surface);
}

.status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.status-indicator.online {
    background: var(--accent-green);
    box-shadow: 0 0 8px var(--accent-green-glow);
    animation: pulse-dot 2.5s ease-in-out infinite;
}

.status-indicator.offline {
    background: var(--accent-red);
    box-shadow: 0 0 8px rgba(239, 68, 68, 0.3);
}

@keyframes pulse-dot {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

.status-info {
    display: flex;
    flex-direction: column;
}

.status-label {
    font-size: 0.7rem;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.status-value {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--accent-green);
}

/* --- Mobile Header --- */
.mobile-header {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-subtle);
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    z-index: 150;
}

.hamburger {
    background: none;
    border: none;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 5px;
    padding: 8px;
}

.hamburger span {
    display: block;
    width: 22px;
    height: 2px;
    background: var(--text-primary);
    border-radius: 2px;
    transition: var(--transition-fast);
}

.mobile-title {
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.mobile-status {
    padding: 8px;
}

/* --- Main Content --- */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    position: relative;
    z-index: 1;
}

.page-section {
    display: none;
    padding: 32px 40px;
    max-width: 100%;
    /* Permite usar a largura total disponível */
    animation: page-enter 0.4s var(--ease-out);
}

.page-section.active {
    display: block;
}

@keyframes page-enter {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 28px;
}

.page-title {
    font-size: 1.65rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    margin-bottom: 4px;
}

.page-subtitle {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.badge {
    font-size: 0.68rem;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 20px;
    background: var(--accent-orange-subtle);
    color: var(--accent-orange);
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

/* --- Webhook Banner --- */
.webhook-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    margin-bottom: 24px;
    gap: 16px;
    flex-wrap: wrap;
}

.webhook-banner-content {
    display: flex;
    align-items: center;
    gap: 14px;
}

.webhook-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    background: var(--accent-primary-subtle);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent-primary);
    flex-shrink: 0;
}

.webhook-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    display: block;
    margin-bottom: 2px;
}

.webhook-url {
    font-size: 0.88rem;
    font-family: 'SF Mono', 'JetBrains Mono', 'Fira Code', monospace;
    color: var(--accent-primary-hover);
    background: transparent;
    cursor: pointer;
    user-select: all;
}

.btn-copy {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: var(--accent-primary-subtle);
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: var(--radius-sm);
    color: var(--accent-primary-hover);
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition-fast);
    white-space: nowrap;
}

.btn-copy:hover {
    background: rgba(99, 102, 241, 0.2);
}

.btn-copy.copied {
    background: var(--accent-green-subtle);
    border-color: rgba(34, 197, 94, 0.2);
    color: var(--accent-green);
}

/* --- Period Selector --- */
.period-selector {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 24px;
}

.period-pills {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.period-pill,
.clients-period-pill {
    padding: 7px 16px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-default);
    border-radius: 20px;
    color: var(--text-secondary);
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition-fast);
    font-family: inherit;
    white-space: nowrap;
}

.period-pill:hover,
.clients-period-pill:hover {
    color: var(--text-primary);
    border-color: var(--border-active);
    background: var(--bg-surface);
}

.period-pill.active,
.clients-period-pill.active {
    background: var(--accent-primary-subtle);
    border-color: var(--accent-primary);
    color: var(--accent-primary-hover);
}

.period-custom-range {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.period-range-sep {
    font-size: 0.82rem;
    color: var(--text-tertiary);
}

.period-date-input {
    padding: 8px 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.85rem;
    transition: border-color 0.2s, box-shadow 0.2s;
    color-scheme: dark;
}

.period-date-input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--accent-primary-subtle);
}

@media (max-width: 768px) {
    .period-pills {
        gap: 4px;
    }

    .period-pill,
    .clients-period-pill {
        padding: 6px 12px;
        font-size: 0.75rem;
    }

    .period-custom-range {
        flex-direction: column;
        align-items: stretch;
    }

    .period-range-sep {
        text-align: center;
    }
}


/* Dashboard overview period pills (mirrors .period-pill) */
.dashboard-period-pill {
    padding: 7px 16px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-default);
    border-radius: 20px;
    color: var(--text-secondary);
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition-fast);
    font-family: inherit;
    white-space: nowrap;
}

.dashboard-period-pill:hover {
    color: var(--text-primary);
    border-color: var(--border-active);
    background: var(--bg-surface);
}

.dashboard-period-pill.active {
    background: var(--accent-primary-subtle);
    border-color: var(--accent-primary);
    color: var(--accent-primary-hover);
}

@media (max-width: 768px) {
    .dashboard-period-pill {
        padding: 6px 12px;
        font-size: 0.75rem;
    }
}

/* --- Stats --- */
/* --- Stats (New Grid) --- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 24px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 20px;
    transition: var(--transition-normal);
    position: relative;
    overflow: hidden;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
    border-color: var(--accent-primary-subtle);
}

.stat-icon {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    flex-shrink: 0;
    background: var(--bg-surface);
}

.stat-icon-clients {
    color: var(--accent-primary);
    background: var(--accent-primary-subtle);
}

.stat-icon-status {
    color: var(--accent-green);
    background: var(--accent-green-subtle);
}

.stat-icon-uptime {
    color: var(--accent-cyan);
    background: var(--accent-cyan-subtle);
}

.stat-icon-webhook {
    color: var(--accent-orange);
    background: var(--accent-orange-subtle);
}

.stat-data {
    display: flex;
    flex-direction: column;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.1;
    color: var(--text-primary);
    margin-bottom: 4px;
    font-variant-numeric: tabular-nums;
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* --- Cards --- */
.card {
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 20px;
    border-bottom: 1px solid var(--border-subtle);
}

.card-header h3 {
    font-size: 0.95rem;
    font-weight: 600;
}

.card-body {
    padding: 16px 20px;
}

.dashboard-grid {
    display: grid;
    /* Aumenta a largura mínima da coluna lateral para dar mais espaço ao widget */
    grid-template-columns: minmax(380px, 420px) 1fr;
    gap: 24px;
    align-items: start;
    margin-bottom: 40px;
}

@media (max-width: 1100px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .overview-grid {
        grid-template-columns: 1fr;
    }
}

/* --- Apps Overview --- */
.apps-overview {
    margin-top: 32px;
}

.apps-overview .section-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 16px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.apps-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.app-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    cursor: pointer;
    transition: var(--transition-normal);
}

.app-card:hover {
    transform: translateY(-2px);
    border-color: var(--border-default);
    box-shadow: var(--shadow-md);
}

.app-card-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.app-card-icon.sdr {
    background: var(--accent-green-subtle);
    color: var(--accent-green);
}

.app-card-icon.calc {
    background: var(--accent-primary-subtle);
    color: var(--accent-primary);
}

.app-card-icon.relatorio {
    background: var(--accent-orange-subtle);
    color: var(--accent-orange);
}

.app-card-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    min-width: 0;
}

.app-card-name {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
}

.app-card-stat {
    font-size: 0.75rem;
    color: var(--text-tertiary);
}

.app-card-arrow {
    font-size: 1.1rem;
    color: var(--text-tertiary);
    flex-shrink: 0;
    transition: var(--transition-fast);
}

.app-card:hover .app-card-arrow {
    color: var(--text-secondary);
    transform: translateX(2px);
}

/* --- App Context Bar --- */
.app-context-bar {
    padding: 8px 20px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-secondary);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-subtle);
    position: sticky;
    top: 0;
    z-index: 10;
}

.app-context-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
}

.app-context-bar.ctx-automacao .app-context-dot,
.app-context-bar.ctx-clients .app-context-dot,
.app-context-bar.ctx-logs .app-context-dot,
.app-context-bar.ctx-alerts .app-context-dot { background: var(--accent-cyan); }
.app-context-bar.ctx-sdr .app-context-dot { background: var(--accent-green); }
.app-context-bar.ctx-calculadora .app-context-dot { background: var(--accent-primary); }
.app-context-bar.ctx-relatorio .app-context-dot { background: var(--accent-orange); }

/* --- Overview Grid (Dashboard Home) --- */
.overview-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

.overview-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 28px;
    cursor: pointer;
    transition: var(--transition-normal);
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.overview-card:hover {
    transform: translateY(-3px);
    border-color: var(--border-active);
    box-shadow: var(--shadow-lg);
}

.overview-card-header {
    display: flex;
    align-items: center;
    gap: 16px;
}

.overview-card-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.overview-card-icon.icon-automacao {
    background: var(--accent-cyan-subtle);
    color: var(--accent-cyan);
}

.overview-card-icon.icon-sdr {
    background: var(--accent-green-subtle);
    color: var(--accent-green);
}

.overview-card-icon.icon-calc {
    background: var(--accent-primary-subtle);
    color: var(--accent-primary);
}

.overview-card-icon.icon-relatorio {
    background: var(--accent-orange-subtle);
    color: var(--accent-orange);
}

.overview-card-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.overview-card-desc {
    font-size: 0.78rem;
    color: var(--text-tertiary);
}

.overview-card-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(70px, 1fr));
    gap: 12px;
}

.overview-stat {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.overview-stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
    line-height: 1.2;
}

.overview-stat-label {
    font-size: 0.7rem;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 500;
}

.overview-card-action {
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--accent-primary);
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: auto;
    transition: var(--transition-fast);
}

.overview-card:hover .overview-card-action {
    color: var(--accent-primary-hover);
}

.overview-card:hover .overview-card-action span {
    transform: translateX(3px);
    display: inline-block;
    transition: var(--transition-fast);
}

/* --- Automação Tab Bar --- */
.automacao-tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border-subtle);
    margin-bottom: 24px;
    padding: 0;
}

.automacao-tab {
    padding: 10px 16px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: var(--transition-fast);
    font-family: inherit;
    margin-bottom: -1px;
    white-space: nowrap;
}

.automacao-tab:hover {
    color: var(--text-primary);
}

.automacao-tab.active {
    color: var(--accent-primary-hover);
    border-bottom-color: var(--accent-primary);
}

.tab-badge {
    background: var(--accent-red);
    color: white;
    font-size: 0.6rem;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 8px;
    margin-left: 4px;
    min-width: 16px;
    text-align: center;
    display: inline-block;
    line-height: 1.3;
}

/* --- Status Dot Tooltips --- */
.status-dot-wrap {
    position: relative;
    display: inline-flex;
    cursor: default;
}

.status-dot-wrap::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-elevated);
    color: var(--text-primary);
    padding: 5px 10px;
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 500;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s ease;
    border: 1px solid var(--border-default);
    box-shadow: var(--shadow-md);
    z-index: 50;
}

.status-dot-wrap:hover::after {
    opacity: 1;
}

/* --- Dismiss Button --- */
.btn-dismiss {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    background: transparent;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    transition: var(--transition-fast);
    flex-shrink: 0;
}

.btn-dismiss:hover {
    background: var(--bg-surface);
    color: var(--text-primary);
}

/* --- Relatório Tab Content --- */
.rel-tab-content {
    display: none;
}

.rel-tab-content.active {
    display: block;
    animation: page-enter 0.3s var(--ease-out);
}

/* Relatório execution error display */
.exec-error-row {
    background: rgba(239, 68, 68, 0.04);
    border-left: 3px solid var(--error);
    padding-left: 12px;
    border-radius: 6px;
    margin-bottom: 4px;
}

.exec-error-detail {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    margin-top: 6px;
    padding: 8px 10px;
    background: rgba(239, 68, 68, 0.08);
    border-radius: 6px;
    font-size: 0.78rem;
    color: var(--error);
    line-height: 1.4;
    word-break: break-word;
}

.exec-error-detail svg {
    flex-shrink: 0;
    margin-top: 1px;
}

/* --- Activity List (New) --- */
.activity-feed {
    display: flex;
    flex-direction: column;
}

.activity-item {
    display: grid;
    grid-template-columns: 44px 1fr auto;
    gap: 20px;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-subtle);
    align-items: center;
    transition: background 0.2s;
}

.activity-item.clickable {
    grid-template-columns: 44px 1fr auto auto;
}

.activity-item:hover {
    background: var(--bg-surface);
}

.activity-item:last-child {
    border-bottom: none;
}

/* Integration alerts */
.alert-item { align-items: start; grid-template-columns: 44px 1fr; }
.alert-item .activity-content { display: flex; flex-direction: column; gap: 6px; }
.alert-item .alert-header { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; align-items: center; }
.alert-item .alert-ids { font-size: 0.82rem; color: var(--text-secondary); }
.alert-item .alert-ids code { background: var(--bg-surface); padding: 1px 6px; border-radius: 4px; font-size: 0.78rem; }
.alert-item .alert-reason { font-size: 0.82rem; color: var(--text-secondary); }
.alert-item .alert-detail { font-size: 0.85rem; color: var(--text-primary); line-height: 1.5; padding: 8px 10px; background: var(--bg-surface); border-radius: 6px; }
.alert-item .alert-actions { display: flex; gap: 8px; margin-top: 4px; }
.alert-item.alert-warning { border-left: 3px solid var(--success, #10b981); }
.alert-item.alert-critical { border-left: 3px solid var(--error, #ef4444); }
.alert-item.alert-dismissed { opacity: 0.55; }
.btn-small { padding: 4px 10px !important; font-size: 0.78rem !important; height: auto !important; display: inline-flex; align-items: center; gap: 4px; }

.activity-icon-wrapper {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    position: relative;
    background: var(--bg-surface);
}

.activity-content {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.activity-title {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    /* Permite que o badge caia para a próxima linha se apertar */
    gap: 8px;
    margin-bottom: 4px;
    line-height: 1.4;
}

.activity-subtitle {
    font-size: 0.85rem;
    color: var(--text-secondary);
    /* Removemos white-space: nowrap para permitir quebra suave se necessário, ou mantemos com ellipsis melhor controlado */
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    word-break: break-all;
}

.activity-meta {
    text-align: right;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
    min-width: 80px;
    /* Garante que a data não seja espremida */
}

.activity-time {
    font-size: 0.8rem;
    color: var(--text-tertiary);
    font-weight: 500;
    font-variant-numeric: tabular-nums;
}

/* Status Badges */
.badge-status {
    display: inline-flex;
    align-items: center;
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 0.65rem;
    /* Um pouco menor para caber melhor */
    line-height: 1;
    font-weight: 700;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    flex-shrink: 0;
    /* Impede que o badge seja esmagado */
}

.badge-new {
    background: rgba(34, 197, 94, 0.15);
    color: #4ade80;
    border: 1px solid rgba(34, 197, 94, 0.2);
}

.badge-update {
    background: rgba(99, 102, 241, 0.15);
    color: #818cf8;
    border: 1px solid rgba(99, 102, 241, 0.2);
}

.badge-sale {
    background: rgba(168, 85, 247, 0.15);
    color: #c084fc;
    border: 1px solid rgba(168, 85, 247, 0.2);
}

.badge-error {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

/* --- Flow Card --- */
.flow-card .flow-steps {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 28px 20px;
    flex-wrap: wrap;
}

.flow-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 16px 20px;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    min-width: 120px;
    transition: var(--transition-fast);
}

.flow-step:hover {
    border-color: var(--accent-primary);
    background: var(--accent-primary-subtle);
}

.flow-icon {
    font-size: 1.5rem;
}

.flow-step span {
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-align: center;
}

.flow-arrow {
    color: var(--text-tertiary);
    font-size: 1.2rem;
}

/* --- Button System --- */
.btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    background: var(--accent-primary);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-fast);
    box-shadow: 0 2px 8px var(--accent-primary-glow);
    font-family: inherit;
}

.btn-primary:hover {
    background: var(--accent-primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 16px var(--accent-primary-glow);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 16px;
    background: transparent;
    color: var(--text-primary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition-fast);
    font-family: inherit;
}

.btn-secondary:hover {
    background: var(--bg-surface);
    border-color: var(--border-active);
}

.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: var(--radius-sm);
    background: transparent;
    border: 1px solid var(--border-default);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition-fast);
}

.btn-icon:hover {
    background: var(--bg-surface);
    color: var(--text-primary);
    border-color: var(--border-active);
}

.btn-text {
    background: none;
    border: none;
    color: var(--accent-primary);
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    font-family: inherit;
    transition: var(--transition-fast);
}

.btn-text:hover {
    color: var(--accent-primary-hover);
}

/* --- Clients Grid --- */
.clients-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 16px;
}

.client-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 20px;
    transition: var(--transition-normal);
    position: relative;
    overflow: hidden;
}

.client-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--accent-primary), var(--accent-cyan));
    opacity: 0;
    transition: var(--transition-fast);
}

.client-card:hover {
    border-color: var(--border-active);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.client-card:hover::before {
    opacity: 1;
}

.client-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 14px;
}

.client-name-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.client-avatar {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    background: linear-gradient(135deg, var(--accent-primary), #4f46e5);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.client-name {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 2px;
}

.client-status {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 0.72rem;
    font-weight: 500;
    padding: 3px 8px;
    border-radius: 20px;
}

.client-status.active {
    color: var(--accent-green);
    background: var(--accent-green-subtle);
}

.client-status.inactive {
    color: var(--accent-red);
    background: var(--accent-red-subtle);
}

.client-meta {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 12px;
}

.client-meta-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.78rem;
    color: var(--text-secondary);
}

.client-meta-row svg {
    flex-shrink: 0;
    opacity: 0.5;
}

.client-meta-row code {
    font-family: 'SF Mono', 'JetBrains Mono', monospace;
    font-size: 0.72rem;
    background: rgba(255, 255, 255, 0.05);
    padding: 2px 6px;
    border-radius: 4px;
}

.client-card-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid var(--border-subtle);
}

.btn-client-delete {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: var(--accent-red-subtle);
    border: none;
    border-radius: var(--radius-sm);
    color: var(--accent-red);
    font-size: 0.78rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition-fast);
    font-family: inherit;
}

.btn-client-delete:hover {
    background: rgba(239, 68, 68, 0.2);
}

/* --- Client Card KPIs --- */
.client-card-kpis {
    display: flex;
    gap: 12px;
    margin-top: 14px;
    padding: 10px 0;
    border-top: 1px solid var(--border-subtle);
}

.client-kpi {
    flex: 1;
    text-align: center;
    min-width: 0;
}

.client-kpi-value {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

.client-kpi-label {
    font-size: 0.68rem;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-top: 2px;
}

/* --- Client Card Origins --- */
.client-card-origins {
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.client-origin-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.client-origin-label {
    font-size: 0.7rem;
    color: var(--text-secondary);
    min-width: 72px;
    flex-shrink: 0;
}

.client-origin-bar-track {
    flex: 1;
    height: 6px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 3px;
    overflow: hidden;
}

.client-origin-bar {
    height: 100%;
    border-radius: 3px;
    transition: width 0.4s ease;
    min-width: 2px;
}

.client-origin-bar.origin-meta {
    background: #818cf8;
}

.client-origin-bar.origin-google {
    background: #60a5fa;
}

.client-origin-bar.origin-whatsapp {
    background: #34d399;
}

.client-origin-bar.origin-other {
    background: #94a3b8;
}

.client-origin-count {
    font-size: 0.7rem;
    color: var(--text-tertiary);
    min-width: 24px;
    text-align: right;
}

.client-no-leads {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    font-style: italic;
    padding: 6px 0;
}

/* --- Client Source Badge --- */
.client-source-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.68rem;
    font-weight: 500;
}

.client-source-badge.source-tintim {
    background: rgba(59, 130, 246, 0.12);
    color: #60a5fa;
}

.client-source-badge.source-kommo {
    background: rgba(168, 85, 247, 0.12);
    color: #c084fc;
}

.client-source-badge.source-both {
    background: rgba(6, 182, 212, 0.12);
    color: #22d3ee;
}

/* --- Client Card Meta (updated) --- */
.client-card-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
    flex-wrap: wrap;
}

.client-sheet-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.72rem;
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.15s;
}

.client-sheet-link:hover {
    color: var(--accent-primary);
}

/* --- Client Card Footer (updated for 3 buttons) --- */
.client-card-footer .btn-details {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: var(--accent-primary-subtle);
    border: none;
    border-radius: var(--radius-sm);
    color: var(--accent-primary);
    font-size: 0.78rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition-fast);
    font-family: inherit;
}

.client-card-footer .btn-details:hover {
    background: rgba(99, 102, 241, 0.2);
}

@media (max-width: 768px) {
    .client-card-kpis {
        gap: 6px;
    }

    .client-kpi-value {
        font-size: 0.9rem;
    }

    .client-kpi-label {
        font-size: 0.62rem;
    }
}

/* --- Activity Feed --- */
.activity-feed {
    min-height: 120px;
}

.activity-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    text-align: center;
    gap: 10px;
}

.activity-empty p {
    color: var(--text-secondary);
    font-size: 0.88rem;
}

.activity-empty small {
    color: var(--text-tertiary);
    font-size: 0.78rem;
}



/* --- Log Stream --- */
.log-stream {
    min-height: 300px;
    max-height: 600px;
    overflow-y: auto;
}

/* --- Settings --- */
.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 16px;
}

.settings-list {
    padding: 8px 0;
}

.setting-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    border-bottom: 1px solid var(--border-subtle);
}

.setting-row:last-child {
    border-bottom: none;
}

.setting-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.setting-value {
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-primary);
}

code.setting-value {
    font-family: 'SF Mono', 'JetBrains Mono', monospace;
    font-size: 0.75rem;
    background: rgba(255, 255, 255, 0.05);
    padding: 3px 8px;
    border-radius: 4px;
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.settings-actions {
    padding: 8px 0;
}

.btn-action {
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    padding: 14px 20px;
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-primary);
    cursor: pointer;
    transition: var(--transition-fast);
    text-align: left;
    font-family: inherit;
}

.btn-action:last-child {
    border-bottom: none;
}

.btn-action:hover {
    background: var(--bg-surface);
}

.btn-action svg {
    color: var(--accent-primary);
    flex-shrink: 0;
}

.btn-action div {
    display: flex;
    flex-direction: column;
}

.btn-action span {
    font-size: 0.88rem;
    font-weight: 500;
}

.btn-action small {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    margin-top: 2px;
}

.shortcuts-list {
    padding: 12px 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.shortcut-item {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

kbd {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 26px;
    padding: 0 8px;
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* --- Modal --- */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    z-index: 1000;
    justify-content: center;
    align-items: flex-start;
    padding: 20px;
    overflow-y: auto;
}

.modal-overlay.visible {
    display: flex;
    animation: modal-fade-in 0.25s var(--ease-out);
}

@keyframes modal-fade-in {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.modal-content {
    width: 100%;
    max-width: 480px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    animation: modal-slide-in 0.3s var(--ease-out);
}

@keyframes modal-slide-in {
    from {
        opacity: 0;
        transform: translateY(16px) scale(0.97);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 24px 16px;
}

.modal-header h2 {
    font-size: 1.15rem;
    font-weight: 700;
}

.btn-modal-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition-fast);
}

.btn-modal-close:hover {
    background: var(--bg-surface);
    color: var(--text-primary);
}

.modal-content form {
    padding: 0 24px 24px;
}

.form-group {
    margin-bottom: 18px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-group input {
    width: 100%;
    padding: 11px 14px;
    background: var(--bg-primary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.88rem;
    font-family: inherit;
    transition: var(--transition-fast);
}

.form-group input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--accent-primary-subtle);
}

.form-group select {
    width: 100%;
    padding: 11px 14px;
    background: var(--bg-primary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.88rem;
    font-family: inherit;
    transition: var(--transition-fast);
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20width%3D%2224%22%20height%3D%2224%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22%238b8d98%22%20stroke-width%3D%222%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Cpolyline%20points%3D%226%209%2012%2015%2018%209%22%3E%3C%2Fpolyline%3E%3C%2Fsvg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    background-size: 16px;
    padding-right: 40px;
    text-overflow: ellipsis;
    white-space: nowrap;
    overflow: hidden;
    color-scheme: dark;
    cursor: pointer;
}

.form-group select:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--accent-primary-subtle);
}

.form-group select option {
    background: var(--bg-elevated);
    color: var(--text-primary);
}

.form-group input::placeholder {
    color: var(--text-tertiary);
}

.form-hint {
    display: block;
    margin-top: 5px;
    font-size: 0.72rem;
    color: var(--text-tertiary);
}

.form-hint strong {
    color: var(--accent-primary);
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 24px;
}

/* --- Empty State --- */
.empty-state {
    text-align: center;
    color: var(--text-tertiary);
    font-size: 0.88rem;
    padding: 32px 20px;
}

/* --- Toast System --- */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 18px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    color: var(--text-primary);
    font-size: 0.85rem;
    min-width: 280px;
    max-width: 400px;
    animation: toast-in 0.3s var(--ease-out);
}

.toast.hiding {
    animation: toast-out 0.25s var(--ease-out) forwards;
}

@keyframes toast-in {
    from {
        opacity: 0;
        transform: translateX(20px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes toast-out {
    to {
        opacity: 0;
        transform: translateX(20px);
    }
}

.toast .toast-icon {
    font-size: 1.1rem;
    flex-shrink: 0;
}

.toast.success {
    border-left: 3px solid var(--accent-green);
}

.toast.error {
    border-left: 3px solid var(--accent-red);
}

.toast.info {
    border-left: 3px solid var(--accent-primary);
}

/* --- Scrollbar --- */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-default);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--border-active);
}

/* --- Loading Skeleton --- */
.skeleton {
    background: linear-gradient(90deg, var(--bg-surface) 25%, rgba(255, 255, 255, 0.06) 50%, var(--bg-surface) 75%);
    background-size: 200% 100%;
    animation: skeleton-pulse 1.5s ease-in-out infinite;
    border-radius: var(--radius-sm);
}

@keyframes skeleton-pulse {
    from {
        background-position: 200% 0;
    }

    to {
        background-position: -200% 0;
    }
}

/* --- Responsive --- */
@media (max-width: 1024px) {
    .stats-row {
        grid-template-columns: repeat(2, 1fr);
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
        box-shadow: var(--shadow-lg);
    }

    .mobile-header {
        display: flex;
    }

    .main-content {
        margin-left: 0;
        padding-top: var(--header-height);
    }

    .page-section {
        padding: 20px 16px;
    }

    .stats-row {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    .stat-card {
        padding: 14px;
        gap: 10px;
    }

    .stat-icon {
        width: 40px;
        height: 40px;
    }

    .stat-value {
        font-size: 1.2rem;
    }

    .clients-grid {
        grid-template-columns: 1fr;
    }

    .settings-grid {
        grid-template-columns: 1fr;
    }

    .webhook-banner {
        flex-direction: column;
        align-items: flex-start;
    }

    .flow-arrow {
        display: none;
    }

    .flow-steps {
        gap: 8px !important;
    }

    .flow-step {
        min-width: 100px;
        padding: 12px 14px;
    }

    .toast-container {
        left: 16px;
        right: 16px;
        bottom: 16px;
    }

    .toast {
        min-width: auto;
        max-width: none;
    }

    .nav-group-label {
        font-size: 0.6rem;
        padding: 12px 14px 4px;
    }

    .apps-grid {
        grid-template-columns: 1fr;
    }

    .app-context-bar {
        padding: 6px 16px;
        font-size: 0.7rem;
    }

    .overview-grid {
        grid-template-columns: 1fr;
    }

    .automacao-tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .automacao-tabs::-webkit-scrollbar {
        display: none;
    }
}

@media (max-width: 480px) {
    .stats-row {
        grid-template-columns: 1fr;
    }

    .page-header {
        flex-direction: column;
        gap: 16px;
    }
}

/* Sidebar overlay for mobile */
.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 199;
}

.sidebar-backdrop.visible {
    display: block;
}

/* ============================================
   Webhook URL Edit Group (Settings)
   ============================================ */
.setting-row-stacked {
    flex-direction: column;
    align-items: flex-start !important;
    gap: 10px;
}

.webhook-edit-group {
    display: flex;
    gap: 8px;
    width: 100%;
    align-items: center;
}

.setting-input {
    flex: 1;
    padding: 10px 14px;
    background: var(--bg-primary);
    border: 1px solid var(--border-default);
    border-radius: 10px;
    color: var(--text-primary);
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 0.85rem;
    transition: border-color 0.2s, box-shadow 0.2s;
    min-width: 0;
}

.setting-input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--accent-primary-subtle);
}

.setting-input::placeholder {
    color: var(--text-tertiary);
}

.btn-sm {
    padding: 8px 14px !important;
    font-size: 0.8rem !important;
    gap: 4px;
}

.badge-sm {
    padding: 4px 10px;
    font-size: 0.75rem;
    border-radius: 8px;
    font-weight: 600;
}

/* Tooltip Customizado para Erros */
.error-icon-container {
    position: relative;
    display: inline-flex;
    align-items: center;
    margin-left: 6px;
    cursor: help;
    color: #ef4444;
}

.error-icon-container:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: white;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 0.75rem;
    white-space: nowrap;
    z-index: 100;
    margin-bottom: 6px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    pointer-events: none;
    max-width: 250px;
    white-space: normal;
    text-align: center;
    line-height: 1.4;
}

.error-icon-container:hover::before {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border-width: 6px;
    border-style: solid;
    border-color: #333 transparent transparent transparent;
    margin-bottom: -6px;
    /* Ajuste fino */
    z-index: 100;
}

/* --- Warning Status (Yellow) --- */
.badge-status.badge-warning {
    color: var(--accent-orange);
    background: var(--accent-orange-subtle);
    border: 1px solid rgba(245, 158, 11, 0.2);
}

.stat-icon-warning {
    color: var(--accent-orange);
    background: var(--accent-orange-subtle);
}

/* --- Sale Icon --- */
.stat-icon-sale {
    color: #a855f7;
    background: rgba(168, 85, 247, 0.12);
}

/* --- Error Icon --- */
.stat-icon-error {
    color: var(--accent-red);
    background: var(--accent-red-subtle);
}

/* --- Logs Toolbar (Toggle + Filters) --- */
.logs-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 12px;
    gap: 12px;
    flex-wrap: wrap;
}

.logs-toggle {
    display: inline-flex;
    background: var(--bg-primary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.toggle-btn {
    padding: 7px 16px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition-fast);
    font-family: inherit;
    white-space: nowrap;
}

.toggle-btn:hover {
    color: var(--text-primary);
    background: var(--bg-surface);
}

.toggle-btn.active {
    background: var(--accent-primary);
    color: white;
}

/* --- Client Select (Logs) --- */
.client-select {
    padding: 7px 32px 7px 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition-fast);
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L5 5L9 1' stroke='%238b8d98' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    max-width: 200px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.client-select:hover {
    color: var(--text-primary);
    border-color: var(--border-active);
}

.client-select:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--accent-primary-subtle);
    color: var(--text-primary);
}

.client-select option {
    background: var(--bg-elevated);
    color: var(--text-primary);
}

.logs-filters {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.filter-chip {
    padding: 5px 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border-default);
    border-radius: 20px;
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition-fast);
    font-family: inherit;
    white-space: nowrap;
}

.filter-chip:hover {
    color: var(--text-primary);
    border-color: var(--border-active);
}

.filter-chip.active {
    background: var(--accent-primary-subtle);
    border-color: var(--accent-primary);
    color: var(--accent-primary-hover);
}

/* --- Results Count --- */
.results-count {
    font-size: 0.78rem;
    color: var(--text-tertiary);
    font-weight: 500;
}

/* --- Client Leads Count (Dashboard preview) --- */
.client-leads-count {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    min-width: 50px;
}

.leads-count-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--accent-green);
    line-height: 1;
    font-variant-numeric: tabular-nums;
}

.leads-count-label {
    font-size: 0.6rem;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    font-weight: 500;
}

/* --- Badge Recovered --- */
.badge-recovered {
    background: var(--accent-orange-subtle);
    color: var(--accent-orange);
    border: 1px solid rgba(245, 158, 11, 0.2);
}

/* --- Origin Badges --- */
.badge-origin-meta {
    background: rgba(59, 130, 246, 0.15);
    color: #60a5fa;
    border: 1px solid rgba(59, 130, 246, 0.2);
}

.badge-origin-google {
    background: rgba(234, 179, 8, 0.15);
    color: #facc15;
    border: 1px solid rgba(234, 179, 8, 0.2);
}

.badge-origin-paid {
    background: rgba(6, 182, 212, 0.15);
    color: #22d3ee;
    border: 1px solid rgba(6, 182, 212, 0.2);
}

.badge-origin-default {
    background: rgba(148, 163, 184, 0.12);
    color: #94a3b8;
    border: 1px solid rgba(148, 163, 184, 0.15);
}

/* ============================================
   SDR de IA — Specific Styles
   ============================================ */

/* SDR Full-Page Modal */
.sdr-modal-fullpage {
    max-width: 680px;
    max-height: 90vh;
    overflow-y: auto;
}

.sdr-form-section-title {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-tertiary);
    margin: 20px 0 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-subtle);
}

.sdr-form-section-title:first-of-type {
    margin-top: 0;
}

/* SDR Form Grid */
.sdr-form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 16px;
}

.sdr-form-grid-3 {
    grid-template-columns: 1fr 1fr 1fr;
}

.sdr-form-grid .form-group textarea {
    width: 100%;
    padding: 11px 14px;
    background: var(--bg-primary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.88rem;
    font-family: inherit;
    resize: vertical;
    transition: var(--transition-fast);
}

.sdr-form-grid .form-group textarea:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--accent-primary-subtle);
}


@media (max-width: 600px) {
    .sdr-form-grid {
        grid-template-columns: 1fr;
    }
}

/* SDR Tabs */
.sdr-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border-subtle);
    padding-bottom: 0;
}

.sdr-tab {
    padding: 10px 20px;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-secondary);
    font-size: 0.88rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition-fast);
    font-family: inherit;
    margin-bottom: -1px;
}

.sdr-tab:hover {
    color: var(--text-primary);
}

.sdr-tab.active {
    color: var(--accent-primary-hover);
    border-bottom-color: var(--accent-primary);
}

.sdr-tab-content {
    display: none;
}

.sdr-tab-content.active {
    display: block;
    animation: page-enter 0.3s var(--ease-out);
}

/* SDR Chat Layout */
.sdr-chat-layout {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 16px;
    min-height: 500px;
}

@media (max-width: 900px) {
    .sdr-chat-layout {
        grid-template-columns: 1fr;
    }
}

.sdr-conversations-list-card .activity-feed {
    max-height: 500px;
    overflow-y: auto;
}

.sdr-conversations-list-card .activity-item {
    cursor: pointer;
}

.sdr-conversations-list-card .activity-item.selected {
    background: var(--accent-primary-subtle);
}

/* SDR Messages Container */
.sdr-messages-container {
    padding: 20px;
    max-height: 500px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Chat Bubbles */
.sdr-msg {
    max-width: 75%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 0.88rem;
    line-height: 1.5;
    word-wrap: break-word;
    position: relative;
}

.sdr-msg-incoming {
    align-self: flex-start;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-bottom-left-radius: 4px;
    color: var(--text-primary);
}

.sdr-msg-outgoing {
    align-self: flex-end;
    background: var(--accent-primary);
    color: white;
    border-bottom-right-radius: 4px;
}

.sdr-msg-time {
    font-size: 0.65rem;
    opacity: 0.6;
    margin-top: 4px;
    display: block;
}

.sdr-msg-outgoing .sdr-msg-time {
    text-align: right;
}

/* Lead Qualification Badges */
.badge-lead-hot {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.badge-lead-warm {
    background: rgba(245, 158, 11, 0.15);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.2);
}

.badge-lead-cold {
    background: rgba(59, 130, 246, 0.15);
    color: #60a5fa;
    border: 1px solid rgba(59, 130, 246, 0.2);
}

/* Pipeline Bar */
.pipeline-bar {
    display: flex;
    gap: 4px;
    min-height: 48px;
    border-radius: 8px;
    overflow: hidden;
}

.pipeline-segment {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 6px 8px;
    border-radius: 6px;
    min-width: 60px;
    transition: flex 0.3s ease;
}

.pipeline-count {
    font-size: 1.1rem;
    font-weight: 700;
    line-height: 1;
}

.pipeline-label {
    font-size: 0.6rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-secondary);
    margin-top: 2px;
}

.pipeline-empty {
    text-align: center;
    color: var(--text-tertiary);
    font-size: 0.8rem;
    padding: 8px;
}

/* Kanban Board */
.kanban-board {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    padding-bottom: 8px;
}

.kanban-column {
    min-width: 180px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.kanban-column-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    background: var(--bg-elevated);
    border-radius: 8px 8px 0 0;
}

.kanban-column-title {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
}

.kanban-column-count {
    font-size: 0.7rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 10px;
}

.kanban-column-body {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-top: none;
    border-radius: 0 0 8px 8px;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 60px;
}

.kanban-empty {
    text-align: center;
    color: var(--text-tertiary);
    font-size: 0.8rem;
    padding: 16px 0;
}

.kanban-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    padding: 10px 12px;
}

.kanban-card-name {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.kanban-card-phone {
    font-size: 0.7rem;
    color: var(--text-secondary);
}

.kanban-card-interest {
    font-size: 0.7rem;
    color: var(--text-tertiary);
    margin-top: 4px;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.kanban-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 6px;
    gap: 8px;
}

.kanban-card-date {
    font-size: 0.65rem;
    color: var(--text-tertiary);
    flex-shrink: 0;
}

/* Score Bar (mini, inline) */
.score-bar-mini {
    height: 4px;
    background: var(--bg-surface);
    border-radius: 2px;
    flex: 1;
    min-width: 40px;
    max-width: 80px;
    overflow: hidden;
}

.score-bar-fill {
    height: 100%;
    border-radius: 2px;
    transition: width 0.3s ease;
}

/* Stage Badge (inline) */
.badge-stage {
    font-size: 0.55rem;
    padding: 1px 6px;
    border-radius: 4px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-left: 6px;
    vertical-align: middle;
}

/* SDR KB Document Row */
.sdr-kb-doc {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border-subtle);
}

.sdr-kb-doc:last-child {
    border-bottom: none;
}

.sdr-kb-doc-info {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.sdr-kb-doc-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    background: var(--accent-cyan-subtle);
    color: var(--accent-cyan);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.sdr-kb-doc-name {
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sdr-kb-doc-meta {
    font-size: 0.75rem;
    color: var(--text-tertiary);
}

.sdr-kb-doc-actions {
    flex-shrink: 0;
}

/* ============================================================
   Alert Cards
   ============================================================ */

.alert-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    border-radius: 12px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    margin-bottom: 1rem;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}


@keyframes fadeOut {
    from {
        opacity: 1;
        transform: translateY(0);
    }
    to {
        opacity: 0;
        transform: translateY(-10px);
    }
}
.alert-card.alert-danger {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.1), rgba(239, 68, 68, 0.05));
    border-color: rgba(239, 68, 68, 0.3);
}

.alert-card.alert-warning {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.1), rgba(245, 158, 11, 0.05));
    border-color: rgba(245, 158, 11, 0.3);
}

.alert-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
    flex-shrink: 0;
}

.alert-warning .alert-icon {
    background: rgba(245, 158, 11, 0.2);
    color: #f59e0b;
}

.alert-content {
    flex: 1;
    min-width: 0;
}

.alert-title {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.alert-message {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.alert-meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-alert-action {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
    border: none;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.btn-alert-action:hover {
    background: rgba(239, 68, 68, 0.3);
    transform: translateY(-1px);
}

.btn-alert-action:active {
    transform: translateY(0);
}

.alert-warning .btn-alert-action {
    background: rgba(245, 158, 11, 0.2);
    color: #f59e0b;
}

.alert-warning .btn-alert-action:hover {
    background: rgba(245, 158, 11, 0.3);
}


/* ============================================
   Integration Alert Banner
   ============================================ */
.integration-alert {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: rgba(239, 68, 68, 0.08);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: 10px;
    margin-bottom: 16px;
    animation: alertPulse 2s ease-in-out infinite;
}

.integration-alert-icon {
    flex-shrink: 0;
    color: var(--accent-red, #ef4444);
}

.integration-alert-content {
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: 13px;
    color: var(--text-primary);
}

.integration-alert-content strong {
    color: var(--accent-red, #ef4444);
    font-weight: 600;
}

.integration-alert-content span {
    color: var(--text-secondary);
    font-size: 12px;
}

@keyframes alertPulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.85;
    }
}

/* ============================================
   ALERTS & TRAIL SYSTEM
   ============================================ */

.nav-badge {
    background: var(--accent-red, #ef4444);
    color: white;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 10px;
    margin-left: auto;
    min-width: 18px;
    text-align: center;
    line-height: 1.3;
}

.alerts-error-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.alert-error-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.875rem 1rem;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.06);
    cursor: pointer;
    transition: all 0.15s ease;
}

.alert-error-item:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.12);
}

.alert-error-item .alert-dismiss {
    opacity: 0;
    transition: opacity 0.15s ease;
}

.alert-error-item:hover .alert-dismiss {
    opacity: 1;
}

.alert-error-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

.alert-error-info {
    flex: 1;
    min-width: 0;
}

.alert-error-info .lead-name {
    font-weight: 500;
    font-size: 0.875rem;
    color: var(--text-primary, #f1f5f9);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.alert-error-info .error-detail {
    font-size: 0.75rem;
    color: var(--text-secondary, #94a3b8);
    margin-top: 2px;
}

.alert-error-info .error-step {
    font-size: 0.7rem;
    color: #ef4444;
    margin-top: 2px;
    font-weight: 500;
}

.alert-error-meta {
    text-align: right;
    flex-shrink: 0;
}

.alert-error-meta .error-time {
    font-size: 0.7rem;
    color: var(--text-secondary, #94a3b8);
}

.alert-error-meta .error-badge {
    display: inline-block;
    font-size: 0.6rem;
    font-weight: 600;
    text-transform: uppercase;
    padding: 2px 6px;
    border-radius: 4px;
    margin-top: 4px;
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

/* Trail Modal */
.trail-modal {
    max-width: 600px;
    width: 90vw;
}

.trail-timeline {
    position: relative;
    padding: 0.5rem 0;
}

.trail-step {
    display: flex;
    gap: 1rem;
    padding: 0.5rem 0;
    position: relative;
}

.trail-step-dot {
    position: relative;
    z-index: 1;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 0.7rem;
    font-weight: 700;
    color: white;
}

.trail-step-dot.ok {
    background: #22c55e;
}

.trail-step-dot.error {
    background: #ef4444;
}

.trail-step-dot.skipped {
    background: #64748b;
}

.trail-step-line {
    position: absolute;
    left: 13px;
    top: 36px;
    bottom: -8px;
    width: 2px;
    background: rgba(255, 255, 255, 0.08);
}

.trail-step:last-child .trail-step-line {
    display: none;
}

.trail-step-content {
    flex: 1;
    min-width: 0;
    padding-bottom: 0.75rem;
}

.trail-step-name {
    font-weight: 600;
    font-size: 0.8rem;
    color: var(--text-primary, #f1f5f9);
}

.trail-step-detail {
    font-size: 0.75rem;
    color: var(--text-secondary, #94a3b8);
    margin-top: 2px;
    word-break: break-word;
}

.trail-step-detail.error-detail {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.08);
    padding: 0.5rem;
    border-radius: 6px;
    margin-top: 4px;
}

.trail-step-time {
    font-size: 0.65rem;
    color: var(--text-muted, #64748b);
    margin-top: 2px;
}

/* --- User Management --- */
.users-list {
    padding: 0;
}

.user-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-subtle);
    transition: background var(--transition-fast);
}

.user-row:last-child {
    border-bottom: none;
}

.user-row:hover {
    background: var(--bg-surface);
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--accent-primary-subtle);
    color: var(--accent-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.user-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.user-name {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-primary);
}

.user-email {
    font-size: 0.8rem;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-meta {
    flex-shrink: 0;
}

.user-date {
    font-size: 0.75rem;
    color: var(--text-tertiary);
}

.user-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

@keyframes fadeOut {
    from { opacity: 1; transform: scale(1); }
    to { opacity: 0; transform: scale(0.95); }
}

@media (max-width: 768px) {
    .user-meta {
        display: none;
    }

    .user-row {
        padding: 0.75rem 1rem;
    }

    .user-actions {
        flex-shrink: 0;
    }
}

/* ============================================
   Automação — Origin Breakdown & Client Table
   ============================================ */

/* --- Origins Card --- */
.automacao-origins-card {
    margin-bottom: 24px;
}

.automacao-origins-summary {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.automacao-origins-summary strong {
    color: var(--text-primary);
    font-weight: 600;
}

.automacao-origins-sep {
    color: var(--text-tertiary);
}

.automacao-origin-bars {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.automacao-origin-row {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.automacao-origin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.automacao-origin-name {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 0.9rem;
}

.automacao-origin-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.automacao-origin-stats {
    display: flex;
    gap: 16px;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.automacao-origin-stats span strong {
    color: var(--text-primary);
}

.automacao-origin-bar-track {
    height: 8px;
    background: var(--bg-surface);
    border-radius: 4px;
    overflow: hidden;
}

.automacao-origin-bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.6s ease;
}

.automacao-origin-bar-fill.origin-meta { background: #6366f1; }
.automacao-origin-bar-fill.origin-google { background: #4285f4; }
.automacao-origin-bar-fill.origin-whatsapp { background: #22c55e; }
.automacao-origin-bar-fill.origin-other { background: var(--text-tertiary); }

.automacao-origin-dot.origin-meta { background: #6366f1; }
.automacao-origin-dot.origin-google { background: #4285f4; }
.automacao-origin-dot.origin-whatsapp { background: #22c55e; }
.automacao-origin-dot.origin-other { background: var(--text-tertiary); }

/* --- Client Performance Table --- */
.automacao-clients-card {
    margin-bottom: 24px;
}

.automacao-clients-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.automacao-clients-table thead th {
    text-align: left;
    padding: 12px 16px;
    font-weight: 600;
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 1px solid var(--border-subtle);
    white-space: nowrap;
}

.automacao-clients-table tbody tr {
    cursor: pointer;
    transition: background 0.15s ease;
}

.automacao-clients-table tbody tr:hover {
    background: var(--bg-surface);
}

.automacao-clients-table tbody td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-primary);
    vertical-align: middle;
}

.automacao-clients-table tbody tr:last-child td {
    border-bottom: none;
}

.automacao-table-empty {
    text-align: center;
    padding: 32px 16px !important;
    color: var(--text-secondary);
}

.automacao-client-name {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 500;
}

.automacao-client-avatar {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    background: var(--accent-primary-subtle);
    color: var(--accent-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    flex-shrink: 0;
}

/* Mini origin bars in table */
.automacao-mini-bars {
    display: flex;
    gap: 3px;
    height: 6px;
    border-radius: 3px;
    overflow: hidden;
    min-width: 80px;
    background: var(--bg-surface);
}

.automacao-mini-bar {
    height: 100%;
    border-radius: 3px;
    transition: width 0.4s ease;
}

.automacao-mini-bar.origin-meta { background: #6366f1; }
.automacao-mini-bar.origin-google { background: #4285f4; }
.automacao-mini-bar.origin-whatsapp { background: #22c55e; }
.automacao-mini-bar.origin-other { background: var(--text-tertiary); }

.automacao-conversion {
    font-weight: 600;
}

.automacao-revenue {
    font-variant-numeric: tabular-nums;
}

/* --- Expandable Client Row --- */
.automacao-expand-row td {
    padding: 0 !important;
    border-bottom: 1px solid var(--border-subtle);
}

.automacao-expand-row:hover {
    background: transparent !important;
}

.automacao-expand-content {
    overflow: hidden;
    max-height: 0;
    transition: max-height 0.35s ease, padding 0.35s ease;
    padding: 0 16px;
}

.automacao-expand-row.expanded .automacao-expand-content {
    max-height: 500px;
    padding: 16px;
}

.automacao-expand-grid {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.automacao-expand-card {
    flex: 1;
    min-width: 160px;
    padding: 14px 16px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
}

.automacao-expand-card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    font-weight: 600;
    font-size: 0.85rem;
}

.automacao-expand-card-stats {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.automacao-expand-card-stats strong {
    color: var(--text-primary);
}

.automacao-expand-card.origin-meta { border-color: rgba(99, 102, 241, 0.3); background: rgba(99, 102, 241, 0.05); }
.automacao-expand-card.origin-google { border-color: rgba(66, 133, 244, 0.3); background: rgba(66, 133, 244, 0.05); }
.automacao-expand-card.origin-whatsapp { border-color: rgba(34, 197, 94, 0.3); background: rgba(34, 197, 94, 0.05); }
.automacao-expand-card.origin-other { border-color: var(--border-default); background: var(--bg-surface); }

/* --- Client Details Origin Cards --- */
.client-origins-grid {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.client-origin-card {
    flex: 1;
    min-width: 140px;
    padding: 16px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
    text-align: center;
}

.client-origin-card .origin-label {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-weight: 600;
    font-size: 0.85rem;
    margin-bottom: 12px;
}

.client-origin-card .origin-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.1;
}

.client-origin-card .origin-pct {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

.client-origin-card .origin-detail {
    font-size: 0.78rem;
    color: var(--text-secondary);
    margin-top: 8px;
}

.client-origin-card.origin-meta { border-color: rgba(99, 102, 241, 0.3); background: rgba(99, 102, 241, 0.05); }
.client-origin-card.origin-google { border-color: rgba(66, 133, 244, 0.3); background: rgba(66, 133, 244, 0.05); }
.client-origin-card.origin-whatsapp { border-color: rgba(34, 197, 94, 0.3); background: rgba(34, 197, 94, 0.05); }
.client-origin-card.origin-other { border-color: var(--border-default); background: var(--bg-surface); }

/* --- Responsive --- */
@media (max-width: 768px) {
    .automacao-origins-summary {
        display: none;
    }

    .automacao-clients-table thead th:nth-child(5),
    .automacao-clients-table tbody td:nth-child(5) {
        display: none;
    }

    .automacao-expand-grid {
        flex-direction: column;
    }

    .client-origins-grid {
        flex-direction: column;
    }
}

/* ============================================
   Keywords Section (Palavras-Chave Google Ads)
   ============================================ */

.keywords-filters {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.keywords-client-select {
    background: var(--bg-elevated);
    border: 1px solid var(--border-default);
    color: var(--text-primary);
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-family: 'Inter', sans-serif;
    min-width: 180px;
}

.keywords-client-select:focus {
    outline: none;
    border-color: var(--accent-google);
}

.kw-custom-range {
    display: flex;
    align-items: center;
    gap: 8px;
}

.keywords-stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.kw-stat-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: border-color var(--transition-fast);
}

.kw-stat-card:hover {
    border-color: var(--accent-google);
}

.kw-stat-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-sm);
    background: var(--accent-google-subtle);
    color: var(--accent-google);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.kw-stat-data {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.kw-stat-value {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.kw-stat-label {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.kw-trend-chart {
    width: 100%;
    min-height: 200px;
}

.kw-trend-chart canvas {
    width: 100%;
}

/* Keywords Table */
.keywords-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.keywords-table thead th {
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-subtle);
    background: var(--bg-surface);
    white-space: nowrap;
}

.keywords-table tbody td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-primary);
}

.keywords-table tbody tr:last-child td {
    border-bottom: none;
}

.keywords-table tbody tr:hover {
    background: var(--bg-surface);
}

.kw-row-clickable {
    cursor: pointer;
}

.kw-row-clickable:hover {
    background: var(--accent-google-subtle) !important;
}

/* Keyword bar visual */
.kw-cell-bar {
    position: relative;
    display: flex;
    align-items: center;
    min-width: 200px;
}

.kw-bar {
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    height: 26px;
    background: var(--accent-google-subtle);
    border-radius: 4px;
    transition: width 0.4s var(--ease-out);
}

.kw-keyword-text {
    position: relative;
    z-index: 1;
    padding: 4px 8px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 300px;
}

/* Keyword Detail Modal */
#modal-keyword-detail {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

#modal-keyword-detail .modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 700px;
    max-height: 80vh;
    overflow-y: auto;
}

#modal-keyword-detail .modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-subtle);
}

#modal-keyword-detail .modal-header h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

#modal-keyword-detail .modal-body {
    padding: 20px 24px;
}

/* Active nav highlight for keywords */
.nav-app-keywords.active {
    background: var(--accent-google-subtle);
    color: var(--accent-google);
}

.nav-app-keywords.active .dot-keywords {
    box-shadow: 0 0 8px var(--accent-google-glow);
}

/* Context bar for keywords */
.ctx-keywords {
    border-left-color: var(--accent-google);
}

.ctx-keywords .app-context-dot {
    background: var(--accent-google);
}


/* Breakdown items */
.kw-breakdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
}

.kw-breakdown-item + .kw-breakdown-item {
    border-top: 1px solid rgba(255, 255, 255, 0.04);
}

.kw-breakdown-label {
    font-size: 13px;
    color: var(--text-secondary);
    min-width: 100px;
    white-space: nowrap;
}

.kw-breakdown-bar-bg {
    flex: 1;
    height: 6px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 3px;
    overflow: hidden;
}

.kw-breakdown-bar {
    height: 100%;
    background: var(--accent-google);
    border-radius: 3px;
    transition: width 0.3s ease;
}

.kw-breakdown-bar.kw-bar-location {
    background: var(--accent-purple, #a78bfa);
}

.kw-breakdown-pct {
    font-size: 12px;
    color: var(--text-tertiary);
    min-width: 32px;
    text-align: right;
}

/* Sortable headers */
.kw-sortable {
    cursor: pointer;
    user-select: none;
    position: relative;
    padding-right: 16px !important;
}

.kw-sortable:hover {
    color: var(--text-primary);
}

.kw-sortable::after {
    content: '';
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    border: 4px solid transparent;
    border-top-color: rgba(255, 255, 255, 0.2);
    margin-top: 2px;
}

.kw-sortable.kw-sort-desc::after {
    border-top-color: var(--accent-google);
}

.kw-sortable.kw-sort-asc::after {
    border-top-color: transparent;
    border-bottom-color: var(--accent-google);
    margin-top: -6px;
}

/* Responsive */
@media (max-width: 768px) {
    .keywords-stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .kw-breakdown-grid {
        grid-template-columns: 1fr !important;
    }
    .keywords-filters {
        flex-direction: column;
        align-items: stretch;
    }
    .kw-cell-bar {
        min-width: 120px;
    }
}

@media (max-width: 480px) {
    .keywords-stats-grid {
        grid-template-columns: 1fr;
    }
}

/* --- Data Table (Overview Client Summary) --- */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.data-table thead th {
    padding: 10px 20px;
    text-align: left;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-tertiary);
    border-bottom: 1px solid var(--border-subtle);
    white-space: nowrap;
}

.data-table tbody tr {
    border-bottom: 1px solid var(--border-subtle);
    transition: background var(--transition-fast);
}

.data-table tbody tr:last-child {
    border-bottom: none;
}

.data-table tbody tr:hover {
    background: var(--bg-surface);
}

.data-table tbody td {
    padding: 12px 20px;
    color: var(--text-primary);
    white-space: nowrap;
}

.data-table .client-avatar {
    background: var(--accent-primary-subtle);
    color: var(--accent-primary);
}

/* --- Card Title (shared) --- */
.card-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* --- Responsive: Overview Grid --- */
@media (max-width: 768px) {
    .data-table {
        font-size: 0.78rem;
    }
    .data-table thead th,
    .data-table tbody td {
        padding: 8px 12px;
    }
}


/* ============================================
   Schedule Cards & Toggle
   ============================================ */

.schedule-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 20px;
    margin-bottom: 16px;
    transition: border-color var(--transition-fast);
}

.schedule-card:hover {
    border-color: var(--border-default);
}

.schedule-card.schedule-disabled {
    opacity: 0.6;
}

.schedule-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.schedule-card-title {
    display: flex;
    align-items: center;
    gap: 12px;
}

.schedule-name {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.schedule-card-body {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.schedule-info-row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.schedule-label {
    min-width: 140px;
    color: var(--text-tertiary);
    font-weight: 500;
    flex-shrink: 0;
}

.schedule-last-run {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.schedule-detail {
    font-size: 0.8rem;
    color: var(--text-tertiary);
}

.schedule-error-detail {
    color: var(--accent-red);
}

.schedule-run-btn {
    white-space: nowrap;
}

.schedule-run-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Toggle Switch (iOS-style) */
.schedule-toggle {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}

.schedule-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.schedule-toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: 24px;
    transition: background var(--transition-fast), border-color var(--transition-fast);
}

.schedule-toggle-slider::before {
    content: '';
    position: absolute;
    height: 18px;
    width: 18px;
    left: 2px;
    bottom: 2px;
    background: var(--text-secondary);
    border-radius: 50%;
    transition: transform var(--transition-fast), background var(--transition-fast);
}

.schedule-toggle input:checked + .schedule-toggle-slider {
    background: var(--accent-green-subtle);
    border-color: var(--accent-green);
}

.schedule-toggle input:checked + .schedule-toggle-slider::before {
    transform: translateX(20px);
    background: var(--accent-green);
}

.schedule-toggle input:focus + .schedule-toggle-slider {
    box-shadow: 0 0 0 2px var(--accent-primary-subtle);
}

/* Badge variants */
.badge-success {
    background: var(--accent-green-subtle);
    color: var(--accent-green);
    font-size: 0.75rem;
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 500;
}

.badge-muted {
    background: var(--bg-surface);
    color: var(--text-tertiary);
    font-size: 0.75rem;
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 500;
}

/* Responsive */
@media (max-width: 768px) {
    .schedule-card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .schedule-info-row {
        flex-direction: column;
        gap: 4px;
    }

    .schedule-label {
        min-width: auto;
    }
}

/* Schedule editable fields */
.schedule-edit-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.schedule-select {
    background: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    padding: 6px 10px;
    font-size: 0.875rem;
    cursor: pointer;
    transition: border-color var(--transition-fast);
    appearance: auto;
}

.schedule-select:hover {
    border-color: var(--accent-primary);
}

.schedule-select:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px var(--accent-primary-subtle);
}

/* ============================================
   Sync Health Card
   ============================================ */

.sync-health-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-lg);
    padding: 16px 20px;
    margin-bottom: 16px;
}

.sync-health-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.sync-health-icon {
    color: var(--text-secondary);
}

.sync-health-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    flex: 1;
}

.sync-health-badge {
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}

.sync-health-badge.ok {
    background: rgba(52, 211, 153, 0.15);
    color: var(--accent-green);
}

.sync-health-badge.warning {
    background: rgba(245, 158, 11, 0.15);
    color: #F59E0B;
}

.sync-health-badge.error {
    background: rgba(239, 68, 68, 0.15);
    color: var(--accent-red);
}

.sync-health-body {
    display: flex;
    align-items: center;
    gap: 24px;
    flex-wrap: wrap;
}

.sync-health-stat {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sync-stat-label {
    font-size: 11px;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.sync-stat-value {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border-primary);
    color: var(--text-secondary);
    border-radius: var(--radius-md);
    padding: 6px 14px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.15s ease;
    margin-left: auto;
}

.btn-outline:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
    background: var(--accent-primary-subtle);
}

/* ============================================
   Sync Page — Tabela detalhada
   ============================================ */
.sync-table-wrap {
    background: var(--bg-surface);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.sync-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.sync-table thead th {
    background: var(--bg-tertiary);
    padding: 10px 14px;
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-primary);
    white-space: nowrap;
}

.sync-table tbody td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border-subtle, var(--border-primary));
    color: var(--text-primary);
}

.sync-table tbody tr:last-child td {
    border-bottom: none;
}

.sync-table tbody tr:hover {
    background: var(--bg-hover, rgba(255,255,255,0.02));
}

.sync-cell-client {
    font-weight: 600;
}

.sync-cell-num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.sync-cell-disc {
    font-weight: 700;
    color: var(--accent-red) !important;
}

.sync-cell-date {
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
}

.sync-badge {
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 10px;
    border-radius: 10px;
}

.sync-badge-ok {
    background: rgba(52, 211, 153, 0.15);
    color: var(--accent-green);
}

.sync-badge-warning {
    background: rgba(245, 158, 11, 0.15);
    color: #F59E0B;
}

.sync-badge-error {
    background: rgba(239, 68, 68, 0.15);
    color: var(--accent-red);
}

@media (max-width: 768px) {
    #sync-overview-stats > div {
        grid-template-columns: 1fr 1fr !important;
    }
    .sync-table-wrap {
        overflow-x: auto;
    }
}

/* SDR Toggle Row */
.sdr-toggle-row {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--text-primary);
    padding: 6px 0;
}
.sdr-toggle-row input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent-primary, #6366f1);
    cursor: pointer;
}

/* SDR Mini Stat */
.sdr-mini-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 12px;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    min-width: 60px;
}

/* SDR Table */
.sdr-table {
    border-collapse: collapse;
    font-size: 0.85rem;
}
.sdr-table th {
    text-align: left;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-tertiary);
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-subtle);
    font-weight: 600;
}
.sdr-table td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-subtle);
    vertical-align: middle;
}
.sdr-table tbody tr:hover {
    background: var(--bg-surface-hover, rgba(255,255,255,0.03));
}

/* Badge Status (reusable) */
.badge-status {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.72rem;
    font-weight: 600;
    white-space: nowrap;
}

/* Spin animation */
@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ============================================================
   Leads View — Stats, Filters, Table, Drag-Drop, Pagination
   ============================================================ */

/* Stats Cards Grid */
.leads-stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 20px;
}
@media (max-width: 768px) {
    .leads-stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}
.leads-stat-card {
    padding: 20px;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    transition: border-color 0.15s;
}
.leads-stat-card:hover {
    border-color: var(--border-color);
}
.leads-stat-card .stat-label {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-tertiary);
    margin-bottom: 6px;
}
.leads-stat-card .stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
}

/* Filter Row */
.leads-filter-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
}
.leads-search-wrap {
    position: relative;
    flex: 1;
    min-width: 200px;
}
.leads-search-wrap svg {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-tertiary);
    pointer-events: none;
}
.leads-search-wrap input {
    width: 100%;
    padding: 7px 10px 7px 32px;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    font-size: 0.8rem;
    color: var(--text-primary);
    outline: none;
    transition: border-color 0.15s;
}
.leads-search-wrap input:focus {
    border-color: var(--accent-primary, #6366f1);
    box-shadow: 0 0 0 2px rgba(99,102,241,0.15);
}
.leads-search-wrap input::placeholder {
    color: var(--text-tertiary);
}

/* View Toggle */
.leads-view-toggle {
    display: inline-flex;
    align-items: center;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    padding: 2px;
}
.leads-view-toggle button {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 10px;
    border-radius: 6px;
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text-tertiary);
    background: none;
    border: none;
    cursor: pointer;
    transition: all 0.15s;
}
.leads-view-toggle button:hover {
    color: var(--text-secondary);
}
.leads-view-toggle button.active {
    background: var(--bg-elevated);
    color: var(--text-primary);
}

/* Leads Table */
.leads-table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    background: var(--bg-surface);
}
.leads-table {
    width: 100%;
    border-collapse: collapse;
}
.leads-table thead tr {
    border-bottom: 1px solid var(--border-subtle);
}
.leads-table th {
    padding: 10px 14px;
    text-align: left;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-tertiary);
    white-space: nowrap;
}
.leads-table td {
    padding: 10px 14px;
    vertical-align: middle;
    font-size: 0.82rem;
}
.leads-table tbody tr {
    border-bottom: 1px solid rgba(255,255,255,0.04);
    cursor: pointer;
    transition: background 0.15s;
}
.leads-table tbody tr:hover {
    background: rgba(255,255,255,0.03);
}
.leads-table tbody tr:last-child {
    border-bottom: none;
}
.leads-table .lead-name {
    font-weight: 600;
    color: var(--text-primary);
}
.leads-table .lead-email {
    font-size: 0.72rem;
    color: var(--text-tertiary);
}
.leads-table .lead-phone {
    color: var(--text-secondary);
    font-size: 0.8rem;
}
.leads-table .lead-score-cell {
    display: flex;
    align-items: center;
    gap: 8px;
}
.leads-table .lead-score-num {
    font-family: ui-monospace, monospace;
    font-weight: 600;
    color: var(--text-secondary);
    min-width: 24px;
}
.leads-table .lead-score-bar {
    width: 80px;
    height: 5px;
    background: var(--bg-elevated);
    border-radius: 3px;
    overflow: hidden;
}
.leads-table .lead-score-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.3s;
}
.leads-table .lead-followup {
    color: var(--text-secondary);
    font-size: 0.8rem;
}
.leads-table .lead-date {
    color: var(--text-tertiary);
    font-size: 0.78rem;
}

/* Stage Badge (inline, colored) */
.badge-stage-inline {
    display: inline-flex;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.62rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.badge-stage-novo { background: rgba(99,102,241,0.1); color: #818cf8; }
.badge-stage-em_conversa { background: rgba(161,161,170,0.1); color: #a1a1aa; }
.badge-stage-qualificado { background: rgba(245,158,11,0.1); color: #fbbf24; }
.badge-stage-agendado { background: rgba(99,102,241,0.1); color: #818cf8; }
.badge-stage-convertido { background: rgba(34,197,94,0.1); color: #4ade80; }
.badge-stage-perdido { background: rgba(239,68,68,0.1); color: #f87171; }

/* Temperature Badge (inline, with icon) */
.badge-temp-inline {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.62rem;
    font-weight: 700;
    text-transform: uppercase;
}
.badge-temp-hot { background: rgba(239,68,68,0.1); color: #f87171; }
.badge-temp-warm { background: rgba(245,158,11,0.1); color: #fbbf24; }
.badge-temp-cold { background: rgba(59,130,246,0.1); color: #60a5fa; }

/* Pagination */
.leads-pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    margin-top: 12px;
}
.leads-pagination .pagination-info {
    font-size: 0.75rem;
    color: var(--text-tertiary);
}
.leads-pagination .pagination-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}
.leads-pagination .pagination-page {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 600;
}
.leads-pagination button {
    padding: 5px 12px;
    font-size: 0.72rem;
    font-weight: 600;
    border-radius: 6px;
    border: 1px solid var(--border-subtle);
    background: var(--bg-surface);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s;
}
.leads-pagination button:hover:not(:disabled) {
    background: var(--bg-elevated);
    color: var(--text-primary);
}
.leads-pagination button:disabled {
    opacity: 0.4;
    cursor: default;
}

/* Kanban Drag & Drop States */
.kanban-card {
    transition: all 0.15s;
    cursor: grab;
}
.kanban-card:hover {
    border-color: var(--border-color);
    transform: translateY(-1px);
}
.kanban-card:active {
    cursor: grabbing;
}
.kanban-card.dragging {
    opacity: 0.35;
    transform: scale(0.96);
}
.kanban-column.drag-over .kanban-column-body {
    background: rgba(99,102,241,0.04);
    border-color: rgba(99,102,241,0.2);
}
.kanban-empty.drag-over-empty {
    color: var(--accent-primary, #6366f1);
    border: 1px dashed rgba(99,102,241,0.3);
    border-radius: 8px;
}

/* Kanban Card Enhancements */
.kanban-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 2px;
    gap: 6px;
}
.kanban-card .whatsapp-badge {
    font-size: 0.58rem;
    font-weight: 700;
    text-transform: uppercase;
    color: #818cf8;
    background: rgba(99,102,241,0.1);
    padding: 2px 6px;
    border-radius: 3px;
    flex-shrink: 0;
}
.kanban-card .score-section {
    margin: 8px 0;
}
.kanban-card .score-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 3px;
}
.kanban-card .score-label {
    font-size: 0.6rem;
    color: var(--text-tertiary);
}
.kanban-card .score-value {
    font-size: 0.6rem;
    font-weight: 700;
    color: var(--text-secondary);
}
.kanban-card .tags-row {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    margin: 6px 0;
}
.kanban-card .tags-row .tag {
    font-size: 0.58rem;
    padding: 1px 6px;
    border-radius: 8px;
    background: rgba(99,102,241,0.1);
    color: #818cf8;
}
.kanban-card .tags-row .tag-more {
    font-size: 0.58rem;
    color: var(--text-tertiary);
}
.kanban-card .time-row {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.6rem;
    color: var(--text-tertiary);
}

/* Lead Detail Modal — Enhanced */
.lead-detail-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}
.lead-detail-header .lead-info h4 {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}
.lead-detail-header .lead-info p {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    margin: 2px 0 0;
}
.lead-detail-header .lead-badges {
    display: flex;
    gap: 6px;
}
.lead-detail-metrics {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 14px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border-subtle);
}
.lead-detail-metrics .metric-sep {
    color: var(--border-subtle);
}
.lead-detail-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 14px;
}
.lead-detail-field {
    margin-bottom: 14px;
}
.lead-detail-field label {
    display: block;
    font-size: 0.68rem;
    font-weight: 500;
    color: var(--text-tertiary);
    margin-bottom: 4px;
}
.lead-detail-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding-top: 14px;
    border-top: 1px solid var(--border-subtle);
}
.lead-detail-actions .btn-cancel {
    padding: 6px 14px;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-secondary);
    background: none;
    border: none;
    cursor: pointer;
    border-radius: 6px;
    transition: color 0.15s;
}
.lead-detail-actions .btn-cancel:hover {
    color: var(--text-primary);
}
.lead-detail-actions .btn-save {
    padding: 6px 18px;
    font-size: 0.75rem;
    font-weight: 700;
    color: #fff;
    background: var(--accent-primary, #6366f1);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: opacity 0.15s;
}
.lead-detail-actions .btn-save:hover {
    opacity: 0.9;
}
.lead-detail-actions .btn-save:disabled {
    opacity: 0.5;
    cursor: default;
}
