/* ===================================
   CSS VARIABLES & ROOT STYLES
   =================================== */
:root {
    /* Core Colors */
    --primary: #0f172a;
    --primary-light: #1e293b;
    --primary-lighter: #334155;
    
    /* Accent Colors */
    --accent-blue: #3b82f6;
    --accent-purple: #8b5cf6;
    --accent-green: #10b981;
    --accent-yellow: #f59e0b;
    --accent-red: #ef4444;
    
    /* Gradients */
    --gradient-primary: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
    --gradient-success: linear-gradient(135deg, #10b981 0%, #059669 100%);
    --gradient-warning: linear-gradient(135deg, #f59e0b 0%, #dc2626 100%);
    
    /* Backgrounds */
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-tertiary: #f1f5f9;
    --bg-elevated: #ffffff;
    
    /* Text */
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    
    /* Borders */
    --border-light: #e2e8f0;
    --border-medium: #cbd5e1;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    
    /* Spacing */
    --spacing-xs: 0.5rem;
    --spacing-sm: 0.75rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
    --spacing-2xl: 3rem;
    
    /* Transitions */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 350ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===================================
   RESET & BASE STYLES
   =================================== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-secondary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ===================================
   LOGIN PAGE
   =================================== */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary);
    padding: 2rem;
    position: relative;
    overflow: hidden;
}

.login-page::before {
    content: '';
    position: absolute;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(59, 130, 246, 0.15) 0%, transparent 70%);
    top: -200px;
    right: -200px;
    animation: float 20s ease-in-out infinite;
}

.login-page::after {
    content: '';
    position: absolute;
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(139, 92, 246, 0.15) 0%, transparent 70%);
    bottom: -100px;
    left: -100px;
    animation: float 15s ease-in-out infinite reverse;
}

@keyframes float {
    0%, 100% { transform: translate(0, 0) rotate(0deg); }
    33% { transform: translate(30px, -30px) rotate(5deg); }
    66% { transform: translate(-20px, 20px) rotate(-5deg); }
}

.login-card {
    background: white;
    border-radius: 24px;
    padding: 3rem;
    width: 100%;
    max-width: 440px;
    box-shadow: var(--shadow-xl);
    position: relative;
    z-index: 1;
    animation: slideUp 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.login-logo {
    margin-bottom: 2rem;
    text-align: center;
    animation: logoFade 0.8s ease-out 0.2s backwards;
}

.login-logo img {
    max-width: 100%;
    height: auto;
}

@keyframes logoFade {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.login-card h2 {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.875rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: var(--primary);
}

.login-card p {
    color: var(--text-secondary);
    margin-bottom: 2rem;
    font-size: 0.95rem;
}

.login-demo {
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border-light);
    font-size: 0.85rem;
    color: var(--text-muted);
}

.login-demo p {
    margin-bottom: 0.25rem;
}

.login-demo strong {
    color: var(--text-secondary);
}

/* ===================================
   FORM ELEMENTS
   =================================== */
.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.875rem 1rem;
    border: 2px solid var(--border-light);
    border-radius: 12px;
    font-size: 0.95rem;
    font-family: inherit;
    transition: all var(--transition-base);
    background: var(--bg-primary);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-group textarea {
    resize: vertical;
    min-height: 100px;
}

/* Inputs fora de .form-group (usados nas telas) */
.input {
    width: 100%;
    padding: 0.75rem 0.9rem;
    border: 1.5px solid var(--border-medium);
    border-radius: 12px;
    font-size: 0.92rem;
    font-family: inherit;
    color: var(--text-primary);
    background: #fff;
    transition: all var(--transition-fast);
}

.input:focus {
    outline: none;
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}

.mesa-perf-toolbar {
    display: grid;
    grid-template-columns: minmax(280px, 340px) 1fr;
    gap: 16px;
    align-items: end;
}

.mesa-perf-tabs {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.mesa-perf-section {
    display: grid;
    gap: 12px;
}

.mesa-perf-filter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
}

.mesa-perf-category-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 12px;
}

.mesa-perf-check {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: #fff;
    border: 1px solid var(--border-light);
    border-radius: 999px;
    padding: 8px 12px;
    font-size: 0.9rem;
}

.mesa-perf-inline-check {
    padding-left: 0;
    border: none;
    background: transparent;
}

.mesa-perf-chart-grid,
.mesa-perf-data-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 12px;
}

.mesa-perf-canvas-wrap {
    min-height: 320px;
    position: relative;
}

.mesa-perf-block-card {
    margin-bottom: 0;
}

