:root {
  --primary: #3b82f6;
  --primary-light: #eff6ff;
  --bg-body: #f8fafc;
  --bg-card: #ffffff;
  --text-main: #1e293b;
  --text-muted: #64748b;
  --border-color: #e2e8f0;
}

/* VARIÁVEIS DO MODO ESCURO */
.dark-theme {
  --bg-body: #0f172a;
  --bg-card: #1e293b;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --border-color: #334155;
  --primary-light: rgba(59, 130, 246, 0.1);
}

body {
    background-color: var(--bg-body);
    color: var(--text-main);
    margin: 0;
    overflow-x: hidden;
    font-family: 'Inter', sans-serif;
    transition: background 0.3s, color 0.3s;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

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

/* AJUSTES PARA COMPONENTES NO MODO ESCURO */
.dark-theme .navbar, .dark-theme .menu-bar, .dark-theme .main-card, .dark-theme .profile-dropdown {
  background-color: var(--bg-card) !important;
  border-color: var(--border-color);
}
.dark-theme .search-bar, .dark-theme .nav-filters-compact {
  background-color: #1a2236;
  border-color: var(--border-color);
}
.dark-theme .search-bar input, .dark-theme .nav-filters-compact input {
  color: white;
}

/* NAVBAR */
.navbar {
  height: 70px; background: white; border-bottom: 1px solid var(--border-color);
  display: flex !important; align-items: center !important; justify-content: space-between;
  padding: 0 15px 0 25px; /* Mais espaço na direita para o perfil */
  position: sticky; top: 0; z-index: 1000; box-sizing: border-box;
  width: 100%;
}

.navbar img {
  max-width: 100%;
  max-height: 40px !important;
  object-fit: contain;
}

.navbar-left { display: flex !important; align-items: center !important; gap: 15px; }

/* LOGO PRINCIPAL (APP) */
.brand-logo-main {
  max-height: 40px !important;
  max-width: 200px !important;
}

/* LOGO DA UEN NA CAPSULA */
.logo-uen {
  max-height: 20px !important;
  max-width: 80px !important;
  margin: 0 4px;
}

.logo-mini {
  max-height: 18px !important;
  opacity: 0.6;
}

.navbar-center { flex: 1; display: flex; justify-content: center; }

/* CAPSULA DE CONTEXTO (UEN) */
.uen-capsule {
  display: flex !important;
  align-items: center !important;
  gap: 8px;
  background: var(--bg-card);
  padding: 4px 12px;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  box-shadow: 0 1px 2px rgba(0,0,0,0.03);
  height: 34px;
  max-width: 500px; /* Aumentado */
  overflow: hidden;
  transition: background 0.3s, border-color 0.3s;
}

.divider-v {
  width: 1px;
  height: 16px;
  background: var(--border-color);
  margin: 0 4px;
}

.uen-selector-premium {
  border: none !important;
  background-color: var(--bg-card) !important;
  padding: 0 20px 0 4px !important;
  font-size: 0.75rem !important;
  font-weight: 700 !important;
  outline: none !important;
  color: var(--text-main) !important;
  cursor: pointer;
  max-width: 400px;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
}

.navbar-right { 
  display: flex !important; 
  align-items: center !important; 
  gap: 12px; 
  flex-shrink: 0;
}

/* BUSCA COMPACTA */
.search-bar {
  background: #f1f5f9; border-radius: 8px; padding: 6px 12px;
  display: flex; align-items: center; width: 200px; border: 1px solid transparent;
}
.search-bar input { background: transparent; border: none; outline: none; margin-left: 10px; flex: 1; font-size: 0.8rem; }
.search-hint { font-size: 0.6rem; color: var(--text-muted); font-weight: 700; opacity: 0.6; margin-left: 5px; }

/* FILTROS COMPACTOS (FIX) */
.nav-filters-compact {
  display: flex; align-items: center; gap: 5px; background: #f1f5f9; padding: 4px 12px; border-radius: 100px;
  border: 1px solid #e2e8f0; max-width: 280px;
}
.nav-filters-compact input { 
  background: transparent; border: none; outline: none; font-size: 0.78rem; font-weight: 700; color: var(--text-main); 
  width: 90px; cursor: pointer;
}
.nav-filters-compact span { font-size: 0.7rem; color: var(--text-muted); font-weight: 700; }

/* USER PROFILE & DROPDOWN (FIX) */
.user-profile { position: relative; margin-left: 10px; margin-right: 10px; }
.avatar-img { width: 34px; height: 34px; border-radius: 50%; border: 2px solid var(--primary-light); cursor: pointer; }

.profile-dropdown {
  position: absolute; right: 0; top: 120%; background: white; border-radius: 10px;
  width: 180px; box-shadow: 0 10px 25px -5px rgba(0,0,0,0.15);
  border: 1px solid var(--border-color); padding: 8px 0;
  display: none; z-index: 1100; /* Floating over everything */
}
.profile-dropdown.active { display: block !important; }

.dropdown-header { padding: 8px 15px; font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); font-weight: 800; border-bottom: 1px solid #f1f5f9; margin-bottom: 5px; }
.dropdown-item { padding: 8px 15px; font-size: 0.8rem; color: var(--text-main); cursor: pointer; display: flex; align-items: center; gap: 10px; font-weight: 600; }
.dropdown-item:hover { background: var(--primary-light); color: var(--primary); }
.dropdown-divider { height: 1px; background: #f1f5f9; margin: 5px 0; }

.color-options { display: flex; gap: 6px; padding: 10px 15px; justify-content: center; }
.color-dot { width: 14px; height: 14px; border-radius: 50%; cursor: pointer; border: 2px solid transparent; transition: all 0.2s; }
.color-dot:hover, .color-dot.active { border-color: #cbd5e1; transform: scale(1.2); }

/* DASHBOARD CARDS (FONTES PEQUENAS IGUAL AO FLOW) */
.dashboard-container { padding: 20px 15px; width: 100%; box-sizing: border-box; flex: 1; max-width: none !important; }
.welcome-row { display: flex; gap: 15px; margin-bottom: 15px; align-items: flex-start; }

.main-card {
  background: white; border-radius: 12px; padding: 20px;
  border: 1px solid var(--border-color); box-shadow: 0 1px 3px rgba(0,0,0,0.05); position: relative;
  height: auto !important;
  overflow: visible !important;
}

.group-container {
    margin-bottom: 0;
    display: block !important;
    border-radius: 16px;
    overflow: hidden;
    position: relative;
    flex: 1;
}

.group-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--primary), #818cf8, #a855f7);
    opacity: 0.7;
    border-radius: 16px 16px 0 0;
}

.group-header {
    padding: 10px 15px 4px 15px !important;
    display: flex;
    align-items: center;
    gap: 8px;
}

.group-header .kpi-label {
    font-size: 0.65rem;
    font-weight: 800;
    letter-spacing: 0.08em;
}

/* VALORES PREMIUM */
.kpi-value { font-size: 1.15rem; font-weight: 700; color: var(--text-main); font-family: 'Outfit', sans-serif; line-height: 1.2; }
.kpi-label { font-size: 0.6rem; color: var(--text-muted); font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; }
.kpi-spike { font-size: 0.65rem; font-weight: 700; margin-top: 2px; }

/* GRID PRINCIPAL */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 15px;
}