.mesa-perf-card-header-inline {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.mesa-perf-source-note {
    margin-top: 16px;
    font-size: 0.82rem;
    color: var(--text-muted);
}

.table-scroll {
    overflow: auto;
}

@media (max-width: 900px) {
    .mesa-perf-toolbar {
        grid-template-columns: 1fr;
    }

    .mesa-perf-tabs {
        justify-content: flex-start;
    }
}

select.input {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    padding-right: 2.2rem;
    background-image:
      linear-gradient(45deg, transparent 50%, #64748b 50%),
      linear-gradient(135deg, #64748b 50%, transparent 50%),
      linear-gradient(to right, #e2e8f0, #e2e8f0);
    background-position:
      calc(100% - 18px) calc(50% - 3px),
      calc(100% - 12px) calc(50% - 3px),
      calc(100% - 2.2rem) 50%;
    background-size: 6px 6px, 6px 6px, 1px 60%;
    background-repeat: no-repeat;
}

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

.error-message {
    background: #fee2e2;
    color: var(--accent-red);
    padding: 0.75rem 1rem;
    border-radius: 8px;
    font-size: 0.875rem;
    margin-bottom: 1rem;
    border-left: 3px solid var(--accent-red);
}

/* ===================================
   BUTTONS
   =================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.875rem 1.5rem;
    border: none;
    border-radius: 12px;
    font-size: 0.95rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all var(--transition-base);
    text-decoration: none;
}

.btn-primary {
    background: var(--gradient-primary);
    color: white;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(59, 130, 246, 0.4);
}

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

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: var(--border-medium);
}

.btn-accent {
    background: var(--accent-blue);
    color: white;
}

.btn-accent:hover {
    background: #2563eb;
    transform: translateY(-1px);
}

.btn-success {
    background: var(--accent-green);
    color: white;
}

.btn-success:hover {
    background: #059669;
}

.btn-full {
    width: 100%;
}

.btn-sm {
    padding: 0.625rem 1rem;
    font-size: 0.875rem;
}

.year-segmented {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px;
    border-radius: 9999px;
    border: 1px solid #dbe4ff;
    background: linear-gradient(180deg, #f8fafc 0%, #eef2ff 100%);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.75);
}

.year-btn {
    border: none;
    background: transparent;
    color: var(--text-secondary);
    border-radius: 9999px;
    padding: 0.45rem 0.85rem;
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.01em;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.year-btn:hover {
    color: var(--primary);
    background: rgba(255, 255, 255, 0.72);
}

.year-btn.active {
    color: #0b3b9e;
    background: linear-gradient(135deg, #dbeafe 0%, #e0e7ff 100%);
    box-shadow: 0 1px 2px rgba(30, 64, 175, 0.25);
}

.btn-icon {
    padding: 0.5rem;
    border-radius: 8px;
}

.action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 8px;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.action-btn:hover {
    background: var(--border-medium);
    color: var(--text-primary);
}

/* ===================================
   APP LAYOUT
   =================================== */
#app {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 280px;
    background: var(--bg-elevated);
    border-right: 1px solid var(--border-light);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    left: 0;
    top: 0;
    z-index: 100;
}

.sidebar-header {
    padding: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    border-bottom: 1px solid var(--border-light);
    background: white;
}

.sidebar-header img {
    transition: transform var(--transition-base);
}

.sidebar-header img:hover {
    transform: scale(1.05);
}

.sidebar-title {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary);
}

.nav {
    flex: 1;
    padding: 1rem;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    border-radius: 12px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
    font-weight: 500;
    position: relative;
    margin-bottom: 0.25rem;
}

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

.nav-item.active {
    background: var(--gradient-primary);
    color: white;
}

.nav-item svg {
    flex-shrink: 0;
}

.nav-divider {
    height: 1px;
    background: var(--border-light);
    margin: 1rem 0;
}

.badge-count {
    margin-left: auto;
    background: var(--accent-red);
    color: white;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.25rem 0.5rem;
    border-radius: 9999px;
    min-width: 20px;
    text-align: center;
}

.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 1 1 auto;
    min-width: 0;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: var(--gradient-primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.875rem;
}

.user-avatar.admin {
    background: var(--gradient-warning);
}

.user-details {
    flex: 1;
    min-width: 0;
}

.user-name {
    font-weight: 600;
    font-size: 0.875rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: capitalize;
}

.logout-btn {
    width: 40px;
    height: 40px;
    flex: 0 0 40px;
    border: none;
    border-radius: 10px;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.logout-btn:hover {
    background: #fee2e2;
    color: var(--accent-red);
}

.main-content {
    flex: 1;
    margin-left: 280px;
    padding: 2rem;
    min-height: 100vh;
}

@media (min-width: 1025px) and (hover: hover) and (pointer: fine) {
    .sidebar {
        width: 86px;
        transition: width var(--transition-base), box-shadow var(--transition-base);
        overflow-x: hidden;
        overflow-y: auto;
    }

    .sidebar:hover {
        width: 280px;
        box-shadow: var(--shadow-lg);
    }

    .sidebar-header {
        padding: 1.25rem 1rem;
        transition: padding var(--transition-base);
    }

    .sidebar:not(:hover) .sidebar-header img {
        height: 30px;
        width: auto;
    }

    .sidebar .nav {
        padding: 0.875rem;
    }

    .sidebar .nav-item {
        justify-content: center;
        padding: 0.875rem;
        gap: 0;
    }

    .sidebar:hover .nav-item {
        justify-content: flex-start;
        padding: 0.875rem 1rem;
        gap: 0.75rem;
    }

    .sidebar .nav-item span:not(.badge-count),
    .sidebar .user-details {
        opacity: 0;
        width: 0;
        overflow: hidden;
        white-space: nowrap;
        transition: opacity var(--transition-fast);
    }

    .sidebar:hover .nav-item span:not(.badge-count),
    .sidebar:hover .user-details {
        opacity: 1;
        width: auto;
    }

    .sidebar .badge-count {
        margin-left: 0;
        position: absolute;
        top: 8px;
        right: 8px;
    }

    .sidebar:hover .badge-count {
        margin-left: auto;
        position: static;
    }

    /* Collapsed: SO o avatar/foto aparece. Dark e sair so no hover. */
    .sidebar-footer {
        justify-content: center;
        padding: 0.875rem;
    }

    .sidebar:hover .sidebar-footer {
        justify-content: space-between;
        padding: 1rem;
    }

    .sidebar .user-info {
        justify-content: center;
        flex: 0 0 auto;
    }

    .sidebar:hover .user-info {
        justify-content: flex-start;
        flex: 1 1 auto;
    }

    /* Esconde dark-mode + logout no collapsed; mostra so no hover */
    .sidebar:not(:hover) .dark-mode-wrap,
    .sidebar:not(:hover) .logout-btn {
        display: none;
    }

    .main-content {
        margin-left: 86px;
        transition: margin-left var(--transition-base);
    }
}

/* ===================================
   PAGE HEADERS
   =================================== */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 2rem;
    gap: 1rem;
}

.page-title {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 0.25rem;
}

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

/* ===================================
   CARDS
   =================================== */
.card {
    background: var(--bg-elevated);
    border-radius: 16px;
    border: 1px solid var(--border-light);
    overflow: hidden;
    transition: all var(--transition-base);
}

.card:hover {
    box-shadow: var(--shadow-lg);
}

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

.card-title {
    font-weight: 700;
    font-size: 1.125rem;
    color: var(--primary);
}

.card-body {
    padding: 1.5rem;
}

/* ===================================
   STATS GRID
   =================================== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border-light);
    border-radius: 16px;
    padding: 1.5rem;
    transition: all var(--transition-base);
    min-width: 0;
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.stat-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.stat-val {
    font-size: clamp(1.1rem, 1.45vw, 1.55rem);
    font-weight: 700;
    font-family: 'Space Grotesk', sans-serif;
    color: var(--primary);
    line-height: 1.2;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.stat-change {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.8rem;
    margin-top: 0.5rem;
    flex-wrap: wrap;
    overflow-wrap: anywhere;
}

.stat-change.positive {
    color: var(--accent-green);
}

.stat-change.negative {
    color: var(--accent-red);
}

/* ===================================
   SEARCH BOX
   =================================== */
.search-box {
    position: relative;
    margin-bottom: 2rem;
}

.search-box svg {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    color: var(--text-muted);
    pointer-events: none;
}

.search-box input {
    width: 100%;
    padding: 0.875rem 1rem 0.875rem 3rem;
    border: 2px solid var(--border-light);
    border-radius: 12px;
    font-size: 0.95rem;
    transition: all var(--transition-base);
    background: var(--bg-primary);
}

.search-box input:focus {
    outline: none;
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* ===================================
   DATA TABLE
   =================================== */
.data-table {
    background: var(--bg-elevated);
    border: 1px solid var(--border-light);
    border-radius: 16px;
    overflow: hidden;
}

.table-header,
.table-row {
    display: grid;
    align-items: center;
    padding: 1rem 1.5rem;
    gap: 1rem;
}

.table-header {
    background: var(--bg-tertiary);
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.table-row {
    border-top: 1px solid var(--border-light);
    transition: all var(--transition-fast);
    cursor: pointer;
}

.table-row:hover {
    background: var(--bg-secondary);
}

.table-sort-btn {
    border: none;
    background: transparent;
    padding: 0;
    margin: 0;
    font: inherit;
    color: inherit;
    cursor: pointer;
    font-weight: 700;
}

.table-sort-btn:hover {
    color: var(--accent-blue);
}

.clients-table .table-header,
.clients-table .table-row {
    grid-template-columns: 2fr 1fr 1fr 1fr auto;
}

.users-table .table-header,
.users-table .table-row {
    grid-template-columns: 2fr 2fr 1fr 1fr auto;
}

.cell-client {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.cell-avatar {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.875rem;
    color: white;
    flex-shrink: 0;
}

.cell-name {
    font-weight: 600;
    color: var(--text-primary);
}

.cell-email {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.cell-value {
    font-weight: 600;
}

.cell-value.positive {
    color: var(--accent-green);
}

.cell-value.negative {
    color: var(--accent-red);
}

/* ===================================
   BADGES
   =================================== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.375rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: capitalize;
}

.badge.active {
    background: #d1fae5;
    color: #065f46;
}

.badge.inactive,
.badge.pending {
    background: #fee2e2;
    color: #991b1b;
}

.badge.admin {
    background: #fef3c7;
    color: #92400e;
}

.badge.gestor {
    background: #dbeafe;
    color: #1e40af;
}

.badge.assessor {
    background: #e0e7ff;
    color: #3730a3;
}

/* ===================================
   DOCUMENTS
   =================================== */
.docs-section {
    margin-bottom: 2rem;
}

.docs-section-title {
    font-weight: 700;
    font-size: 1.125rem;
    margin-bottom: 1rem;
    color: var(--primary);
}

.docs-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1rem;
}

.doc-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border-light);
    border-radius: 12px;
    padding: 1.25rem;
    display: flex;
    gap: 1rem;
    cursor: pointer;
    transition: all var(--transition-base);
}

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

.doc-icon {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.doc-icon.pdf {
    background: #fee2e2;
    color: var(--accent-red);
}

.doc-icon.xlsx {
    background: #d1fae5;
    color: var(--accent-green);
}

.doc-icon.pptx {
    background: #fef3c7;
    color: var(--accent-yellow);
}

.doc-icon.docx {
    background: #dbeafe;
    color: var(--accent-blue);
}

.doc-name {
    font-weight: 600;
    margin-bottom: 0.25rem;
    color: var(--text-primary);
}

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

.doc-tag {
    display: inline-block;
    background: var(--accent-blue);
    color: white;
    font-size: 0.625rem;
    font-weight: 700;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    margin-top: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ===================================
   AVISOS (NOTICES)
   =================================== */
/* ===================================
   AVISOS — toolbar (filtros + busca)
   =================================== */
.avisos-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    justify-content: space-between;
}

.avisos-toolbar-left {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
}

.avisos-count {
    font-size: 0.78rem;
    color: var(--text-muted);
    font-weight: 600;
}

.avisos-segmented {
    display: inline-flex;
    align-items: center;
    background: linear-gradient(180deg, #f8fafc 0%, #eef2ff 100%);
    border: 1px solid #dbe4ff;
    border-radius: 9999px;
    padding: 4px;
    gap: 4px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

.avisos-tipo-btn {
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.01em;
    border-radius: 9999px;
    padding: 0.45rem 0.95rem;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.avisos-tipo-btn:hover {
    color: var(--primary);
    background: rgba(255, 255, 255, 0.7);
}

.avisos-tipo-btn.active {
    color: #0b3b9e;
    background: linear-gradient(135deg, #dbeafe 0%, #e0e7ff 100%);
    box-shadow: 0 1px 2px rgba(30, 64, 175, 0.25);
}

.avisos-tipo-btn .pill-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    background: rgba(15, 23, 42, 0.08);
    color: inherit;
    border-radius: 9999px;
    font-size: 0.7rem;
    font-weight: 700;
}

/* ===================================
   AVISOS — composer (collapsible)
   =================================== */
.avisos-composer {
    margin-bottom: 16px;
    border-radius: 16px;
    overflow: hidden;
    border: 1px solid var(--border-light);
    background: var(--bg-elevated);
    transition: box-shadow .2s ease;
}

.avisos-composer-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 18px;
    background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
    border: none;
    cursor: pointer;
    font: inherit;
    color: var(--primary);
    font-weight: 700;
    transition: background .18s ease;
}

.avisos-composer-toggle:hover {
    background: linear-gradient(180deg, #f6f9ff 0%, #eef4ff 100%);
}

.avisos-composer-toggle-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 8px;
    background: rgba(11, 59, 158, 0.1);
    color: #0b3b9e;
    font-size: 1.1rem;
    transition: transform .25s ease;
}

.avisos-composer.open .avisos-composer-toggle-icon {
    transform: rotate(45deg);
}

.avisos-composer-body {
    padding: 0 18px;
    max-height: 0;
    overflow: hidden;
    transition: max-height .3s ease, padding .25s ease;
    display: grid;
    gap: 10px;
}

.avisos-composer.open .avisos-composer-body {
    padding: 14px 18px 18px 18px;
    max-height: 600px;
}

.avisos-composer-row {
    display: grid;
    grid-template-columns: minmax(140px, 200px) 1fr;
    gap: 10px;
    align-items: stretch;
}

.avisos-composer-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 4px;
}

@media (max-width: 720px) {
    .avisos-composer-row {
        grid-template-columns: 1fr;
    }
}

/* ===================================
   AVISOS — lista de cards
   =================================== */
.avisos-list {
    display: flex;
    flex-direction: column;
    gap: 0.875rem;
}

.aviso-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border-light);
    border-radius: 16px;
    padding: 1.1rem 1.3rem 1rem 1.5rem;
    cursor: pointer;
    transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
    position: relative;
    overflow: hidden;
}

/* Faixa lateral colorida por tipo */
.aviso-card::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: #cbd5e1;
    transition: background .18s ease;
}

.aviso-card[data-tipo="importante"]::before { background: #dc2626; }
.aviso-card[data-tipo="novidade"]::before  { background: #2563eb; }
.aviso-card[data-tipo="info"]::before      { background: #94a3b8; }

.aviso-card:hover {
    transform: translateY(-1px);
    border-color: #cbd5e1;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
}

/* Não-lido — fundo levemente tingido + título mais forte */
.aviso-card.unread {
    background: linear-gradient(180deg, #f5f9ff 0%, #ffffff 60%);
    border-color: #c8dafe;
}

.aviso-card.unread .aviso-title {
    color: var(--primary);
}

/* Lido — visual mais discreto */
.aviso-card.lido .aviso-title {
    color: #475569;
}

.aviso-card.lido {
    opacity: 0.92;
}

.aviso-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 0.6rem;
    flex-wrap: wrap;
}

.aviso-meta {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.aviso-unread-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.18);
    flex-shrink: 0;
}

.aviso-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px 3px 8px;
    border-radius: 9999px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.4px;
    text-transform: uppercase;
}

.aviso-badge::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    opacity: 0.85;
}

.aviso-badge.importante {
    background: #fee2e2;
    color: #b91c1c;
}

.aviso-badge.novidade {
    background: #dbeafe;
    color: #1d4ed8;
}

.aviso-badge.info {
    background: #f1f5f9;
    color: #475569;
}

.aviso-date {
    font-size: 0.78rem;
    color: var(--text-muted);
}

.aviso-title {
    font-weight: 700;
    font-size: 1.05rem;
    margin-bottom: 0.35rem;
    color: var(--primary);
    line-height: 1.35;
}

.aviso-content {
    color: var(--text-secondary);
    line-height: 1.55;
    font-size: 0.92rem;
    white-space: pre-wrap;
}

.aviso-actions {
    display: flex;
    gap: 6px;
    margin-top: 0.85rem;
    padding-top: 0.75rem;
    border-top: 1px dashed var(--border-light);
    flex-wrap: wrap;
}

.aviso-action-btn {
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-secondary);
    font: inherit;
    font-size: 0.82rem;
    font-weight: 600;
    padding: 6px 10px;
    border-radius: 8px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: background .15s ease, color .15s ease, border-color .15s ease;
}

.aviso-action-btn:hover {
    background: rgba(15, 23, 42, 0.05);
    color: var(--primary);
}

.aviso-action-btn.primary {
    color: #0b3b9e;
}

.aviso-action-btn.primary:hover {
    background: rgba(11, 59, 158, 0.08);
}

.aviso-action-btn.danger {
    color: #b91c1c;
}

.aviso-action-btn.danger:hover {
    background: rgba(185, 28, 28, 0.08);
    border-color: rgba(185, 28, 28, 0.18);
}

.aviso-lido-marker {
    margin-left: auto;
    font-size: 0.72rem;
    color: #16a34a;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

/* Empty state */
.avisos-empty {
    padding: 40px 20px;
    text-align: center;
    border: 1px dashed var(--border-light);
    border-radius: 16px;
    background: var(--bg-elevated);
}

.avisos-empty-icon {
    font-size: 2.4rem;
    opacity: 0.45;
    margin-bottom: 8px;
}

.avisos-empty-title {
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 4px;
}

.avisos-empty-text {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* ===================================
   RANKING
   =================================== */
.ranking-list {
    display: flex;
    flex-direction: column;
}

.ranking-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-light);
    transition: all var(--transition-fast);
}

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

.ranking-item:hover {
    background: var(--bg-secondary);
}

.ranking-pos {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.875rem;
    flex-shrink: 0;
}

.ranking-pos.gold {
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    color: white;
}

.ranking-pos.silver {
    background: linear-gradient(135deg, #d1d5db, #9ca3af);
    color: white;
}

.ranking-pos.bronze {
    background: linear-gradient(135deg, #d97706, #92400e);
    color: white;
}

.ranking-pos.normal {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}

.ranking-info {
    flex: 1;
}

.ranking-name {
    font-weight: 600;
    color: var(--text-primary);
}

.ranking-meta {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.ranking-value {
    font-weight: 700;
    font-family: 'Space Grotesk', sans-serif;
    color: var(--primary);
}

.ranking-campaign-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    border: 1px solid var(--border-light);
    border-radius: 12px;
    overflow: hidden;
    background: #fff;
}

.ranking-campaign-table thead th {
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    color: #f8fafc;
    font-size: 12px;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    padding: 10px 12px;
    text-align: left;
}

.ranking-campaign-table tbody td {
    padding: 10px 12px;
    border-top: 1px solid #e5e7eb;
    color: #111827;
    font-size: 13px;
}

.ranking-campaign-table tbody tr:nth-child(even) {
    background: #f8fafc;
}

.ranking-campaign-table tbody tr:hover {
    background: #eef2ff;
}

.ranking-campaign-table tbody tr.campaign-row-selected {
    background: #e0e7ff !important;
    box-shadow: inset 4px 0 0 #4f46e5;
}

.ranking-campaign-table .col-assessor {
    font-weight: 600;
}

.ranking-campaign-table .col-num {
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.rank-medal {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 42px;
    padding: 4px 8px;
    border-radius: 999px;
    font-weight: 700;
    font-size: 12px;
    background: #e5e7eb;
    color: #374151;
}

.rank-medal.medal-gold {
    background: linear-gradient(135deg, #facc15 0%, #f59e0b 100%);
    color: #111827;
}

.rank-medal.medal-silver {
    background: linear-gradient(135deg, #d1d5db 0%, #9ca3af 100%);
    color: #111827;
}

.rank-medal.medal-bronze {
    background: linear-gradient(135deg, #fdba74 0%, #c2410c 100%);
    color: #fff;
}

.pts-badge {
    display: inline-block;
    min-width: 64px;
    padding: 3px 8px;
    border-radius: 999px;
    text-align: center;
    font-weight: 700;
}

.pts-badge.pts-positive {
    background: #dcfce7;
    color: #166534;
}

.pts-badge.pts-negative {
    background: #fee2e2;
    color: #991b1b;
}

.mini-rank-badge {
    display: inline-block;
    margin-left: 8px;
    padding: 2px 7px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    background: #e2e8f0;
    color: #0f172a;
    vertical-align: middle;
}

/* ===================================
   TABLE CLEANUP (GESTAO)
   =================================== */
.table-wrap {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 14px;
    padding: 12px;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
}

.table-wrap .table:not(.ranking-campaign-table) {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.table-wrap .table:not(.ranking-campaign-table) thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: linear-gradient(180deg, #f8fafc 0%, #eef2ff 100%);
    color: #0f172a;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    padding: 10px 12px;
    border-bottom: 1px solid #dbe4ff;
    text-align: left;
    white-space: nowrap;
}

.table-wrap .table:not(.ranking-campaign-table) tbody td {
    padding: 10px 12px;
    border-bottom: 1px solid #eef2f7;
    color: #111827;
    font-size: 14px;
    white-space: nowrap;
}

.table-wrap .table:not(.ranking-campaign-table) tbody tr:nth-child(even) {
    background: #fafcff;
}

.table-wrap .table:not(.ranking-campaign-table) tbody tr:hover {
    background: #eef2ff;
}

.table-wrap .table:not(.ranking-campaign-table) tbody tr:last-child td {
  border-bottom: none;
}

.page-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.page-actions {
  display: flex;
  gap: 8px;
}

.cards-grid {
  display: grid;
  gap: 16px;
}

.cards-grid-compact {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.brapi-page {
  background: linear-gradient(180deg, rgba(10, 19, 40, 0.04), rgba(255, 255, 255, 0.65));
  border-radius: 24px;
  padding: 12px 4px 24px;
}

.brapi-page h1 {
  font-size: 26px;
  letter-spacing: -0.02em;
}

.brapi-page .page-header-row p {
  color: #5d6b85;
  margin-top: 6px;
}

.brapi-cards {
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.brapi-overview {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.brapi-overview-card {
  background: #ffffff;
  border-radius: 18px;
  border: 1px solid #e6edf7;
  padding: 16px;
  box-shadow: 0 14px 32px rgba(15, 30, 60, 0.08);
}

.brapi-overview-title {
  font-weight: 700;
  color: #18233a;
  margin-bottom: 12px;
}

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

.brapi-stat {
  background: #f6f9ff;
  border-radius: 12px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  border: 1px solid #e6edf7;
}

.brapi-stat .label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #6a7a96;
}

.brapi-stat strong {
  font-size: 18px;
  color: #0f1b34;
}

.brapi-stat-up strong {
  color: #1a8f5b;
}

.brapi-stat-down strong {
  color: #d45a4c;
}

.brapi-stat-flat strong {
  color: #4a5b78;
}

.brapi-movers {
  background: linear-gradient(135deg, rgba(14, 20, 36, 0.96), rgba(18, 28, 48, 0.92));
  color: #eef3ff;
}

.brapi-movers .brapi-overview-title {
  color: #eef3ff;
}

.brapi-movers-list {
  display: grid;
  gap: 10px;
}

.brapi-mover-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
}

.brapi-mover-item .symbol {
  font-weight: 700;
  letter-spacing: 0.04em;
}

.brapi-card {
  border: 1px solid #e8edf5;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.95), rgba(246, 249, 255, 0.9));
  box-shadow: 0 16px 36px rgba(15, 30, 60, 0.08);
}

.brapi-card .card-title {
  color: #6b7a96;
  font-weight: 600;
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.12em;
}

.brapi-card .card-value {
  font-size: 24px;
  font-weight: 700;
  color: #0f1b34;
  margin-top: 8px;
}

.brapi-table-wrap {
  border-radius: 18px;
  padding: 12px;
  background: #ffffff;
  border: 1px solid #e8edf5;
  box-shadow: 0 18px 40px rgba(15, 30, 60, 0.08);
}

.brapi-table {
  border-collapse: separate;
  border-spacing: 0 10px;
}

.brapi-table thead th {
  background: transparent;
  color: #6b7a96;
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.12em;
  border: none;
  padding: 8px 12px;
}

.brapi-table tbody tr {
  background: #f7f9fc;
  border-radius: 12px;
  box-shadow: inset 0 0 0 1px #eef2f8;
}

.brapi-table tbody td {
  border: none;
  padding: 12px;
}

.brapi-table tbody tr td:first-child {
  border-top-left-radius: 12px;
  border-bottom-left-radius: 12px;
  font-weight: 700;
  color: #1a2540;
}

.brapi-table tbody tr td:last-child {
  border-top-right-radius: 12px;
  border-bottom-right-radius: 12px;
}

.brapi-table tbody tr:hover {
  background: #eef4ff;
}

.brapi-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 5px 11px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  border: 1px solid transparent;
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}

.brapi-pill.up {
  background: rgba(34, 197, 94, 0.14);
  color: #22c55e;
  border-color: rgba(34, 197, 94, 0.32);
}

.brapi-pill.down {
  background: rgba(239, 68, 68, 0.14);
  color: #ef4444;
  border-color: rgba(239, 68, 68, 0.32);
}

.brapi-pill.flat {
  background: rgba(100, 116, 150, 0.12);
  color: #94a3b8;
  border-color: rgba(100, 116, 150, 0.25);
}

[data-tip] {
  position: relative;
  cursor: help;
}

[data-tip]::after {
  content: attr(data-tip);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.95);
  color: #f5f7ff;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 11px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
  z-index: 5;
}

[data-tip]:hover::after {
  opacity: 1;
}

.brapi-hero {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  border-radius: 16px;
  background: #101a2f;
  color: #f5f7ff;
  margin-bottom: 16px;
  box-shadow: 0 18px 40px rgba(10, 20, 40, 0.25);
}

.brapi-hero-title {
  font-size: 18px;
  font-weight: 700;
}

.brapi-hero-sub {
  color: rgba(245, 247, 255, 0.7);
  margin-top: 6px;
}

.brapi-hero-right {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 200px;
}

.brapi-hero-right label {
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(245, 247, 255, 0.6);
}

.brapi-hero-right select {
  border-radius: 10px;
  border: none;
  padding: 10px 12px;
  font-weight: 600;
  color: #101a2f;
}

.brapi-filters {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.brapi-filter-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.brapi-filter-group label {
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #7c8aa7;
}

.brapi-filter-group input[type="date"] {
  border-radius: 10px;
  border: 1px solid #d3def5;
  padding: 8px 12px;
  font-weight: 600;
  color: #1d2b4b;
}

.brapi-chart-card {
  background: #0b1224;
  border-radius: 18px;
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: 0 18px 40px rgba(10, 20, 40, 0.3);
  height: 280px;
}

.brapi-chart-title {
  color: #e7edff;
  font-weight: 600;
  margin-bottom: 12px;
}

.brapi-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

.brapi-compare {
  background: #0b1224;
  border-radius: 18px;
  padding: 16px;
  margin-bottom: 16px;
  color: #e7edff;
  box-shadow: 0 18px 40px rgba(10, 20, 40, 0.3);
}

.brapi-compare-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.brapi-compare-title {
  font-weight: 700;
  font-size: 16px;
}

.brapi-compare-sub {
  color: rgba(231, 237, 255, 0.65);
  font-size: 13px;
  margin-top: 4px;
}

.brapi-compare-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.brapi-compare-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  font-size: 12px;
  color: #dfe6f6;
}

.brapi-compare-item input {
  accent-color: #6ea8ff;
}

.brapi-chart-card-compare {
  height: 260px;
}

.brapi-chart-card-wide {
  height: 300px;
}

.brapi-heatmap-card {
  background: #0b1224;
  border-radius: 18px;
  padding: 16px;
  box-shadow: 0 18px 40px rgba(10, 20, 40, 0.3);
  color: #e7edff;
  min-height: 300px;
}

.brapi-heatmap-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
}

.brapi-heatmap-cell {
  border-radius: 12px;
  padding: 10px;
  background: #16203a;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}

.brapi-heatmap-cell.up {
  background: linear-gradient(135deg, rgba(70, 214, 156, 0.3), rgba(22, 32, 58, 0.9));
  border: 1px solid rgba(70, 214, 156, 0.6);
}

.brapi-heatmap-cell.down {
  background: linear-gradient(135deg, rgba(255, 110, 110, 0.3), rgba(22, 32, 58, 0.9));
  border: 1px solid rgba(255, 110, 110, 0.6);
}

.brapi-heatmap-cell .symbol {
  font-weight: 700;
  letter-spacing: 0.02em;
}

.brapi-heatmap-cell .value {
  margin-top: 6px;
  font-size: 13px;
  color: rgba(231, 237, 255, 0.75);
}

.brapi-heatmap-empty {
  color: rgba(231, 237, 255, 0.7);
  font-size: 13px;
}

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

/* ===================================
   BRAPI — LAYOUT SHELL & HEADER
   =================================== */

.brapi-shell {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 1200px;
  margin: 0 auto;
  padding: 4px 0 24px;
}

.brapi-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.brapi-title h1 {
  font-size: 24px;
  font-weight: 700;
  color: #0f1b34;
  letter-spacing: -0.02em;
  margin: 6px 0 4px;
}

.brapi-title p {
  font-size: 13px;
  color: #6a7a96;
  margin: 0;
}

.brapi-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  background: rgba(99, 145, 255, 0.12);
  color: #3a6fd8;
  border: 1px solid rgba(99, 145, 255, 0.28);
}

.brapi-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-top: 6px;
}

/* ===================================
   BRAPI — QUOTE BAR
   =================================== */

.brapi-quote-bar {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 20px;
  align-items: center;
  background: linear-gradient(135deg, #0d1829 0%, #101e38 100%);
  border-radius: 20px;
  padding: 20px 24px;
  box-shadow: 0 12px 32px rgba(10, 20, 45, 0.28);
  border: 1px solid rgba(255,255,255,0.06);
}

.brapi-quote-main {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.brapi-quote-symbol {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(200, 215, 255, 0.65);
}

.brapi-quote-price {
  font-size: 32px;
  font-weight: 800;
  color: #f0f4ff;
  letter-spacing: -0.02em;
  line-height: 1;
}

.brapi-quote-change {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 2px;
}

.brapi-quote-range {
  font-size: 11px;
  color: rgba(200, 215, 255, 0.45);
  letter-spacing: 0.04em;
}

.brapi-quote-meta {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 0 20px;
  border-left: 1px solid rgba(255,255,255,0.07);
  border-right: 1px solid rgba(255,255,255,0.07);
}

.brapi-meta-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.brapi-meta-item .label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: rgba(200, 215, 255, 0.45);
}

.brapi-meta-item strong {
  font-size: 14px;
  font-weight: 700;
  color: #dde8ff;
}

.brapi-quote-select {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 160px;
}

.brapi-quote-select label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: rgba(200, 215, 255, 0.45);
}

.brapi-quote-select select {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 12px;
  padding: 10px 14px;
  color: #dde8ff;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  outline: none;
  transition: border-color 0.15s;
}

.brapi-quote-select select:hover {
  border-color: rgba(255,255,255,0.28);
}

.brapi-quote-select select option {
  background: #0d1829;
  color: #dde8ff;
}

/* ===================================
   BRAPI — TOOLBAR (date range)
   =================================== */

.brapi-toolbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  background: #ffffff;
  border: 1px solid #e6edf7;
  border-radius: 16px;
  padding: 14px 18px;
  box-shadow: 0 4px 16px rgba(15,30,60,0.06);
}

.brapi-toolbar-group {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.brapi-range-pills {
  display: flex;
  gap: 6px;
}

.brapi-range-pills .btn {
  padding: 7px 14px;
  font-size: 12px;
  border-radius: 999px;
  font-weight: 700;
  letter-spacing: 0.04em;
  border: 1.5px solid #d3def5;
  background: #f4f7ff;
  color: #3a5280;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.brapi-range-pills .btn:hover {
  background: #e0e9ff;
  border-color: #9ab4f0;
  color: #1e3a6e;
}

/* ===================================
   BRAPI — CHART HERO (main chart)
   =================================== */

.brapi-chart-hero {
  height: 320px !important;
  background: linear-gradient(160deg, #0b1224 0%, #0e1830 100%);
  border: 1px solid rgba(255,255,255,0.05);
}

/* ===================================
   BRAPI — TOOLTIP (improved)
   =================================== */

[data-tip] {
  position: relative;
  cursor: help;
}

[data-tip]::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: calc(100% + 2px);
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: rgba(15, 23, 42, 0.95);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
  z-index: 6;
}

[data-tip]::after {
  content: attr(data-tip);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 12px);
  transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.95);
  color: #e8eeff;
  padding: 7px 12px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
  z-index: 6;
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
  letter-spacing: 0.02em;
  max-width: 320px;
  white-space: pre-wrap;
  text-align: center;
}

[data-tip]:hover::before,
[data-tip]:hover::after {
  opacity: 1;
}

/* Pills com cursor pointer nas tabelas */
.brapi-table .brapi-pill[data-tip],
.brapi-mover-item .brapi-pill[data-tip] {
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.1s;
}

.brapi-table .brapi-pill[data-tip]:hover,
.brapi-mover-item .brapi-pill[data-tip]:hover {
  transform: scale(1.08);
  box-shadow: 0 2px 10px rgba(0,0,0,0.12);
}

/* ===================================
   BRAPI — TABLE (improvements)
   =================================== */

.brapi-table tbody tr td:first-child {
  font-family: monospace;
  font-size: 13px;
  letter-spacing: 0.06em;
  color: #1a2540;
}

.brapi-table .num-cell {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
  text-align: right;
  font-weight: 600;
  color: #1a2540;
}

.brapi-table tbody td:last-child {
  font-size: 11px;
  color: #8a9ab8;
}

/* ===================================
   BRAPI — RESPONSIVE
   =================================== */

@media (max-width: 860px) {
  .brapi-quote-bar {
    grid-template-columns: 1fr;
  }
  .brapi-quote-meta {
    flex-direction: row;
    border: none;
    border-top: 1px solid rgba(255,255,255,0.07);
    border-bottom: 1px solid rgba(255,255,255,0.07);
    padding: 12px 0;
  }
  .brapi-toolbar {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* ===================================
   BRAPI — HEADER TOP ROW
   =================================== */

.brapi-title-top {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.brapi-live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.6);
  animation: brapi-pulse 2s infinite;
}

@keyframes brapi-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.6); }
  70%  { box-shadow: 0 0 0 7px rgba(34, 197, 94, 0); }
  100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

.brapi-live-label {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #22c55e;
}

.brapi-updated-label {
  font-size: 12px;
  color: #7a8aaa;
  margin-right: 4px;
}

.brapi-refresh-hint {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: #7a8aaa;
  background: rgba(110, 168, 255, 0.08);
  border: 1px solid rgba(110, 168, 255, 0.18);
  border-radius: 999px;
  padding: 3px 10px 3px 8px;
  cursor: default;
  letter-spacing: 0.02em;
}

.brapi-refresh-hint svg {
  color: #6ea8ff;
  flex-shrink: 0;
}

[data-theme="dark"] .brapi-refresh-hint {
  background: rgba(99, 145, 255, 0.1);
  border-color: rgba(99, 145, 255, 0.2);
  color: #6a88b0;
}

.brapi-refresh-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1.5px solid #d3def5;
  background: #f4f7ff;
  color: #3a5280;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.2s;
  outline: none;
}

.brapi-refresh-btn:hover {
  background: #e0e9ff;
  border-color: #9ab4f0;
  color: #1e3a6e;
}

.brapi-refresh-btn:active {
  transform: rotate(180deg);
}

/* ===================================
   BRAPI — TICKER STRIP
   =================================== */

@keyframes brapi-ticker-scroll {
  0%   { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}

.brapi-ticker-strip {
  overflow: hidden;
  position: relative;
  background: linear-gradient(135deg, #0d1829 0%, #0f1e35 100%);
  border-radius: 14px;
  padding: 10px 0;
  border: 1px solid rgba(255,255,255,0.06);
  box-shadow: 0 4px 16px rgba(10,20,45,0.22);
  cursor: default;
}

/* Fade masks on edges */
.brapi-ticker-strip::before,
.brapi-ticker-strip::after {
  content: "";
  position: absolute;
  top: 0;
  height: 100%;
  width: 60px;
  z-index: 2;
  pointer-events: none;
}
.brapi-ticker-strip::before {
  left: 0;
  background: linear-gradient(90deg, #0d1829 30%, transparent);
}
.brapi-ticker-strip::after {
  right: 0;
  background: linear-gradient(270deg, #0d1829 30%, transparent);
}

.brapi-ticker-inner {
  display: flex;
  align-items: center;
  white-space: nowrap;
  width: max-content;
  animation: brapi-ticker-scroll 30s linear infinite;
}

/* Pause on hover */
.brapi-ticker-strip:hover .brapi-ticker-inner {
  animation-play-state: paused;
}

.brapi-ticker-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 14px;
  white-space: nowrap;
  flex-shrink: 0;
}

.brapi-ticker-sym {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: rgba(200, 215, 255, 0.75);
  font-family: ui-monospace, "Cascadia Code", "Fira Code", monospace;
}

.brapi-ticker-pct {
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
  color: #a0aec0;
}

.brapi-ticker-pct.up  { color: #4ade80; }
.brapi-ticker-pct.down { color: #f87171; }

.brapi-ticker-sep {
  font-size: 14px;
  color: rgba(200, 215, 255, 0.2);
  margin: 0 4px;
  user-select: none;
}

/* ===================================
   BRAPI — QUOTE PANEL (Bloomberg style)
   =================================== */

.brapi-quote-panel {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0;
  align-items: stretch;
  background: linear-gradient(160deg, #0a1420 0%, #0e1c34 55%, #0b1829 100%);
  border-radius: 20px;
  overflow: hidden;
  border: 1px solid rgba(99,145,255,0.14);
  box-shadow:
    0 20px 56px rgba(6,12,32,0.5),
    inset 0 1px 0 rgba(255,255,255,0.07),
    inset 0 -1px 0 rgba(0,0,0,0.2);
  position: relative;
}

/* Accent glow top-left */
.brapi-quote-panel::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, #3b82f6 0%, #6366f1 40%, transparent 80%);
  border-radius: 20px 20px 0 0;
  pointer-events: none;
}

.brapi-qp-left {
  padding: 22px 28px 22px 24px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 210px;
  border-right: 1px solid rgba(255,255,255,0.06);
  background: rgba(255,255,255,0.015);
}

.brapi-qp-symbol {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: #6ea8ff;
  font-family: ui-monospace, "Cascadia Code", monospace;
}

.brapi-qp-name {
  font-size: 11px;
  color: rgba(200, 215, 255, 0.38);
  letter-spacing: 0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 230px;
  margin-bottom: 2px;
}

.brapi-qp-price {
  font-size: 38px;
  font-weight: 800;
  color: #f4f8ff;
  letter-spacing: -0.04em;
  line-height: 1;
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
  text-shadow: 0 2px 12px rgba(110,168,255,0.18);
}

.brapi-qp-change {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 6px;
}

.brapi-qp-range {
  font-size: 10px;
  color: rgba(180, 200, 255, 0.32);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.brapi-qp-stats {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  align-items: center;
  padding: 0;
  gap: 0;
}

.brapi-qstat {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 22px 16px;
  border-right: 1px solid rgba(255,255,255,0.055);
  transition: background 0.15s;
}

.brapi-qstat:last-child {
  border-right: none;
}

.brapi-qstat:hover {
  background: rgba(255,255,255,0.03);
}

.brapi-qstat-label {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: rgba(180, 200, 255, 0.35);
  white-space: nowrap;
}

.brapi-qstat-val {
  font-size: 24px;
  font-weight: 800;
  color: #e8f0ff;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
  line-height: 1;
  letter-spacing: -0.02em;
}

.brapi-qstat-up   { color: #4ade80; text-shadow: 0 0 16px rgba(74,222,128,0.3); }
.brapi-qstat-down { color: #f87171; text-shadow: 0 0 16px rgba(248,113,113,0.3); }

.brapi-qp-select {
  padding: 22px 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  justify-content: center;
  border-left: 1px solid rgba(255,255,255,0.06);
  min-width: 175px;
  background: rgba(255,255,255,0.015);
}

.brapi-qp-select label {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: rgba(180, 200, 255, 0.35);
}

.brapi-qp-select select {
  background: rgba(99,145,255,0.1);
  border: 1px solid rgba(99,145,255,0.22);
  border-radius: 10px;
  padding: 10px 12px;
  color: #c8d8ff;
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 0.06em;
  cursor: pointer;
  outline: none;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
  appearance: auto;
  font-family: ui-monospace, "Cascadia Code", monospace;
}

.brapi-qp-select select:hover,
.brapi-qp-select select:focus {
  border-color: rgba(99, 145, 255, 0.55);
  background: rgba(99,145,255,0.18);
  box-shadow: 0 0 0 3px rgba(99,145,255,0.12);
}

.brapi-qp-select select option {
  background: #0d1829;
  color: #dde8ff;
}

/* ===================================
   BRAPI — MID ROW (movers + period)
   =================================== */

.brapi-mid-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.brapi-panel {
  background: #ffffff;
  border: 1px solid #e6edf7;
  border-radius: 18px;
  padding: 18px 20px;
  box-shadow: 0 8px 24px rgba(15,30,60,0.07);
}

.brapi-panel-header {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-bottom: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid #eef2f8;
}

.brapi-panel-title {
  font-size: 14px;
  font-weight: 700;
  color: #18233a;
  letter-spacing: -0.01em;
}

.brapi-panel-sub {
  font-size: 11px;
  color: #8a9ab8;
  letter-spacing: 0.02em;
}

/* Movers list */
.brapi-movers-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.brapi-mover-row {
  display: grid;
  grid-template-columns: 20px 54px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  background: #f8fafc;
  border: 1px solid #eef2f8;
  transition: background 0.12s;
}

.brapi-mover-row:hover {
  background: #eef4ff;
  border-color: #d0e2ff;
}

.brapi-mover-rank {
  font-size: 11px;
  font-weight: 700;
  color: #b0bcd8;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.brapi-mover-sym {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: #1a2540;
  font-family: ui-monospace, "Cascadia Code", monospace;
  white-space: nowrap;
}

.brapi-mover-track {
  height: 5px;
  background: #e8edf5;
  border-radius: 999px;
  overflow: hidden;
}

.brapi-mover-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.4s ease;
}

.brapi-mover-fill.up   { background: linear-gradient(90deg, #22c55e, #4ade80); }
.brapi-mover-fill.down { background: linear-gradient(90deg, #ef4444, #f87171); }
.brapi-mover-fill.flat { background: #94a3b8; }

/* Period panel */
.brapi-period-inputs {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.brapi-period-inputs .brapi-filter-group {
  flex: 1;
  min-width: 120px;
}

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

.brapi-rpill {
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  border-radius: 999px;
  border: 1.5px solid #d3def5;
  background: #f4f7ff;
  color: #3a5280;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  outline: none;
}

.brapi-rpill:hover {
  background: #e0e9ff;
  border-color: #9ab4f0;
  color: #1e3a6e;
}

.brapi-rpill.active {
  background: #1e3a6e;
  border-color: #1e3a6e;
  color: #fff;
}

/* ===================================
   BRAPI — CHART CARD HEADER
   =================================== */

.brapi-chart-hdr {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 10px;
}

.brapi-chart-hdr > div {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.brapi-chart-hdr .brapi-chart-title {
  color: #e7edff;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.01em;
  margin-bottom: 0;
}

.brapi-chart-hdr .brapi-chart-sub {
  font-size: 11px;
  color: rgba(200, 215, 255, 0.45);
  letter-spacing: 0.04em;
}

.brapi-chart-sym {
  color: #7eb3ff;
  font-family: ui-monospace, "Cascadia Code", monospace;
  letter-spacing: 0.08em;
}

/* ===================================
   BRAPI — TABLE HEADER & ROW TINTS
   =================================== */

.brapi-table-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  padding: 4px 8px 14px;
}

.brapi-table-hdr .brapi-panel-title {
  font-size: 15px;
}

.brapi-td-ticker {
  font-family: ui-monospace, "Cascadia Code", "Fira Code", monospace !important;
  font-size: 12px !important;
  font-weight: 800 !important;
  letter-spacing: 0.08em;
  color: #1a2540 !important;
}

.brapi-td-name {
  font-size: 12px;
  color: #5d6b85;
  max-width: 200px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brapi-td-open {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
  font-size: 13px;
  font-weight: 600;
  color: #3a4f6e;
}

.brapi-td-empty {
  text-align: center;
  color: #8a9ab8;
  font-size: 13px;
  padding: 24px !important;
}

/* Row-level tinting */
.brapi-tr-up td   { background: rgba(34, 197, 94, 0.045) !important; }
.brapi-tr-down td { background: rgba(239, 68, 68, 0.045) !important; }
.brapi-tr-flat td { background: #f8fafb !important; }

.brapi-tr-up:hover td   { background: rgba(34, 197, 94, 0.10) !important; }
.brapi-tr-down:hover td { background: rgba(239, 68, 68, 0.10) !important; }
.brapi-tr-flat:hover td { background: #eef4ff !important; }

/* ===================================
   BRAPI — PILL LARGE VARIANT
   =================================== */

.brapi-pill-lg {
  padding: 8px 16px !important;
  font-size: 15px !important;
  font-weight: 800 !important;
  letter-spacing: 0.02em;
  border-radius: 999px !important;
}

/* ===================================
   BRAPI — EMPTY STATE
   =================================== */

.brapi-empty-state {
  padding: 20px;
  text-align: center;
  color: rgba(180, 200, 255, 0.45);
  font-size: 13px;
  font-style: italic;
}

/* ===================================
   BRAPI — RESPONSIVE (new layout)
   =================================== */

@media (max-width: 960px) {
  .brapi-quote-panel {
    grid-template-columns: 1fr;
  }
  .brapi-qp-left {
    border-right: none;
    border-bottom: 1px solid rgba(255,255,255,0.07);
  }
  .brapi-qp-stats {
    grid-template-columns: repeat(3, 1fr);
    border-left: none;
    border-top: 1px solid rgba(255,255,255,0.07);
    padding-top: 16px;
  }
  .brapi-qp-select {
    border-left: none;
    border-top: 1px solid rgba(255,255,255,0.07);
  }
  .brapi-qstat {
    border-right: none;
    padding: 8px 0;
  }
  .brapi-mid-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 680px) {
  .brapi-qp-stats {
    grid-template-columns: repeat(2, 1fr);
  }
  .brapi-qp-price {
    font-size: 28px;
  }
}

.table-wrap .table:not(.ranking-campaign-table) td.num-cell {
    text-align: right;
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum";
}

.table-wrap .table:not(.ranking-campaign-table) th.num-cell {
    text-align: right;
}

.table-wrap .table:not(.ranking-campaign-table) td.num-cell.pos {
    color: #0f172a;
}

.table-wrap .table:not(.ranking-campaign-table) td.num-cell.neg {
    color: #991b1b;
}

.churn-pill {
    display: inline-block;
    min-width: 64px;
    padding: 3px 8px;
    border-radius: 999px;
    text-align: center;
    font-weight: 700;
    font-size: 12px;
}

.churn-pill.churn-low {
    background: #ecfdf5;
    color: #065f46;
}

.churn-pill.churn-mid {
    background: #fff7ed;
    color: #9a3412;
}

.churn-pill.churn-high {
    background: #fee2e2;
    color: #991b1b;
}

.gestao-clean-table td:first-child,
.gestao-clean-table th:first-child {
    font-weight: 700;
}

.magnet-cover-table,
.magnet-main-table {
    min-width: 100%;
}

.magnet-cover-table th,
.magnet-cover-table td,
.magnet-main-table th,
.magnet-main-table td {
    white-space: nowrap;
    vertical-align: middle;
}

.magnet-cover-table th,
.magnet-cover-table td {
    padding: 12px 14px;
}

.magnet-main-table th,
.magnet-main-table td {
    padding: 12px 14px;
}

.magnet-assessor-cell {
    min-width: 220px;
    white-space: normal !important;
    line-height: 1.35;
}

.magnet-cliente-cell {
    min-width: 280px;
    white-space: normal !important;
    line-height: 1.35;
}

.magnet-conta-cell {
    min-width: 110px;
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum";
}

.mesa-perf-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.5fr) minmax(320px, 0.9fr);
    gap: 16px;
    margin-top: 16px;
}

.mesa-perf-filters {
    display: grid;
    grid-template-columns: minmax(180px, 220px) minmax(180px, 220px) minmax(280px, 1fr);
    gap: 12px;
    align-items: end;
}

.mesa-perf-filter {
    min-width: 0;
}

.mesa-perf-filter-wide {
    min-width: 0;
}

.mesa-perf-filter-label {
    font-size: 12px;
    color: #64748b;
    font-weight: 700;
    margin-bottom: 6px;
}

.mesa-perf-chart-card {
    min-height: 360px;
}

.mesa-perf-chart-wrap {
    position: relative;
    width: 100%;
    height: 300px;
}

.stat-sub {
    margin-top: 4px;
    font-size: 12px;
    color: #94a3b8;
}

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

    .mesa-perf-filters {
        grid-template-columns: 1fr;
    }
}

.magnet-date-cell {
    min-width: 110px;
}

.magnet-tipo-cell {
    min-width: 210px;
    white-space: normal !important;
    line-height: 1.35;
}

.farol-dot {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 999px;
    box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.2);
}

.farol-dot.farol-verde {
    background: #22c55e;
}

.farol-dot.farol-amarelo {
    background: #f59e0b;
}

.farol-dot.farol-vermelho {
    background: #ef4444;
}

/* ===================================
   PERFORMANCE TABLE
   =================================== */
.performance-table {
    display: flex;
    flex-direction: column;
}

.performance-header,
.performance-row {
    display: grid;
    grid-template-columns: 60px 2fr 1fr 1.5fr 1.2fr 0.8fr 1.3fr;
    align-items: center;
    padding: 1rem 1.5rem;
    gap: 1rem;
}

.performance-header {
    background: var(--bg-tertiary);
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    position: sticky;
    top: 0;
    z-index: 10;
}

.performance-row {
    border-bottom: 1px solid var(--border-light);
    transition: all var(--transition-fast);
}

.performance-row:hover {
    background: var(--bg-secondary);
}

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

@media (max-width: 1200px) {
    .performance-header,
    .performance-row {
        grid-template-columns: 60px 2fr 1fr 1.5fr;
    }
    
    .performance-header > div:nth-child(n+5),
    .performance-row > div:nth-child(n+5) {
        display: none;
    }
}

@media (max-width: 768px) {
    .performance-header {
        display: none;
    }
    
    .performance-row {
        grid-template-columns: 1fr;
        padding: 1.5rem;
        gap: 0.75rem;
    }
    
    .performance-row > div {
        display: flex;
        justify-content: space-between;
        align-items: center;
    }
    
    .performance-row > div:before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--text-secondary);
        font-size: 0.875rem;
    }
}

/* ===================================
   GRID LAYOUTS
   =================================== */
.home-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 1.5rem;
}

/* ===================================
   MODAL
   =================================== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 2rem;
    animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.modal-content {
    background: white;
    border-radius: 20px;
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    box-shadow: var(--shadow-xl);
    animation: slideUpModal 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideUpModal {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 10px;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition-fast);
    z-index: 1;
}

.modal-close:hover {
    background: var(--border-medium);
    color: var(--text-primary);
}

#modalBody {
    padding: 2rem;
}

/* ===================================
   TOAST NOTIFICATIONS
   =================================== */
.toast-container {
    position: fixed;
    top: 2rem;
    right: 2rem;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.toast {
    background: white;
    border-radius: 12px;
    padding: 1rem 1.5rem;
    box-shadow: var(--shadow-xl);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 300px;
    animation: slideInRight 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(100px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

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

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

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

/* ===================================
   ADMIN-ONLY ELEMENTS
   =================================== */
body:not(.is-admin) .admin-only {
    display: none !important;
}

.brapi-access-only {
    display: none !important;
}

body.is-admin .brapi-access-only,
body.has-brapi .brapi-access-only {
    display: flex !important;
}

body:not(.is-admin):not(.is-gestor) .gestor-admin-only {
    display: none !important;
}

/* Rota /ranking — esconde outras tabs e seções da Gestão, mostra só Ranking */
body.ranking-only-mode #gestaoTabNnm,
body.ranking-only-mode #gestaoTabClientes,
body.ranking-only-mode #gestaoTabPipeline,
body.ranking-only-mode #gestaoTabIntensidade,
body.ranking-only-mode #gestaoTabNecton,
body.ranking-only-mode #gestaoTabMagnet {
    display: none !important;
}
body.ranking-only-mode #gestaoTabRanking {
    pointer-events: none;
    opacity: 1 !important;
}
body.ranking-only-mode #gestaoExclusoesCard {
    display: none !important;
}

.performance-access-only {
    display: none;
}

body.is-admin .performance-access-only,
body.has-mesa-perf .performance-access-only {
    display: flex !important;
}

.alocacao-access-only {
    display: none;
}

body.has-alocacao .alocacao-access-only,
body.is-admin .alocacao-access-only {
    display: flex !important;
}

body.is-admin .nav-item[data-page="home"],
body.is-admin .nav-item[data-page="auc"],
body.is-admin .nav-item[data-page="clientes"],
body.is-admin .nav-item[data-page="documentos"] {
    display: none !important;
}

body.is-admin .nav-item[data-page="nnm"] {
    display: flex !important;
}

body.is-admin .nav-item[data-page="mesa-performance"],
body.is-admin .nav-item[data-page="avisos"],
body.is-admin .nav-item[data-page="gestao"],
body.is-admin .nav-item[data-page="usuarios"] {
    display: flex !important;
}

.external-module-shell {
    overflow: hidden;
}

.external-module-frame {
    width: 100%;
    min-height: 78vh;
    border: 0;
    background: #fff;
    display: block;
}

.mesa-perf-frame {
    width: 100%;
    min-height: 82vh;
    border: 0;
    border-radius: 12px;
    background: #fff;
    display: block;
}

.alocacao-frame {
    width: 100%;
    min-height: 70vh;
    border: 0;
    border-radius: 12px;
    background: #0a1628;
    display: block;
}

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

.alocacao-page-compact {
    margin: -2rem;
    padding: 0;
    min-height: calc(100vh + 4rem);
}

.alocacao-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.alocacao-header h1 {
    margin-bottom: 4px;
}

.alocacao-header p {
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.alocacao-source {
    font-size: 12px;
    color: var(--text-muted);
}

.alocacao-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.alocacao-frame-wrap {
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--border-color);
    min-height: calc(100vh - 240px);
}

.alocacao-frame {
    height: calc(100vh - 240px);
}

.alocacao-frame-wrap-full {
    min-height: calc(100vh + 4rem);
    height: calc(100vh + 4rem);
    border-radius: 0;
    border: 0;
    background: transparent;
}

.alocacao-frame-wrap-full .alocacao-frame {
    height: 100%;
    border-radius: 0;
}

@media (max-width: 900px) {
    .alocacao-frame-wrap {
        min-height: 70vh;
    }
    .alocacao-frame {
        height: 70vh;
    }
    .alocacao-frame-wrap-full {
        min-height: 75vh;
    }
    .alocacao-frame-wrap-full .alocacao-frame {
        height: 75vh;
    }
    .alocacao-page-compact {
        margin: -1rem;
        min-height: calc(100vh + 2rem);
    }
}

.mesa-perf-notice {
    display: none;
    margin-bottom: 12px;
    padding: 12px 14px;
    border-radius: 10px;
    border: 1px solid transparent;
    font-size: 14px;
    line-height: 1.4;
}

.mesa-perf-notice-info {
    color: #1d4ed8;
    background: #eff6ff;
    border-color: #bfdbfe;
}

.mesa-perf-notice-warning {
    color: #92400e;
    background: #fffbeb;
    border-color: #fcd34d;
}

.mesa-perf-notice-success {
    color: #166534;
    background: #f0fdf4;
    border-color: #86efac;
}

/* ===================================
   CHART CONTAINER
   =================================== */
.chart-container {
    position: relative;
    height: 300px;
    margin: 1rem 0;
}

/* ===================================
   MOBILE SIDEBAR TOGGLE
   =================================== */
.sidebar-toggle {
    display: none;
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 1100;
    background: var(--bg-primary);
    border: 1px solid var(--border-light);
    border-radius: 10px;
    padding: 8px;
    cursor: pointer;
    box-shadow: var(--shadow-md);
    color: var(--text-primary);
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 999;
}

.sidebar-overlay.active {
    display: block;
}

/* ===================================
   RESPONSIVE
   =================================== */
@media (max-width: 1024px) {
    .sidebar-toggle {
        display: flex;
    }

    .sidebar {
        transform: translateX(-100%);
        transition: transform var(--transition-base);
        z-index: 1000;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
    }
    
    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    }
    
    .home-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .main-content {
        padding: 1rem;
    }
    
    .page-title {
        font-size: 1.5rem;
    }
    
    .table-header {
        display: none;
    }
    
    .table-row {
        grid-template-columns: 1fr;
        padding: 1rem;
    }
    
    .docs-grid {
        grid-template-columns: 1fr;
    }
}

.mesa-perf-page {
  max-width: 1600px;
}

.mesa-perf-shell {
  display: grid;
  gap: 12px;
  margin-bottom: 12px;
}

.mesa-perf-heading {
  display: grid;
  gap: 4px;
}

.mesa-perf-title {
  margin: 0;
  font-size: 2rem;
  font-weight: 800;
  color: #0f172a;
}

.mesa-perf-subtitle {
  margin: 0;
  color: #64748b;
  font-size: 1.05rem;
}

.mesa-perf-top-card,
.mesa-perf-panel {
  background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
  border: 1px solid #dbe7fb;
  border-radius: 22px;
  padding: 14px 16px;
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.06);
}

.mesa-perf-assessor-field {
  margin-bottom: 0;
}

.mesa-perf-tabs-wide {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
  background: #f6f8fc;
  border: 1px solid #dbe3f2;
  border-radius: 18px;
  padding: 4px;
}

.mesa-perf-tab {
  border: 0;
  background: transparent;
  color: #0f172a;
  font: inherit;
  font-weight: 700;
  padding: 12px 14px;
  border-radius: 14px;
  cursor: pointer;
  transition: background .18s ease, color .18s ease, transform .18s ease;
}

.mesa-perf-tab.active {
  background: #157f78;
  color: #fff;
}

.mesa-perf-toolbar-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.mesa-perf-filter-grid-exec {
  grid-template-columns: repeat(2, minmax(240px, 1fr));
}

.mesa-perf-filter-grid-proj {
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(240px, 320px) 1fr minmax(180px, 220px);
  align-items: end;
}

.mesa-perf-kpi-grid {
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.mesa-perf-category-grid-exec {
  padding-top: 8px;
  gap: 8px;
}

.mesa-perf-category-grid-proj {
  gap: 12px 18px;
}

.mesa-perf-check-compact {
  padding: 6px 10px;
  font-size: 0.88rem;
}

.mesa-perf-check-plain {
  border: none;
  background: transparent;
  padding: 0;
  border-radius: 0;
}

.mesa-perf-helper-text {
  margin-bottom: 12px;
  color: #64748b;
  line-height: 1.5;
}

.mesa-perf-compact-header {
  align-items: center;
  gap: 12px;
}

.mesa-perf-sim-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.mesa-perf-sim-main-table .data-table th,
.mesa-perf-sim-main-table .data-table td,
.mesa-perf-sim-side-table .data-table th,
.mesa-perf-sim-side-table .data-table td {
  white-space: nowrap;
}

.mesa-perf-sim-main-table .input,
.mesa-perf-sim-side-table .input {
  min-width: 0;
}

.mesa-perf-panel .table-container {
  overflow-x: auto;
}

.mesa-perf-panel table.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: auto;
  background: #fff;
  border: 1px solid #dbe7fb;
  border-radius: 16px;
  overflow: hidden;
}

.mesa-perf-panel table.data-table thead th {
  background: #eef5ff;
  color: #0f172a;
  font-size: 0.84rem;
  font-weight: 700;
  text-transform: none;
  letter-spacing: 0;
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid #dbe7fb;
}

.mesa-perf-panel table.data-table tbody td {
  padding: 10px 12px;
  border-top: 1px solid #edf2f7;
  vertical-align: middle;
}

.mesa-perf-panel table.data-table tbody tr:first-child td {
  border-top: none;
}

.mesa-perf-panel table.data-table .input {
  width: 100%;
}

.mesa-perf-subblock-title {
  margin-top: 18px;
  font-size: 1rem;
  font-weight: 700;
  color: #0f172a;
}

.mesa-perf-chart-card {
  overflow: hidden;
}

.mesa-perf-chart-card-light {
  border-color: #dbe7fb;
}

.mesa-perf-chart-card-dark {
  background: #050b18;
  border: 1px solid #0f1a31;
}

.mesa-perf-chart-card-dark .card-header,
.mesa-perf-chart-card-dark .card-body {
  background: transparent;
}

.mesa-perf-chart-card-dark .card-title {
  color: #ffffff;
}

.mesa-perf-canvas-wrap-xl {
  min-height: 420px;
}

.mesa-perf-table-action {
  white-space: nowrap;
}

.mesa-perf-horizon-field {
  display: grid;
  gap: 8px;
}

.mesa-perf-horizon-label {
  font-size: .9rem;
  font-weight: 600;
  color: #334155;
}

.mesa-perf-horizon-wrap {
  display: grid;
  grid-template-columns: 1fr 72px;
  gap: 12px;
  align-items: center;
}

.mesa-perf-horizon-slider {
  width: 100%;
  accent-color: #8b5cf6;
}

.mesa-perf-horizon-value {
  text-align: center;
  padding-left: .5rem;
  padding-right: .5rem;
}

.mesa-perf-horizon-scale {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 6px;
  color: #94a3b8;
  font-size: .78rem;
  text-align: center;
}

@media (max-width: 960px) {
  .mesa-perf-filter-grid-proj,
  .mesa-perf-filter-grid-exec {
    grid-template-columns: 1fr;
  }

  .mesa-perf-sim-grid {
    grid-template-columns: 1fr;
  }

  .mesa-perf-tabs-wide {
    grid-template-columns: 1fr;
  }

  .mesa-perf-horizon-wrap {
    grid-template-columns: 1fr;
  }
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.metrics-grid-compact {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.metric-card {
  background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
  border: 1px solid #dbe7fb;
  border-radius: 20px;
  padding: 16px 18px;
  box-shadow: 0 16px 36px rgba(15, 23, 42, 0.06);
  display: grid;
  gap: 8px;
  min-height: 132px;
}

.metric-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.metric-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: #5f7190;
  line-height: 1.35;
}

.metric-value {
  font-family: 'Space Grotesk', sans-serif;
  font-size: clamp(1.6rem, 2vw, 2.2rem);
  font-weight: 800;
  color: #0f172a;
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.metric-footer {
  font-size: 0.88rem;
  color: #94a3b8;
  line-height: 1.45;
}

/* ===================================
   DARK MODE TOGGLE BUTTON
   =================================== */

/* Wrapper for positioning the hint tooltip */
.dark-mode-wrap {
  position: relative;
  flex-shrink: 0;
}

/* Hint tooltip bubble */
.dark-mode-hint {
  position: absolute;
  bottom: calc(100% + 10px);
  right: 0;
  background: #1e3a6e;
  color: #e7edff;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.4;
  padding: 8px 13px;
  border-radius: 10px;
  white-space: nowrap;
  box-shadow: 0 6px 20px rgba(0, 0, 60, 0.35);
  border: 1px solid rgba(110, 168, 255, 0.3);
  z-index: 200;
  pointer-events: none;
  animation: dm-hint-in 0.3s ease forwards;
}

/* Arrow pointing down at the button */
.dark-mode-hint::after {
  content: "";
  position: absolute;
  top: 100%;
  right: 11px;
  border: 6px solid transparent;
  border-top-color: #1e3a6e;
}

@keyframes dm-hint-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Pulsing badge dot on the button */
.dark-mode-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 8px;
  height: 8px;
  background: #6ea8ff;
  border-radius: 50%;
  border: 1.5px solid #fff;
  display: none;
  animation: dm-badge-pulse 1.6s ease-in-out infinite;
}

.dark-mode-btn.has-hint .dark-mode-badge {
  display: block;
}

@keyframes dm-badge-pulse {
  0%, 100% { transform: scale(1);   opacity: 1; }
  50%       { transform: scale(1.5); opacity: 0.6; }
}

.dark-mode-btn {
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  border: none;
  border-radius: 10px;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
  flex-shrink: 0;
  position: relative;
}

.dark-mode-btn:hover {
  background: #fef9c3;
  color: #b45309;
}

.dark-mode-btn .icon-sun { display: none; }
.dark-mode-btn .icon-moon { display: block; }

.dark-mode-btn.is-dark .icon-sun { display: block; }
.dark-mode-btn.is-dark .icon-moon { display: none; }

[data-theme="dark"] .dark-mode-btn:hover {
  background: rgba(99,145,255,0.16);
  color: #93bbff;
}

/* ===================================
   DARK MODE — VARIABLE OVERRIDES
   =================================== */

[data-theme="dark"] {
  --bg-primary: #1e2538;
  --bg-secondary: #141824;
  --bg-tertiary: #1e2538;
  --bg-elevated: #1e2538;
  --text-primary: #dde8ff;
  --text-secondary: #8a9dbf;
  --text-muted: #566070;
  --border-light: rgba(255,255,255,0.08);
  --border-medium: rgba(255,255,255,0.14);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.4);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.5);
  --shadow-lg: 0 10px 30px rgba(0,0,0,0.6);
  --shadow-xl: 0 20px 48px rgba(0,0,0,0.7);
}

/* ===================================
   DARK MODE — STRUCTURAL OVERRIDES
   =================================== */

[data-theme="dark"] body {
  background: #141824;
}

[data-theme="dark"] .sidebar-header {
  background: #1e2538;
}

[data-theme="dark"] .nav-item:hover {
  background: rgba(255,255,255,0.055);
  color: #dde8ff;
}

[data-theme="dark"] .nav-divider {
  background: rgba(255,255,255,0.07);
}

[data-theme="dark"] .logout-btn:hover {
  background: rgba(239,68,68,0.18);
  color: #f87171;
}

/* Mais contraste pros botoes da sidebar-footer no dark mode */
[data-theme="dark"] .logout-btn,
[data-theme="dark"] .dark-mode-btn {
  background: rgba(255,255,255,0.06);
  color: #cbd5e1;
  border: 1px solid rgba(255,255,255,0.10);
}

/* ===================================
   DARK MODE — CARDS & STAT CARDS
   =================================== */

[data-theme="dark"] .card {
  background: #1e2538;
  border-color: rgba(255,255,255,0.07);
  box-shadow: 0 2px 12px rgba(0,0,0,0.35);
}

[data-theme="dark"] .card-header {
  border-bottom-color: rgba(255,255,255,0.07);
}

[data-theme="dark"] .card-title {
  color: #dde8ff;
}

[data-theme="dark"] .stat-card {
  background: #0e1523;
  border-color: rgba(99, 145, 255, 0.14);
  box-shadow: 0 2px 16px rgba(0, 0, 0, 0.35);
}

[data-theme="dark"] .stat-card:hover {
  border-color: rgba(99, 145, 255, 0.32);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.5);
}

[data-theme="dark"] .stat-label {
  color: rgba(160, 185, 230, 0.7);
}

/* Fix: class is .stat-val, not .stat-value */
[data-theme="dark"] .stat-val {
  color: #e8f2ff;
}

[data-theme="dark"] .stat-change {
  color: rgba(160, 185, 230, 0.6);
  font-size: 0.75rem;
}

/* Accent border per card type — dark mode only */
[data-theme="dark"] .stat-card--nnm {
  border-top: 3px solid #4ade80;
}
[data-theme="dark"] .stat-card--auc {
  border-top: 3px solid #6ea8ff;
}
[data-theme="dark"] .stat-card--avg {
  border-top: 3px solid #f59e0b;
}

/* ===================================
   DARK MODE — TABLES
   =================================== */

[data-theme="dark"] .table-wrap {
  background: #1e2538;
  border-color: rgba(255,255,255,0.07);
}

[data-theme="dark"] .table th {
  background: #252e45;
  color: #7a8fa8;
  border-color: rgba(255,255,255,0.07);
}

[data-theme="dark"] .table td {
  border-color: rgba(255,255,255,0.05);
  color: #c8d8f0;
}

[data-theme="dark"] .table tbody tr:hover td {
  background: rgba(255,255,255,0.04) !important;
}

[data-theme="dark"] .table tbody tr:nth-child(even) td {
  background: rgba(255,255,255,0.02);
}

/* ===================================
   DARK MODE — FORMS & INPUTS
   =================================== */

[data-theme="dark"] input,
[data-theme="dark"] input[type="text"],
[data-theme="dark"] input[type="date"],
[data-theme="dark"] input[type="email"],
[data-theme="dark"] input[type="number"],
[data-theme="dark"] input[type="password"],
[data-theme="dark"] select,
[data-theme="dark"] textarea {
  background: #252e45 !important;
  color: #c8d8f0 !important;
  border-color: rgba(255,255,255,0.14) !important;
}

[data-theme="dark"] input::placeholder,
[data-theme="dark"] textarea::placeholder {
  color: #4a5a72;
}

[data-theme="dark"] input:focus,
[data-theme="dark"] select:focus,
[data-theme="dark"] textarea:focus {
  border-color: rgba(99,145,255,0.5) !important;
  box-shadow: 0 0 0 3px rgba(99,145,255,0.12) !important;
  outline: none;
}

[data-theme="dark"] .form-group label {
  color: #8a9dbf;
}

/* ===================================
   DARK MODE — BUTTONS
   =================================== */

[data-theme="dark"] .btn-secondary {
  background: #252e45;
  color: #93b4d8;
  border-color: rgba(255,255,255,0.14);
}

[data-theme="dark"] .btn-secondary:hover {
  background: #2e3a58;
  border-color: rgba(99,145,255,0.4);
  color: #b8d0f0;
}

/* ===================================
   DARK MODE — PAGE & PAGE ELEMENTS
   =================================== */

[data-theme="dark"] .page {
  color: #c8d8f0;
}

[data-theme="dark"] .page h1,
[data-theme="dark"] .page h2,
[data-theme="dark"] .page h3 {
  color: #dde8ff;
}

[data-theme="dark"] .page-header-row p,
[data-theme="dark"] .page p {
  color: #7a8fa8;
}

[data-theme="dark"] .section-title {
  color: #dde8ff;
}

[data-theme="dark"] .modal-content {
  background: #1e2538;
  border: 1px solid rgba(255,255,255,0.1);
  color: #c8d8f0;
}

[data-theme="dark"] .modal-content h2,
[data-theme="dark"] .modal-content h3 {
  color: #dde8ff;
}

[data-theme="dark"] .modal-close {
  color: #8a9dbf;
}

[data-theme="dark"] .modal-close:hover {
  background: rgba(255,255,255,0.08);
  color: #dde8ff;
}

/* ===================================
   DARK MODE — TOAST
   =================================== */

[data-theme="dark"] .toast {
  background: #252e45;
  border-color: rgba(255,255,255,0.1);
  color: #c8d8f0;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}

/* ===================================
   DARK MODE — BRAPI PAGE LIGHT ELEMENTS
   =================================== */

[data-theme="dark"] .brapi-page {
  background: transparent;
}

[data-theme="dark"] .brapi-title h1 {
  color: #dde8ff;
}

[data-theme="dark"] .brapi-title p {
  color: #8a9dbf;
}

[data-theme="dark"] .brapi-panel {
  background: #1e2538;
  border-color: rgba(255,255,255,0.07);
}

[data-theme="dark"] .brapi-panel-header {
  border-bottom-color: rgba(255,255,255,0.07);
}

[data-theme="dark"] .brapi-panel-title {
  color: #dde8ff;
}

[data-theme="dark"] .brapi-panel-sub {
  color: #566070;
}

[data-theme="dark"] .brapi-mover-row {
  background: #252e45;
  border-color: rgba(255,255,255,0.07);
}

[data-theme="dark"] .brapi-mover-row:hover {
  background: #2e3a58;
  border-color: rgba(99,145,255,0.28);
}

[data-theme="dark"] .brapi-mover-rank {
  color: #4a5a72;
}

[data-theme="dark"] .brapi-mover-sym {
  color: #c8d8f0;
}

[data-theme="dark"] .brapi-mover-track {
  background: rgba(255,255,255,0.08);
}

[data-theme="dark"] .brapi-rpill {
  background: #252e45;
  border-color: rgba(255,255,255,0.12);
  color: #7a9ac0;
}

[data-theme="dark"] .brapi-rpill:hover {
  background: #2e3a58;
  border-color: rgba(99,145,255,0.4);
  color: #b8d0f0;
}

[data-theme="dark"] .brapi-table-wrap {
  background: #1e2538;
  border-color: rgba(255,255,255,0.07);
}

[data-theme="dark"] .brapi-table thead th {
  color: #566070;
}

[data-theme="dark"] .brapi-table tbody tr {
  background: #252e45;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.05);
}

[data-theme="dark"] .brapi-table tbody tr:hover {
  background: #2e3a58;
}

[data-theme="dark"] .brapi-td-ticker {
  color: #93bbff !important;
}

[data-theme="dark"] .brapi-td-name {
  color: #6a7f9a;
}

[data-theme="dark"] .brapi-tr-up td   { background: rgba(34,197,94,0.07) !important; }
[data-theme="dark"] .brapi-tr-down td { background: rgba(239,68,68,0.07) !important; }
[data-theme="dark"] .brapi-tr-flat td { background: #252e45 !important; }

[data-theme="dark"] .brapi-tr-up:hover td   { background: rgba(34,197,94,0.14) !important; }
[data-theme="dark"] .brapi-tr-down:hover td { background: rgba(239,68,68,0.14) !important; }
[data-theme="dark"] .brapi-tr-flat:hover td { background: #2e3a58 !important; }

[data-theme="dark"] .brapi-refresh-btn {
  background: #252e45;
  border-color: rgba(255,255,255,0.12);
  color: #7a9ac0;
}

[data-theme="dark"] .brapi-refresh-btn:hover {
  background: #2e3a58;
  border-color: rgba(99,145,255,0.4);
  color: #93bbff;
}

[data-theme="dark"] .brapi-updated-label {
  color: #4a5a72;
}

[data-theme="dark"] .brapi-filter-group label {
  color: #566070;
}

[data-theme="dark"] .brapi-filter-group input[type="date"] {
  background: #252e45 !important;
  border-color: rgba(255,255,255,0.12) !important;
  color: #c8d8f0 !important;
}

/* Dark overrides for other pages that use light cards */
[data-theme="dark"] .overview-card,
[data-theme="dark"] .brapi-overview-card {
  background: #1e2538;
  border-color: rgba(255,255,255,0.07);
}

[data-theme="dark"] .brapi-overview-title {
  color: #dde8ff;
}

[data-theme="dark"] .brapi-stat {
  background: #252e45;
  border-color: rgba(255,255,255,0.07);
}

[data-theme="dark"] .brapi-stat .label {
  color: #566070;
}

[data-theme="dark"] .brapi-stat strong {
  color: #c8d8f0;
}

/* ===================================
   DARK MODE — TRANSITIONS
   =================================== */

html {
  transition: background-color 0.25s ease, color 0.25s ease;
}

.sidebar,
.main-content,
.card,
.stat-card,
.table-wrap,
.brapi-panel,
.brapi-table-wrap {
  transition: background-color 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
}

/* ===================================
   SKELETON LOADER
   =================================== */

:root {
  --skel-base: #eef2f7;
  --skel-shine: #f4f7fc;
}
[data-theme="dark"] {
  --skel-base: #1e2538;
  --skel-shine: #252e45;
}

@keyframes skel-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skel-block {
  border-radius: 8px;
  background: linear-gradient(90deg, var(--skel-base) 25%, var(--skel-shine) 50%, var(--skel-base) 75%);
  background-size: 200% 100%;
  animation: skel-shimmer 1.4s ease-in-out infinite;
}

.skel-header {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 20px;
}

.skel-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.skel-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border-light);
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: var(--shadow-sm);
}

.skel-chart-block {
  height: 240px;
  padding: 0;
  overflow: hidden;
}

.skel-chart-block .skel-block {
  height: 100%;
  border-radius: 16px;
}

.skel-tr {
  display: grid;
  grid-template-columns: 2fr 3fr 1.2fr 1fr;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-light);
  align-items: center;
}

.skel-tr:last-child { border-bottom: none; }

/* ===================================
   EMPTY STATE
   =================================== */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 52px 24px;
  gap: 10px;
  text-align: center;
}

.empty-state-icon {
  color: var(--text-muted);
  opacity: 0.45;
  margin-bottom: 4px;
}

.empty-state-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-secondary);
}

.empty-state-sub {
  font-size: 13px;
  color: var(--text-muted);
  max-width: 340px;
  line-height: 1.55;
}

/* ===================================
   ERROR STATE
   =================================== */

.error-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 52px 28px;
  gap: 12px;
  text-align: center;
  max-width: 480px;
  margin: 32px auto;
  background: var(--bg-elevated);
  border: 1px solid var(--border-light);
  border-radius: 20px;
  box-shadow: var(--shadow-sm);
}

.error-state-icon { color: var(--accent-red); opacity: 0.75; }
.error-state-title { font-size: 16px; font-weight: 700; color: var(--text-primary); }
.error-state-msg {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.55;
  max-width: 360px;
}

/* ===================================
   SORTABLE TABLE HEADERS
   =================================== */

.th-sort {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  transition: color 0.12s, background 0.12s;
}

.th-sort:hover {
  color: var(--accent-blue) !important;
  background: rgba(59, 130, 246, 0.06) !important;
}

.th-sort-active {
  color: var(--accent-blue) !important;
}

.sort-icon {
  display: inline-block;
  font-size: 10px;
  opacity: 0.45;
  margin-left: 4px;
  vertical-align: middle;
  font-style: normal;
  transition: opacity 0.12s;
}

.th-sort:hover .sort-icon,
.th-sort-active .sort-icon {
  opacity: 1;
}

/* ===================================
   TABLE TOOLBAR (search + export row)
   =================================== */

.table-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.table-toolbar-left  { display: flex; gap: 8px; flex-wrap: wrap; flex: 1; }
.table-toolbar-right { display: flex; gap: 8px; flex-shrink: 0; }

.btn-export {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 10px;
  border: 1.5px solid var(--border-medium);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  white-space: nowrap;
}

.btn-export:hover {
  background: var(--bg-tertiary);
  border-color: var(--accent-blue);
  color: var(--accent-blue);
}

.btn-export svg { flex-shrink: 0; }

/* ===================================
   PAGE HEADER ROW (title + actions)
   =================================== */

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

.page-header-row h1 { margin: 0; }
.page-header-row .page-sub { margin-top: 4px; font-size: 13px; color: var(--text-muted); }

/* ===================================
   TABLE SEARCH INPUT (inside toolbar)
   =================================== */

.table-search-wrap {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px;
  border: 1.5px solid var(--border-medium);
  border-radius: 10px;
  background: var(--bg-elevated);
  transition: border-color 0.15s;
}

.table-search-wrap svg { color: var(--text-muted); flex-shrink: 0; }

.table-search-wrap:focus-within {
  border-color: var(--accent-blue);
}

.table-search-input {
  border: none;
  outline: none;
  background: transparent;
  font-size: 12px;
  color: var(--text-primary);
  width: 160px;
}

.table-search-input::placeholder { color: var(--text-muted); }

/* BRAPI table header: space out title and search */
.brapi-table-hdr {
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

.brapi-table-search-wrap {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px;
  border: 1.5px solid var(--border-medium);
  border-radius: 10px;
  background: var(--bg-elevated);
  transition: border-color 0.15s;
}

.brapi-table-search-wrap svg { color: var(--text-muted); flex-shrink: 0; }
.brapi-table-search-wrap:focus-within { border-color: var(--accent-blue); }

.brapi-table-search {
  border: none;
  outline: none;
  background: transparent;
  font-size: 12px;
  color: var(--text-primary);
  width: 180px;
}

.brapi-table-search::placeholder { color: var(--text-muted); }

/* Active state for range pills */
.brapi-rpill-active,
.brapi-rpill.active {
  background: #1e3a6e;
  border-color: #1e3a6e;
  color: #fff;
}

[data-theme="dark"] .table-search-input,
[data-theme="dark"] .brapi-table-search { color: var(--text-primary); }

[data-theme="dark"] .brapi-rpill-active,
[data-theme="dark"] .brapi-rpill.active {
  background: #3b5bdb;
  border-color: #3b5bdb;
}

/* ===================================
   BRAPI — SECTOR PANEL
   =================================== */

.brapi-sector-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 2fr);
  gap: 16px;
  margin-bottom: 16px;
  align-items: start;
}

/* Override fixed height from .brapi-chart-card */
.brapi-sector-donut-card,
.brapi-variation-card {
  height: auto !important;
  min-height: 0;
}

/* Donut card: vertical layout — chart centered, legend below in 2 cols */
.brapi-sector-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  margin-top: 4px;
}