/* SUMMARY CONTAINER - 3 cards side by side */
.summary-container-group {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-bottom: 10px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 2px;
  padding: 5px 10px 8px 10px;
}

/* PREMIUM KPI CARD ITEM */
.compact-kpi {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 4px 12px;
    border-radius: 10px;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    cursor: default;
}

.compact-kpi:hover {
    background: var(--primary-light);
    transform: translateY(-1px);
}

.compact-kpi .kpi-header {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 2px;
}

.compact-kpi .kpi-icon-badge {
    width: 24px;
    height: 24px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    flex-shrink: 0;
    transition: transform 0.2s;
}

.compact-kpi:hover .kpi-icon-badge {
    transform: scale(1.1);
}

.compact-kpi .kpi-value {
    font-size: 1.1rem;
    padding-left: 2px;
}

/* RANKING */
.ranking-list { display: flex; flex-direction: column; gap: 10px; }
.ranking-info { display: flex; justify-content: space-between; font-size: 0.78rem; font-weight: 700; }
.progress-bar { height: 6px; }

/* CLASSES DE LARGURA DINÂMICA (METADADOS) */
.span-2 { grid-column: span 2 !important; }
.span-3 { grid-column: span 3 !important; }

/* MENU BAR */
.menu-bar { background: white; border-bottom: 1px solid var(--border-color); padding: 0 20px; }
.menu-items { display: flex; gap: 20px; }
.menu-item {
  padding: 12px 10px; font-size: 0.82rem; font-weight: 600; color: var(--text-main);
  cursor: pointer; display: flex; align-items: center; gap: 6px; position: relative;
  transition: all 0.2s;
}
.menu-item:hover { color: var(--primary); }