.brapi-sector-donut-wrap {
  width: clamp(120px, 50%, 160px);
  aspect-ratio: 1;
  position: relative;
  flex-shrink: 0;
}

.brapi-sector-legend {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 12px;
}

.brapi-sector-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  min-width: 0;
}

.brapi-sector-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.brapi-sector-lbl {
  flex: 1;
  color: rgba(200, 215, 255, 0.7);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.brapi-sector-cnt {
  color: #e7edff;
  font-weight: 700;
  font-size: 11px;
  flex-shrink: 0;
}

/* Variation card */
.brapi-variation-card {
  display: flex;
  flex-direction: column;
}

.brapi-sector-pills-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.brapi-sector-pill {
  padding: 4px 11px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.03em;
  border-radius: 999px;
  border: 1.5px solid rgba(120, 150, 200, 0.3);
  background: transparent;
  color: rgba(200, 215, 255, 0.65);
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
  outline: none;
  white-space: nowrap;
}

.brapi-sector-pill:hover {
  opacity: 0.85;
  transform: translateY(-1px);
}

.brapi-sector-pill.active {
  font-weight: 800;
}

.brapi-sector-pill[data-sector=""] {
  border-color: rgba(110, 168, 255, 0.45);
  color: #6ea8ff;
}

.brapi-sector-pill[data-sector=""].active {
  background: rgba(110, 168, 255, 0.2);
}

.brapi-variation-canvas-wrap {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  max-height: 420px;
  position: relative;
}

@media (max-width: 960px) {
  .brapi-sector-row {
    grid-template-columns: 1fr;
  }
  .brapi-sector-legend {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  }
}

/* ===================================
   DARK MODE — MESA PERFORMANCE
   =================================== */

/* Card principal (Assessor + tabs) e painéis */
[data-theme="dark"] .mesa-perf-top-card,
[data-theme="dark"] .mesa-perf-panel {
  background: linear-gradient(180deg, #1a2236 0%, #141b2d 100%);
  border: 1px solid rgba(99, 145, 255, 0.14);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
}

/* Tabs Executivo / Projecao / D0 */
[data-theme="dark"] .mesa-perf-tabs-wide {
  background: #0e1523;
  border-color: rgba(99, 145, 255, 0.16);
}

[data-theme="dark"] .mesa-perf-tab {
  color: #a8baf0;
}

[data-theme="dark"] .mesa-perf-tab:hover {
  background: rgba(99, 145, 255, 0.08);
  color: #dde8ff;
}

[data-theme="dark"] .mesa-perf-tab.active {
  background: #1f9d94;
  color: #fff;
  box-shadow: 0 4px 16px rgba(31, 157, 148, 0.35);
}

/* KPI cards (Receita total, ROA, etc.) */
[data-theme="dark"] .metric-card {
  background: linear-gradient(180deg, #131b2d 0%, #0e1523 100%);
  border: 1px solid rgba(99, 145, 255, 0.14);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.4);
  transition: border-color .2s ease, box-shadow .2s ease, transform .2s ease;
}

[data-theme="dark"] .metric-card:hover {
  border-color: rgba(99, 145, 255, 0.3);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.55);
  transform: translateY(-2px);
}

[data-theme="dark"] .metric-title {
  color: rgba(168, 186, 240, 0.78);
  letter-spacing: 0.2px;
}

[data-theme="dark"] .metric-value {
  color: #e8f2ff;
}

[data-theme="dark"] .metric-footer {
  color: rgba(160, 185, 230, 0.6);
}

/* Acentos coloridos por tipo de KPI Mesa Performance
   (ordem das colunas: Receita total / liquida / recorrente / ROA total / ROA recorrente) */
[data-theme="dark"] .mesa-perf-kpi-grid .metric-card:nth-child(1) { border-top: 3px solid #4ade80; }
[data-theme="dark"] .mesa-perf-kpi-grid .metric-card:nth-child(2) { border-top: 3px solid #34d399; }
[data-theme="dark"] .mesa-perf-kpi-grid .metric-card:nth-child(3) { border-top: 3px solid #6ea8ff; }
[data-theme="dark"] .mesa-perf-kpi-grid .metric-card:nth-child(4) { border-top: 3px solid #f59e0b; }
[data-theme="dark"] .mesa-perf-kpi-grid .metric-card:nth-child(5) { border-top: 3px solid #fb923c; }

/* Labels e texto auxiliar */
[data-theme="dark"] .mesa-perf-filter-label {
  color: rgba(168, 186, 240, 0.75);
}

[data-theme="dark"] .mesa-perf-helper-text {
  color: rgba(160, 185, 230, 0.65);
}

[data-theme="dark"] .mesa-perf-source-note {
  color: rgba(160, 185, 230, 0.6);
}

/* Pills de categorias (checkboxes) */
[data-theme="dark"] .mesa-perf-check {
  color: #c8d8f0;
}

[data-theme="dark"] .mesa-perf-check-plain {
  background: transparent;
}

/* Caixa "Periodo carregado" (div com classe .input) */
[data-theme="dark"] .mesa-perf-filter .input {
  background: #0e1523;
  border: 1px solid rgba(99, 145, 255, 0.16);
  color: #dde8ff;
}

/* Title / subtitle do header da página */
[data-theme="dark"] .mesa-perf-title {
  color: #e8f2ff;
}

[data-theme="dark"] .mesa-perf-subtitle {
  color: rgba(160, 185, 230, 0.7);
}

/* Cards de chart — fundo escuro consistente */
[data-theme="dark"] .mesa-perf-chart-card,
[data-theme="dark"] .mesa-perf-chart-card-light,
[data-theme="dark"] .mesa-perf-chart-card-dark {
  background: linear-gradient(180deg, #1a2236 0%, #141b2d 100%);
  border: 1px solid rgba(99, 145, 255, 0.14);
}

/* ===================================
   DARK MODE — MESA PERFORMANCE / PROJEÇÃO
   =================================== */

/* Subtítulos das seções (Distribuição, Vencimentos, etc.) */
[data-theme="dark"] .mesa-perf-subblock-title {
  color: #dde8ff;
}

/* Tabelas de Projeção (.data-table dentro de .mesa-perf-panel) */
[data-theme="dark"] .mesa-perf-panel table.data-table {
  background: #0e1523;
  border: 1px solid rgba(99, 145, 255, 0.14);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.35);
}

[data-theme="dark"] .mesa-perf-panel table.data-table thead th {
  background: #1a2236;
  color: #c8d8f0;
  border-bottom: 1px solid rgba(99, 145, 255, 0.16);
}

[data-theme="dark"] .mesa-perf-panel table.data-table tbody td {
  color: #c8d8f0;
  border-top: 1px solid rgba(99, 145, 255, 0.08);
}

[data-theme="dark"] .mesa-perf-panel table.data-table tbody tr:hover td {
  background: rgba(99, 145, 255, 0.05);
}

/* .data-table genérica fora do panel (caso apareça em outros lugares) */
[data-theme="dark"] .data-table {
  background: #0e1523;
  border-color: rgba(99, 145, 255, 0.14);
}

[data-theme="dark"] .table-container {
  background: transparent;
}

/* Inputs internos das tabelas (.input dentro do panel) — mantém legibilidade */
[data-theme="dark"] .mesa-perf-panel table.data-table .input {
  background: #1a2236;
  border-color: rgba(99, 145, 255, 0.16);
  color: #e8f2ff;
}

/* Checkbox inline ("Usar vencimentos de Renda Fixa...") */
[data-theme="dark"] .mesa-perf-inline-check {
  color: #c8d8f0;
}

/* ===================================
   MESA PERFORMANCE — D0 (light + dark)
   =================================== */

.d0-section-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin: 6px 0 10px;
  padding: 6px 2px;
  border-bottom: 1px dashed rgba(15, 23, 42, 0.12);
}

.d0-section-title {
  font-size: 0.95rem;
  color: #0f172a;
  font-weight: 600;
}

.d0-section-title strong {
  font-weight: 800;
  color: #0b3b9e;
}

.d0-section-subtitle {
  font-size: 0.8rem;
  color: #64748b;
  margin-top: 2px;
}

.d0-section-meta {
  display: flex;
  align-items: center;
  gap: 8px;
}

.d0-updated-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 9999px;
  background: #ecfdf5;
  color: #047857;
  font-size: 0.78rem;
  font-weight: 600;
}

.d0-updated-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
  animation: d0-pulse 2s ease-in-out infinite;
}

@keyframes d0-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

/* Breakdown por categoria */
.d0-cat-list {
  display: grid;
  gap: 10px;
}

.d0-cat-row {
  display: grid;
  grid-template-columns: minmax(110px, 160px) 1fr minmax(140px, 200px);
  gap: 12px;
  align-items: center;
}

.d0-cat-label {
  font-size: 0.86rem;
  font-weight: 600;
  color: #0f172a;
}

.d0-cat-bar {
  height: 8px;
  background: #f1f5f9;
  border-radius: 9999px;
  overflow: hidden;
}

.d0-cat-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #6366f1 0%, #8b5cf6 100%);
  border-radius: 9999px;
  transition: width .3s ease;
}

.d0-cat-value {
  font-size: 0.85rem;
  font-weight: 700;
  color: #0f172a;
  text-align: right;
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  justify-content: flex-end;
}

.d0-cat-pct {
  font-size: 0.74rem;
  color: #64748b;
  font-weight: 600;
}

@media (max-width: 720px) {
  .d0-cat-row {
    grid-template-columns: 1fr;
    gap: 4px;
  }
  .d0-cat-value {
    justify-content: flex-start;
  }
}

/* Dark mode */
[data-theme="dark"] .d0-section-header {
  border-bottom-color: rgba(99, 145, 255, 0.12);
}

[data-theme="dark"] .d0-section-title {
  color: #dde8ff;
}

[data-theme="dark"] .d0-section-title strong {
  color: #93b4ff;
}

[data-theme="dark"] .d0-section-subtitle {
  color: rgba(160, 185, 230, 0.65);
}

[data-theme="dark"] .d0-updated-pill {
  background: rgba(16, 185, 129, 0.15);
  color: #6ee7b7;
}

[data-theme="dark"] .d0-cat-label {
  color: #dde8ff;
}

[data-theme="dark"] .d0-cat-bar {
  background: rgba(99, 145, 255, 0.1);
}

[data-theme="dark"] .d0-cat-bar-fill {
  background: linear-gradient(90deg, #818cf8 0%, #a78bfa 100%);
}

[data-theme="dark"] .d0-cat-value {
  color: #e8f2ff;
}

[data-theme="dark"] .d0-cat-pct {
  color: rgba(160, 185, 230, 0.6);
}

/* ===================================
   DARK MODE — AVISOS
   =================================== */

/* Toolbar segmentada */
[data-theme="dark"] .avisos-segmented {
  background: linear-gradient(180deg, #141b2d 0%, #0e1523 100%);
  border-color: rgba(99, 145, 255, 0.16);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

[data-theme="dark"] .avisos-tipo-btn {
  color: rgba(168, 186, 240, 0.78);
}

[data-theme="dark"] .avisos-tipo-btn:hover {
  color: #dde8ff;
  background: rgba(99, 145, 255, 0.08);
}

[data-theme="dark"] .avisos-tipo-btn.active {
  color: #c7dbff;
  background: linear-gradient(135deg, #1e3a8a 0%, #1e40af 100%);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] .avisos-tipo-btn .pill-count {
  background: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .avisos-count {
  color: rgba(160, 185, 230, 0.6);
}

/* Composer */
[data-theme="dark"] .avisos-composer {
  background: #1e2538;
  border-color: rgba(99, 145, 255, 0.14);
}

[data-theme="dark"] .avisos-composer-toggle {
  background: linear-gradient(180deg, #1a2236 0%, #141b2d 100%);
  color: #dde8ff;
}

[data-theme="dark"] .avisos-composer-toggle:hover {
  background: linear-gradient(180deg, #1f283f 0%, #161e33 100%);
}

[data-theme="dark"] .avisos-composer-toggle-icon {
  background: rgba(99, 145, 255, 0.15);
  color: #93b4ff;
}

/* Cards */
[data-theme="dark"] .aviso-card {
  background: #1e2538;
  border-color: rgba(99, 145, 255, 0.12);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .aviso-card::before {
  background: rgba(160, 185, 230, 0.25);
}

[data-theme="dark"] .aviso-card[data-tipo="importante"]::before { background: #ef4444; }
[data-theme="dark"] .aviso-card[data-tipo="novidade"]::before  { background: #3b82f6; }
[data-theme="dark"] .aviso-card[data-tipo="info"]::before      { background: #64748b; }

[data-theme="dark"] .aviso-card:hover {
  border-color: rgba(99, 145, 255, 0.28);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.5);
}

[data-theme="dark"] .aviso-card.unread {
  background: linear-gradient(180deg, #1f2a44 0%, #1e2538 70%);
  border-color: rgba(59, 130, 246, 0.32);
}

[data-theme="dark"] .aviso-card.unread .aviso-title {
  color: #e8f2ff;
}

[data-theme="dark"] .aviso-card.lido {
  opacity: 0.78;
}

[data-theme="dark"] .aviso-card.lido .aviso-title {
  color: #a8baf0;
}

[data-theme="dark"] .aviso-title {
  color: #dde8ff;
}

[data-theme="dark"] .aviso-content {
  color: #c8d8f0;
}

[data-theme="dark"] .aviso-date {
  color: rgba(160, 185, 230, 0.6);
}

/* Badges */
[data-theme="dark"] .aviso-badge.importante {
  background: rgba(239, 68, 68, 0.18);
  color: #fca5a5;
}

[data-theme="dark"] .aviso-badge.novidade {
  background: rgba(59, 130, 246, 0.18);
  color: #93c5fd;
}

[data-theme="dark"] .aviso-badge.info {
  background: rgba(148, 163, 184, 0.18);
  color: #cbd5e1;
}

/* Botões de ação */
[data-theme="dark"] .aviso-actions {
  border-top-color: rgba(99, 145, 255, 0.12);
}

[data-theme="dark"] .aviso-action-btn {
  color: rgba(168, 186, 240, 0.78);
}

[data-theme="dark"] .aviso-action-btn:hover {
  background: rgba(99, 145, 255, 0.08);
  color: #e8f2ff;
}

[data-theme="dark"] .aviso-action-btn.primary {
  color: #93b4ff;
}

[data-theme="dark"] .aviso-action-btn.primary:hover {
  background: rgba(99, 145, 255, 0.12);
}

[data-theme="dark"] .aviso-action-btn.danger {
  color: #fca5a5;
}

[data-theme="dark"] .aviso-action-btn.danger:hover {
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.3);
}

[data-theme="dark"] .aviso-lido-marker {
  color: #4ade80;
}

[data-theme="dark"] .aviso-unread-dot {
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25);
}

/* Empty state */
[data-theme="dark"] .avisos-empty {
  background: #141b2d;
  border-color: rgba(99, 145, 255, 0.18);
}

[data-theme="dark"] .avisos-empty-title {
  color: #dde8ff;
}

[data-theme="dark"] .avisos-empty-text {
  color: rgba(160, 185, 230, 0.6);
}

/* ===================================
   DARK MODE — GESTÃO (Ranking + geral)
   =================================== */

/* Ranking table — força dark em qualquer table dentro de card/table-wrap */
[data-theme="dark"] table.table,
[data-theme="dark"] .table-wrap table,
[data-theme="dark"] .card table {
  background: #141b2d !important;
  color: #c8d8f0;
}

[data-theme="dark"] table.table th,
[data-theme="dark"] .table-wrap table th,
[data-theme="dark"] .card table th {
  background: #1a2236 !important;
  color: rgba(168, 186, 240, 0.85);
  border-bottom: 2px solid rgba(99, 145, 255, 0.18);
  border-color: rgba(99, 145, 255, 0.12);
}

[data-theme="dark"] table.table td,
[data-theme="dark"] .table-wrap table td,
[data-theme="dark"] .card table td {
  color: #c8d8f0;
  border-color: rgba(99, 145, 255, 0.06);
  background: transparent;
}

[data-theme="dark"] table.table tbody tr,
[data-theme="dark"] .table-wrap table tbody tr,
[data-theme="dark"] .card table tbody tr {
  background: transparent !important;
}

[data-theme="dark"] table.table tbody tr:nth-child(even),
[data-theme="dark"] .table-wrap table tbody tr:nth-child(even),
[data-theme="dark"] .card table tbody tr:nth-child(even) {
  background: rgba(99, 145, 255, 0.04) !important;
}

/* Scorecard Necton — contraste forte em todas as linhas */
.necton-scorecard-row td,
[data-theme="dark"] .necton-scorecard-row td {
  color: #e5e7eb !important;
  padding: 10px 12px !important;
}

/* FUPs — Carteira de Follow-up (mesma estética do NNM) */
.fups-ranking-table thead th,
[data-theme="dark"] .fups-ranking-table thead th,
[data-theme="dark"] .card .fups-ranking-table thead th,
[data-theme="dark"] .table-wrap .fups-ranking-table thead th {
  color: #ffffff !important;
  font-weight: 700 !important;
  letter-spacing: 0.04em;
}
.fups-ranking-row td,
.fups-cliente-row td,
.leads-row td,
[data-theme="dark"] .fups-ranking-row td,
[data-theme="dark"] .fups-cliente-row td,
[data-theme="dark"] .leads-row td {
  color: #e5e7eb !important;
  padding: 10px 12px !important;
}
[data-theme="dark"] .fups-ranking-table tbody tr.leads-row {
  background: transparent !important;
}
[data-theme="dark"] .fups-ranking-table tbody tr.leads-row:nth-child(even) {
  background: rgba(255, 255, 255, 0.03) !important;
}
[data-theme="dark"] .fups-ranking-table tbody tr.leads-row:hover {
  background: rgba(99, 145, 255, 0.10) !important;
  cursor: pointer;
}
.leads-row td:first-child {
  min-width: 200px;
}
[data-theme="dark"] .fups-ranking-table tbody tr {
  background: transparent !important;
}
[data-theme="dark"] .fups-ranking-table tbody tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.03) !important;
}
[data-theme="dark"] .fups-ranking-table tbody tr:hover {
  background: rgba(99, 145, 255, 0.10) !important;
}
.fups-chip {
  padding: 6px 12px;
  border-radius: 20px;
  border: 1px solid rgba(255,255,255,0.12);
  background: transparent;
  color: #cbd5e1;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}
.fups-chip:hover {
  background: rgba(99, 145, 255, 0.10);
  color: #fff;
}
.fups-chip.active {
  background: #6391ff;
  color: #fff;
  border-color: #6391ff;
  font-weight: 600;
}
[data-theme="dark"] .fups-chip { color: #cbd5e1; }
[data-theme="dark"] .fups-chip.active { color: #fff; background: #6391ff; }

/* NNM Ranking — header e celulas */
.nnm-ranking-table thead th {
  font-weight: 700 !important;
  letter-spacing: 0.04em;
  color: #1f2937;  /* default light: cinza escuro */
}
.nnm-ranking-row td {
  padding: 10px 12px !important;
  color: #1f2937;  /* default light */
}
.nnm-ranking-row td:nth-child(2) {
  font-weight: 600 !important;
  color: #111827;  /* nome do assessor mais forte */
}

/* Dark mode: clareia tudo */
[data-theme="dark"] .nnm-ranking-table thead th,
[data-theme="dark"] .card .nnm-ranking-table thead th,
[data-theme="dark"] .table-wrap .nnm-ranking-table thead th {
  color: #ffffff !important;
}
[data-theme="dark"] .nnm-ranking-row td,
[data-theme="dark"] .table-wrap .nnm-ranking-row td,
[data-theme="dark"] .card .nnm-ranking-row td {
  color: #e5e7eb !important;
}
[data-theme="dark"] .nnm-ranking-row td:nth-child(2) {
  color: #f3f4f6 !important;
}
[data-theme="dark"] .nnm-ranking-table tbody tr.nnm-ranking-row {
  background: transparent !important;
}
[data-theme="dark"] .nnm-ranking-table tbody tr.nnm-ranking-row:nth-child(even) {
  background: rgba(255, 255, 255, 0.03) !important;
}
[data-theme="dark"] .nnm-ranking-table tbody tr.nnm-ranking-row:hover {
  background: rgba(99, 145, 255, 0.10) !important;
}
/* Cabeçalhos das tabelas do Scorecard Necton — letras brancas */
.necton-scorecard-table thead th,
[data-theme="dark"] .necton-scorecard-table thead th,
[data-theme="dark"] .card .necton-scorecard-table thead th,
[data-theme="dark"] .table-wrap .necton-scorecard-table thead th {
  color: #ffffff !important;
  font-weight: 700 !important;
  letter-spacing: 0.04em;
}
[data-theme="dark"] .necton-scorecard-row {
  background: transparent !important;
}
[data-theme="dark"] .necton-scorecard-row:nth-child(even) {
  background: rgba(255, 255, 255, 0.03) !important;
}
.necton-scorecard-row td:first-child {
  min-width: 60px;
}
.necton-scorecard-row td:nth-child(2) {
  min-width: 160px;
  color: #f3f4f6 !important;
  font-weight: 700 !important;
}

[data-theme="dark"] table.table tbody tr:hover,
[data-theme="dark"] .table-wrap table tbody tr:hover,
[data-theme="dark"] .card table tbody tr:hover {
  background: rgba(99, 145, 255, 0.10) !important;
}

/* Medalhas de rank */
[data-theme="dark"] .rank-medal {
  background: #334155;
  color: #c8d8f0;
}

[data-theme="dark"] .rank-medal.medal-gold {
  background: linear-gradient(135deg, #facc15 0%, #eab308 100%);
  color: #111827;
  box-shadow: 0 2px 8px rgba(250, 204, 21, 0.3);
}

[data-theme="dark"] .rank-medal.medal-silver {
  background: linear-gradient(135deg, #cbd5e1 0%, #94a3b8 100%);
  color: #111827;
  box-shadow: 0 2px 8px rgba(148, 163, 184, 0.25);
}

[data-theme="dark"] .rank-medal.medal-bronze {
  background: linear-gradient(135deg, #fb923c 0%, #c2410c 100%);
  color: #fff;
  box-shadow: 0 2px 8px rgba(194, 65, 12, 0.3);
}

/* Points badges */
[data-theme="dark"] .pts-badge {
  background: #1a2236;
  color: #c8d8f0;
}

[data-theme="dark"] .pts-badge.pts-positive {
  background: rgba(34, 197, 94, 0.15);
  color: #86efac;
}

[data-theme="dark"] .pts-badge.pts-negative {
  background: rgba(239, 68, 68, 0.15);
  color: #fca5a5;
}

/* Mini rank badges */
[data-theme="dark"] .mini-rank-badge {
  background: rgba(99, 145, 255, 0.15);
  color: #93b4ff;
}

/* Churn pills */
[data-theme="dark"] .churn-pill {
  background: #1a2236;
  color: #c8d8f0;
}

[data-theme="dark"] .churn-pill.churn-low {
  background: rgba(34, 197, 94, 0.15);
  color: #86efac;
}

[data-theme="dark"] .churn-pill.churn-mid {
  background: rgba(245, 158, 11, 0.15);
  color: #fcd34d;
}

[data-theme="dark"] .churn-pill.churn-high {
  background: rgba(239, 68, 68, 0.15);
  color: #fca5a5;
}

/* Gestao clean table */
[data-theme="dark"] .gestao-clean-table td,
[data-theme="dark"] .gestao-clean-table th {
  color: #e2e8f0 !important;
}
[data-theme="dark"] .gestao-clean-table tbody tr:nth-child(odd) td {
  background: rgba(255, 255, 255, 0.02);
}
[data-theme="dark"] .gestao-clean-table tbody tr:nth-child(even) td {
  background: rgba(99, 145, 255, 0.06) !important;
}
[data-theme="dark"] .gestao-clean-table tbody tr:hover td {
  background: rgba(99, 145, 255, 0.12) !important;
}

/* Gestao sort headers */
[data-theme="dark"] .gestao-sort-header {
  color: rgba(168, 186, 240, 0.85);
}

[data-theme="dark"] .gestao-sort-header:hover {
  color: #e8f2ff;
}

/* Farol (traffic light) dots */
[data-theme="dark"] .farol-dot.farol-verde { box-shadow: 0 0 6px rgba(34, 197, 94, 0.5); }
[data-theme="dark"] .farol-dot.farol-amarelo { box-shadow: 0 0 6px rgba(245, 158, 11, 0.5); }
[data-theme="dark"] .farol-dot.farol-vermelho { box-shadow: 0 0 6px rgba(239, 68, 68, 0.5); }

/* Campaign row selected */
[data-theme="dark"] .campaign-row-selected td {
  background: rgba(99, 145, 255, 0.12) !important;
}

/* ===================================
   TOGGLE SWITCH — Bruto/Líquido (D0)
   =================================== */
.d0-toggle-switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}

.d0-toggle-switch input {
  display: none;
}

.d0-toggle-slider {
  position: relative;
  width: 36px;
  height: 20px;
  background: #cbd5e1;
  border-radius: 9999px;
  transition: background .2s ease;
  flex-shrink: 0;
}

.d0-toggle-slider::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  background: #fff;
  border-radius: 50%;
  transition: transform .2s ease;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.d0-toggle-switch input:checked + .d0-toggle-slider {
  background: #0f766e;
}

.d0-toggle-switch input:checked + .d0-toggle-slider::after {
  transform: translateX(16px);
}

.d0-toggle-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.d0-toggle-switch input:checked ~ .d0-toggle-label {
  color: #0f766e;
}

[data-theme="dark"] .d0-toggle-slider {
  background: #334155;
}

[data-theme="dark"] .d0-toggle-switch input:checked + .d0-toggle-slider {
  background: #1f9d94;
}

[data-theme="dark"] .d0-toggle-switch input:checked ~ .d0-toggle-label {
  color: #6ee7b7;
}