.submenu-dropdown {
  position: absolute; 
  top: 100%; 
  left: 0; 
  background: var(--bg-card); 
  min-width: 220px; 
  border: 1px solid var(--border-color); 
  border-radius: 0 0 8px 8px;
  box-shadow: 0 10px 15px -3px rgba(0,0,0,0.2); 
  display: none; 
  flex-direction: column; /* Força vertical cascata */
  padding: 0; 
  z-index: 2000;
}
.menu-item:hover .submenu-dropdown { display: flex; }

.submenu-item {
  padding: 10px 20px;
  font-size: 0.75rem;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
  border-bottom: 1px solid var(--border-color);
  cursor: pointer;
  transition: all 0.2s;
}
.submenu-item:last-child { border-bottom: none; }
.submenu-item:hover { background: var(--primary-light); color: var(--primary); }
.submenu-item i { width: 16px; text-align: center; opacity: 0.7; }

/* LAYOUT DINÂMICO */
.hero-slot {
  background: linear-gradient(135deg, var(--bg-card) 0%, var(--primary-light) 100%);
  border-left: 4px solid var(--primary) !important;
}

.hero-slot .kpi-value {
    font-size: 1.8rem;
    word-break: break-all;
    margin-top: 5px;
    background: linear-gradient(90deg, var(--primary), #818cf8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* --- NOVOS ESTILOS RANKING PREMIUM --- */
.ranking-item-premium {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-color);
}
.ranking-item-premium:last-child { border-bottom: none; }

.brand-badge {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary-light);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.ranking-content-rich {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.ranking-row-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

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

.brand-value {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-main);
}

.ranking-row-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.variation-container {
    display: flex;
    gap: 10px;
    font-size: 0.72rem;
    font-weight: 600;
}

.var-up { color: #10b981; }
.var-down { color: #ef4444; }

.share-bar-container {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 140px;
}

.share-percent {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: 600;
    width: 40px;
    text-align: right;
}

.progress-mini {
    flex: 1;
    height: 6px;
    background: #e2e8f0;
    border-radius: 10px;
    overflow: hidden;
}

.progress-fill-mini {
    height: 100%;
    background: var(--primary);
    border-radius: 10px;
}

/* --- GESTÃO DE CARTEIRA --- */
.portfolio-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.portfolio-total {
    margin-bottom: 5px;
    padding-bottom: 15px;
    border-bottom: 1px dashed var(--border-color);
}

.portfolio-total-label {
    font-size: 0.72rem;
    color: var(--text-muted);
    font-weight: 700;
    text-transform: uppercase;
}

.portfolio-total-value {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--text-main);
    font-family: 'Outfit', sans-serif;
}

.portfolio-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 10px 0;
    border-bottom: 1px solid rgba(0,0,0,0.03);
}
.portfolio-item:last-child { border-bottom: none; }

.portfolio-icon {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.portfolio-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.portfolio-title {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--text-main);
}

.portfolio-desc {
    font-size: 0.68rem;
    color: var(--text-muted);
    line-height: 1.3;
}

.portfolio-chart-mini {
    width: 50px;
    height: 50px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.portfolio-value {
    font-size: 0.72rem;
    font-weight: 800;
    color: var(--text-main);
    z-index: 2;
}

.portfolio-ring {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 3px solid #f1f5f9;
}

.portfolio-ring-fill {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 3px solid transparent;
    border-top-color: var(--primary);
}

/* --- FOOTER UNIFICADO --- */
.main-footer {
    background: white;
    border-top: 1px solid var(--border-color);
    padding: 15px 40px;
    margin-top: 40px;
}

.footer-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 500;
    white-space: nowrap; /* Garante linha única */
}

.footer-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.footer-status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 12px;
    background: #f8fafc;
    border-radius: 20px;
    border: 1px solid var(--border-color);
}

.status-dot {
    width: 6px;
    height: 6px;
    background: #10b981;
    border-radius: 50%;
    box-shadow: 0 0 5px #10b981;
}

.dark-theme .main-footer { background: #0f172a; border-color: #1e293b; }
.dark-theme .footer-status { background: #1e293b; border-color: #334155; }

/* RESPONSIVIDADE TOTAL v3.2 */
@media (max-width: 1200px) {
    .dashboard-container { padding: 20px; }
    .summary-container-group {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    .dashboard-grid, .summary-grid {
        grid-template-columns: 1fr !important;
    }
    .span-2, .span-3 { grid-column: span 1 !important; }
}

@media (max-width: 900px) {
    .navbar {
        height: auto;
        flex-direction: column;
        padding: 15px;
        gap: 15px;
    }
    .navbar-center, .navbar-right {
        width: 100%;
        justify-content: center;
    }
    .search-bar, .nav-filters-compact {
        width: 100%;
        max-width: none;
    }
    .menu-bar {
        overflow-x: auto;
    }
    .menu-items {
        white-space: nowrap;
    }
}

@media (max-width: 600px) {
    .dashboard-container { padding: 10px; }
    .footer-content {
        flex-direction: column !important;
        align-items: center;
        gap: 10px;
    }
}
/* --- PADRAO CRUD v3.0 --- */
.crud-container { padding: 30px; max-width: 1300px; margin: 0 auto; }
.crud-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 30px; gap: 20px; }
.crud-title-group h1 { font-family: 'Outfit', sans-serif; font-size: 1.5rem; color: var(--text-main); margin: 0; }
.crud-title-group p { color: var(--text-muted); font-size: 0.9rem; margin-top: 5px; }
.btn-primary-crud { background: var(--primary); color: white; border: none; padding: 10px 22px; border-radius: 8px; font-weight: 700; cursor: pointer; display: flex; align-items: center; gap: 8px; transition: all 0.2s; font-size: 0.85rem; }
.search-box-crud { background: var(--bg-card); border: 1px solid var(--border-color); border-radius: 10px; padding: 8px 15px; display: flex; align-items: center; width: 320px; transition: border-color 0.2s; }
.datagrid-card { background: var(--bg-card); border-radius: 16px; border: 1px solid var(--border-color); overflow: hidden; box-shadow: 0 4px 20px rgba(0,0,0,0.05); }
.datagrid { width: 100%; border-collapse: collapse; }
.datagrid th { text-align: left; padding: 18px 20px; background: rgba(0,0,0,0.02); color: var(--text-muted); font-size: 0.72rem; text-transform: uppercase; border-bottom: 1px solid var(--border-color); font-weight: 800; }
.datagrid td { padding: 16px 20px; border-bottom: 1px solid var(--border-color); color: var(--text-main); font-size: 0.88rem; }
.actions-cell { display: flex; gap: 8px; justify-content: flex-end; }
.btn-action { width: 34px; height: 34px; border-radius: 8px; display: flex; align-items: center; justify-content: center; cursor: pointer; border: 1px solid var(--border-color); background: var(--bg-card); color: var(--text-muted); transition: all 0.2s; }
.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(15, 23, 42, 0.6); display: none; align-items: center; justify-content: center; z-index: 2100; backdrop-filter: blur(8px); }
.modal-card { background: var(--bg-card); width: 100%; max-width: 550px; border-radius: 20px; padding: 35px; box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25); border: 1px solid var(--border-color); }
.form-group { margin-bottom: 22px; }
.form-label { display: block; font-size: 0.68rem; font-weight: 800; color: var(--text-muted); margin-bottom: 10px; text-transform: uppercase; }
.form-control { width: 100%; padding: 14px; border-radius: 10px; border: 1px solid var(--border-color); background: var(--bg-body); color: var(--text-main); outline: none; box-sizing: border-box; }

