:root {
  --primary: #3b82f6;
  --primary-rgb: 59, 130, 246;
  --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: #cbd5e1;
  --border-color: #334155;
  --primary-light: rgba(59, 130, 246, 0.1);
}

.dark-theme .badge {
  background-color: rgba(255, 255, 255, 0.08) !important;
  color: var(--text-main) !important;
  border: 1px solid rgba(255, 255, 255, 0.1);
}
.dark-theme .badge.bg-blue-lt, .dark-theme .badge.bg-primary-lt {
  background-color: rgba(59, 130, 246, 0.15) !important;
  color: #60a5fa !important;
  border: 1px solid rgba(59, 130, 246, 0.3) !important;
}
.dark-theme .badge.bg-success-lt, .dark-theme .badge.bg-green-lt {
  background-color: rgba(16, 185, 129, 0.15) !important;
  color: #34d399 !important;
  border: 1px solid rgba(16, 185, 129, 0.3) !important;
}
.dark-theme .badge.bg-secondary-lt {
  background-color: rgba(148, 163, 184, 0.15) !important;
  color: #94a3b8 !important;
  border: 1px solid rgba(148, 163, 184, 0.3) !important;
}
.dark-theme .badge.bg-yellow-lt, .dark-theme .badge.bg-warning-lt {
  background-color: rgba(245, 158, 11, 0.15) !important;
  color: #fbbf24 !important;
  border: 1px solid rgba(245, 158, 11, 0.3) !important;
}
.dark-theme .badge.bg-danger-lt, .dark-theme .badge.bg-red-lt {
  background-color: rgba(239, 68, 68, 0.15) !important;
  color: #f87171 !important;
  border: 1px solid rgba(239, 68, 68, 0.3) !important;
}

.dark-theme .table thead th { color: #e2e8f0; background: rgba(255,255,255,0.05); }
.dark-theme .filter-row input, .dark-theme .filter-row select { background: rgba(255,255,255,0.08); color: #e2e8f0; border-color: #475569; }
.dark-theme .filter-row input::placeholder { color: #94a3b8; }
.dark-theme .premium-table th { color: #e2e8f0; background: rgba(255,255,255,0.05); }
.table thead th { white-space: normal !important; word-wrap: break-word; overflow-wrap: break-word; line-height: 1.3; }

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);
}

@media (max-width: 768px) {
    .dark-theme .navbar, .dark-theme .menu-bar, .dark-theme .main-card, .dark-theme .profile-dropdown {
        background-color: var(--bg-card) !important;
    }
}
.dark-theme .search-bar, .dark-theme .nav-filters-compact {
  background-color: #1a2236;
  border-color: var(--border-color);
}

@media (max-width: 768px) {
    .dark-theme .search-bar, .dark-theme .nav-filters-compact {
        background-color: #1a2236 !important;
    }
}
.dark-theme .search-bar input, .dark-theme .nav-filters-compact input {
  color: white;
}

@media (max-width: 768px) {
    .dark-theme .search-bar input, .dark-theme .nav-filters-compact input {
        color: white !important;
    }
}

/* 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 20px;
  position: sticky; top: 0; z-index: 1000; box-sizing: border-box;
  width: 100%;
}

@media (max-width: 768px) {
    .navbar {
        height: auto !important;
        flex-direction: column !important;
        padding: 10px !important;
        gap: 10px !important;
    }
}

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

@media (max-width: 768px) {
    .navbar img { max-height: 28px !important; }
}

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

@media (max-width: 768px) {
    .navbar-left {
        width: 100% !important;
        justify-content: center !important;
        flex-direction: column !important;
        gap: 8px !important;
    }
}

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

@media (max-width: 768px) {
    .brand-logo-main { max-height: 28px !important; }
}

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

@media (max-width: 768px) {
    .logo-uen { max-height: 18px !important; max-width: 70px !important; }
}

.logo-mini {
  max-height: 20px !important;
  opacity: 0.7;
}

@media (max-width: 768px) {
    .logo-mini { max-height: 16px !important; }
}

.navbar-center { display: flex; align-items: center; gap: 10px; flex: 0 1 auto; }

@media (max-width: 768px) {
    .navbar-center {
        width: 100% !important;
        justify-content: center !important;
        flex-direction: column !important;
        gap: 8px !important;
    }
}

/* CAPSULA DE CONTEXTO (UEN) */
.uen-capsule {
  display: flex !important;
  align-items: center !important;
  gap: 10px;
  background: var(--bg-card);
  padding: 4px 15px;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
  height: 38px;
  max-width: 450px; /* Reduzido de 500px para garantir espaço ao perfil */
  overflow: hidden;
  transition: background 0.3s, border-color 0.3s;
  flex-shrink: 1;
}

@media (max-width: 768px) {
    .uen-capsule {
        width: 100% !important;
        max-width: none !important;
        justify-content: center !important;
        height: auto !important;
        padding: 8px !important;
    }
}

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

@media (max-width: 768px) {
    .divider-v { height: 14px !important; margin: 0 2px !important; }
}

.uen-selector-premium {
  border: none !important;
  background-color: var(--bg-card) !important;
  padding: 0 20px 0 5px !important;
  font-size: 0.85rem !important;
  font-weight: 800 !important;
  outline: none !important;
  color: var(--text-main) !important;
  cursor: pointer;
  max-width: 280px; /* Limite de segurança para não empurrar o perfil */
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
}

@media (max-width: 768px) {
    .uen-selector-premium { font-size: 0.8rem !important; max-width: 200px !important; }
}

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

@media (max-width: 768px) {
    .navbar-right {
        width: 100% !important;
        justify-content: center !important;
        flex-direction: column !important;
        gap: 8px !important;
    }
}

/* BUSCA COMPACTA */
.search-bar {
  background: #f1f5f9; border-radius: 8px; padding: 6px 12px;
  display: flex; align-items: center; width: 200px; border: 1px solid transparent;
}

@media (max-width: 768px) {
    .search-bar { display: none !important; }
}
.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; }

@media (max-width: 768px) {
    .search-hint { display: none !important; }
}

/* FILTROS COMPACTOS (FIX) */
.nav-filters-compact {
  display: flex; align-items: center; gap: 8px; background: #f1f5f9; padding: 4px 15px; border-radius: 100px;
  border: 1px solid #e2e8f0; max-width: 350px;
}

@media (max-width: 768px) {
    .nav-filters-compact {
        width: 100% !important;
        max-width: none !important;
        justify-content: center !important;
    }
}
.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;
}

@media (max-width: 768px) {
    .nav-filters-compact input { width: 80px !important; font-size: 0.75rem !important; }
}
.nav-filters-compact span { font-size: 0.7rem; color: var(--text-muted); font-weight: 700; }

@media (max-width: 768px) {
    .nav-filters-compact span { font-size: 0.65rem !important; }
}

/* USER PROFILE & DROPDOWN (FIX) */
.user-profile { 
  position: relative; 
  margin-left: 10px; 
  margin-right: 15px; /* Garante que nunca saia da tela */
  flex-shrink: 0; 
}

@media (max-width: 768px) {
    .user-profile { margin: 0 !important; }
}
.avatar-img { width: 34px; height: 34px; border-radius: 50%; border: 2px solid var(--primary-light); cursor: pointer; }

@media (max-width: 768px) {
    .avatar-img { width: 30px !important; height: 30px !important; }
}

.profile-dropdown {
  position: absolute; right: 0; top: 120%; background: white; border-radius: 10px;
  width: 280px; max-width: calc(100vw - 20px); box-shadow: 0 10px 25px -5px rgba(0,0,0,0.18);
  border: 1px solid var(--border-color); padding: 8px 0;
  display: none; z-index: 1100; /* Floating over everything */
  box-sizing: border-box;
  overflow: hidden;
}

@media (max-width: 768px) {
    .profile-dropdown { right: -10px !important; width: 260px !important; }
}
.profile-dropdown.active { display: block !important; }

.dropdown-header { padding: 8px 15px; font-size: 0.72rem; text-transform: capitalize; letter-spacing: 0.02em; color: var(--text-muted); font-weight: 700; border-bottom: 1px solid var(--border-color); margin-bottom: 5px; word-break: break-word; overflow-wrap: break-word; white-space: normal !important; }

@media (max-width: 768px) {
    .dropdown-header { padding: 6px 12px !important; font-size: 0.68rem !important; }
}
.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; }

@media (max-width: 768px) {
    .dropdown-item { padding: 8px 12px !important; font-size: 0.78rem !important; }
}
.dropdown-item:hover { background: var(--primary-light); color: var(--primary); }
.dropdown-divider { height: 1px; background: #f1f5f9; margin: 5px 0; }

@media (max-width: 768px) {
    .dropdown-divider { margin: 4px 0 !important; }
}

.color-options { display: flex; gap: 6px; padding: 10px 15px; justify-content: center; }

@media (max-width: 768px) {
    .color-options { padding: 8px 12px !important; gap: 5px !important; }
}
.color-dot { width: 14px; height: 14px; border-radius: 50%; cursor: pointer; border: 2px solid transparent; transition: all 0.2s; }

@media (max-width: 768px) {
    .color-dot { width: 12px !important; height: 12px !important; }
}
.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; }

@media (max-width: 768px) {
    .dashboard-container { padding: 12px 10px !important; }
}

.dark-theme .dashboard-container { background: var(--bg-body); }
.welcome-row { display: flex; gap: 15px; margin-bottom: 15px; align-items: flex-start; }

@media (max-width: 768px) {
    .welcome-row { gap: 10px !important; margin-bottom: 12px !important; }
}

.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;
}

@media (max-width: 768px) {
    .main-card {
        padding: 14px !important;
        border-radius: 10px !important;
    }
}

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

@media (max-width: 768px) {
    .group-container {
        border-radius: 12px !important;
    }
}

.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;
}

@media (max-width: 768px) {
    .group-header .kpi-label {
        font-size: 0.6rem !important;
    }
    .group-header {
        padding: 8px 12px 4px 12px !important;
    }
}

/* Ilustração decorativa no cabeçalho dos grupos de KPI */
.group-illustration {
    position: absolute;
    right: 20px;
    bottom: 6px;
    top: auto;
    transform: none;
    height: 90px;
    opacity: 1;
    pointer-events: none;
    user-select: none;
    filter: saturate(0.7);   /* suaviza as cores para não distrair */
}

@media (max-width: 768px) {
    .group-illustration {
        height: 60px;
        right: 10px;
        bottom: 4px;
        opacity: 0.85;
    }
}

/* ── Split layout ── */
.group-split {
    display: flex;
    flex-direction: row;
    min-height: 0;
}

.group-hero-panel {
    width: 240px;
    min-width: 220px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    padding: 0;
    position: relative;
    border-right: 1px solid var(--border-color);
}

.group-hero-panel .group-illustration {
    position: static;
    width: calc(100% - 32px);
    height: 140px;
    object-fit: contain;
    object-position: center;
    opacity: 1;
    pointer-events: none;
    user-select: none;
    flex-shrink: 0;
    margin: 12px auto 0 auto;
    order: 1;
}

.hero-value-inner {
    position: relative;
    width: 100%;
    padding: 8px 16px 16px 16px;
    box-sizing: border-box;
    z-index: 1;
    order: 2;
}

.hero-kpi-label {
    font-size: 0.58rem;
    font-weight: 700;
    color: var(--text-muted);
    /* NUNCA usar text-transform: uppercase - usar Title Case no HTML */
    letter-spacing: 0.08em;
    margin-bottom: 6px;
}

.hero-kpi-value {
    font-size: 1.55rem;
    font-weight: 800;
    color: var(--primary);
    font-family: 'Outfit', sans-serif;
    line-height: 1.1;
    white-space: nowrap;
}

.group-split .group-content.summary-grid {
    flex: 1;
    min-width: 0;
    padding: 10px 14px 14px 14px;
    align-content: center;
}

@media (max-width: 900px) {
    .group-split {
        flex-direction: column;
    }
    .group-hero-panel {
        width: 100%;
        min-height: 110px;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        flex-direction: row;
        align-items: center;
        padding: 14px 16px;
        gap: 14px;
    }
    .group-hero-panel .group-illustration {
        position: static;
        height: 70px;
        margin-left: auto;
    }
    .hero-value-inner { margin-top: 0; }
}

/* 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.68rem; color: var(--text-muted); font-weight: 700; text-transform: none; letter-spacing: 0.01em; }

@media (max-width: 768px) {
    .kpi-value { font-size: 1rem !important; }
    .kpi-label { font-size: 0.55rem !important; }
}
.kpi-spike { font-size: 0.65rem; font-weight: 700; margin-top: 2px; }

@media (max-width: 768px) {
    .kpi-spike { font-size: 0.6rem !important; }
}

/* 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;
}

@media (max-width: 768px) {
    .summary-container-group {
        gap: 10px !important;
        margin-bottom: 8px !important;
    }
}

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

@media (max-width: 768px) {
    .summary-grid {
        grid-template-columns: 1fr 1fr !important;
        gap: 8px 10px !important;
        padding: 4px 8px 6px 8px !important;
    }
}

/* 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;
}

@media (max-width: 768px) {
    .compact-kpi {
        padding: 4px 10px !important;
    }
    .compact-kpi .kpi-value {
        font-size: 1rem !important;
    }
}

.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;
}

@media (max-width: 768px) {
    .compact-kpi .kpi-value {
        font-size: 1rem !important;
    }
}

/* RANKING */
.ranking-list { display: flex; flex-direction: column; gap: 10px; }

@media (max-width: 768px) {
    .ranking-list { gap: 8px !important; }
}
.ranking-info { display: flex; justify-content: space-between; font-size: 0.78rem; font-weight: 700; }

@media (max-width: 768px) {
    .ranking-info { font-size: 0.72rem !important; }
}
.progress-bar { height: 6px; }

@media (max-width: 768px) {
    .progress-bar { height: 5px !important; }
}

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

@media (max-width: 768px) {
    .span-2, .span-3 { grid-column: span 1 !important; }
}

/* MENU BAR */
.menu-bar { background: white; border-bottom: 1px solid var(--border-color); padding: 0 20px; }

@media (max-width: 768px) {
    .menu-bar { padding: 0 !important; }
}
.menu-items { display: flex; gap: 20px; }

@media (max-width: 768px) {
    .menu-items { padding: 5px 15px !important; gap: 15px !important; }
}
.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;
}

@media (max-width: 768px) {
    .menu-item { font-size: 0.8rem !important; white-space: nowrap; }
}
.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;
}

@media (max-width: 768px) {
    .submenu-dropdown { min-width: 200px !important; }
}
.menu-item:hover .submenu-dropdown,
.menu-item.active .submenu-dropdown { display: flex; }

/* Mobile Menu Fix */
@media (max-width: 768px) {
    .submenu-dropdown {
        left: 50%;
        transform: translateX(-50%);
        position: fixed;
        top: 150px; /* Abaixo da navbar mobile */
        width: 90%;
        max-width: 300px;
    }
}

.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;
}

@media (max-width: 768px) {
    .submenu-item { padding: 12px 20px !important; font-size: 0.78rem !important; }
}
.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;
}

@media (max-width: 768px) {
    .hero-slot { padding: 12px !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;
}

@media (max-width: 768px) {
    .hero-slot .kpi-value { font-size: 1.3rem !important; margin-top: 4px !important; }
}

/* --- 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; }

@media (max-width: 768px) {
    .ranking-item-premium {
        gap: 10px !important;
        padding: 10px 0 !important;
    }
}

.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;
}

@media (max-width: 768px) {
    .brand-badge {
        width: 34px !important;
        height: 34px !important;
        font-size: 0.72rem !important;
    }
}

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

@media (max-width: 768px) {
    .ranking-content-rich {
        min-width: 0 !important;
        overflow: hidden !important;
    }
}

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

@media (max-width: 768px) {
    .ranking-row-top {
        gap: 6px !important;
    }
}

.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);
}

@media (max-width: 768px) {
    .brand-name {
        font-size: 0.82rem !important;
    }
    .brand-value {
        font-size: 0.88rem !important;
    }
}

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

@media (max-width: 768px) {
    .ranking-row-bottom {
        gap: 8px !important;
    }
}

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

.trend-badge {
    cursor: help;
    position: relative;
    padding: 2px 6px;
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.05);
    transition: background 0.2s;
}

.dark-theme .trend-badge {
    background: rgba(255, 255, 255, 0.05);
}

.trend-badge:hover {
    background: rgba(0, 0, 0, 0.1);
}

.dark-theme .trend-badge:hover {
    background: rgba(255, 255, 255, 0.1);
}

.custom-tooltip {
    position: fixed;
    background: #1e293b;
    color: #f8fafc;
    border: 1px solid #475569;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 0.72rem;
    font-weight: 500;
    white-space: pre-line;
    z-index: 9999;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    pointer-events: none;
    text-align: left;
    line-height: 1.6;
    max-width: 320px;
}

@media (max-width: 768px) {
    .variation-container {
        font-size: 0.7rem !important;
    }
}

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

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

@media (max-width: 768px) {
    .share-bar-container {
        width: 100px !important;
    }
    .share-percent {
        font-size: 0.68rem !important;
        width: 38px !important;
    }
}

.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;
}

@media (max-width: 768px) {
    .portfolio-container {
        gap: 12px !important;
    }
}

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

@media (max-width: 768px) {
    .portfolio-total {
        padding-bottom: 12px !important;
    }
}

.portfolio-total-label {
    font-size: 0.72rem;
    color: var(--text-muted);
    font-weight: 700;
    /* NUNCA usar text-transform: uppercase - usar Title Case no HTML */
}

@media (max-width: 768px) {
    .portfolio-total-label {
        font-size: 0.68rem !important;
    }
}

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

@media (max-width: 768px) {
    .portfolio-total-value {
        font-size: 1.4rem !important;
    }
}

.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; }

@media (max-width: 768px) {
    .portfolio-item {
        gap: 10px !important;
        padding: 8px 0 !important;
    }
}

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

@media (max-width: 768px) {
    .portfolio-icon {
        width: 32px !important;
        height: 32px !important;
        font-size: 0.8rem !important;
    }
}

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

@media (max-width: 768px) {
    .portfolio-info {
        gap: 1px !important;
    }
}

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

@media (max-width: 768px) {
    .portfolio-title {
        font-size: 0.78rem !important;
    }
}

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

@media (max-width: 768px) {
    .portfolio-desc {
        font-size: 0.65rem !important;
    }
}

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

@media (max-width: 768px) {
    .portfolio-chart-mini {
        width: 42px !important;
        height: 42px !important;
    }
}

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

@media (max-width: 768px) {
    .portfolio-value {
        font-size: 0.68rem !important;
    }
}

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

@media (max-width: 768px) {
    .portfolio-ring {
        border-width: 2px !important;
    }
}

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

@media (max-width: 768px) {
    .portfolio-ring-fill {
        border-width: 2px !important;
    }
}

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

@media (max-width: 768px) {
    .main-footer {
        padding: 12px 20px !important;
        margin-top: 20px !important;
    }
}

.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 */
}

@media (max-width: 768px) {
    .footer-content {
        flex-direction: column !important;
        gap: 10px !important;
        padding: 20px !important;
    }
}

.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 GLOBAL v5.0 - MOBILE FIRST FOCUS */

/* Ajustes para evitar o "balanço" horizontal */
html, body {
    max-width: 100vw;
    overflow-x: hidden;
}

/* Telas Médias e Pequenas (Tablets e Celulares) */
@media (max-width: 1024px) {
    .dashboard-grid {
        grid-template-columns: 1fr !important;
        gap: 10px;
    }
    
    .summary-container-group {
        display: flex !important;
        flex-direction: column !important;
        gap: 10px !important;
    }

    .summary-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    .group-container {
        width: 100% !important;
        flex: none !important;
        max-width: none !important;
    }

    .span-2, .span-3 {
        grid-column: span 1 !important;
    }

    .main-card {
        width: 100% !important;
        box-sizing: border-box;
        padding: 15px !important;
    }
}

/* Telas de Celular (Ajustes de Cabeçalho e Menu) */
@media (max-width: 768px) {
    .navbar {
        height: auto !important;
        flex-direction: column !important;
        padding: 10px !important;
        gap: 10px !important;
    }

    .navbar-left, .navbar-center, .navbar-right {
        width: 100% !important;
        justify-content: center !important;
        flex-direction: column !important;
        gap: 8px !important;
    }

    .search-bar, .search-hint {
        display: none !important; /* Remove busca para ganhar espaço */
    }

    .brand-logo-main {
        max-height: 28px !important;
    }

    .uen-capsule {
        width: 100% !important;
        max-width: none !important;
        justify-content: center !important;
        height: auto !important;
        padding: 8px !important;
    }

    .nav-filters-compact {
        width: 100% !important;
        max-width: none !important;
        justify-content: center !important;
    }

    /* MENU MOBILE */
    .summary-grid {
        grid-template-columns: 1fr !important;
    }

    .menu-bar {
        padding: 0 !important;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .menu-items {
        padding: 5px 15px !important;
        gap: 15px !important;
    }

    .menu-item {
        font-size: 0.8rem !important;
        white-space: nowrap;
    }

    /* SUBMENU NO MOBILE: Abaixo do item em vez de flutuando */
    .menu-item.active .submenu-dropdown {
        position: fixed !important;
        top: auto !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100% !important;
        max-width: none !important;
        transform: none !important;
        border-radius: 20px 20px 0 0 !important;
        box-shadow: 0 -5px 25px rgba(0,0,0,0.2) !important;
        display: flex !important;
        flex-direction: column !important;
        padding: 20px !important;
        background: var(--bg-card) !important;
        z-index: 3000 !important;
        animation: slideUp 0.3s ease-out;
    }

    @keyframes slideUp {
        from { transform: translateY(100%); }
        to { transform: translateY(0); }
    }

    /* DATAGRIDS */
    .datagrid-card {
        border-radius: 10px !important;
    }
    
    .datagrid th, .datagrid td {
        padding: 10px !important;
        font-size: 0.72rem !important;
    }

    .kpi-value {
        font-size: 1.2rem !important;
    }

    .footer-content {
        flex-direction: column !important;
        gap: 10px !important;
        padding: 20px !important;
    }
}

/* Ajustes para telas muito pequenas (iPhone SE, etc) */
@media (max-width: 400px) {
    .kpi-value {
        font-size: 1.1rem !important;
    }
    .brand-name {
        font-size: 0.8rem !important;
    }
    .brand-value {
        font-size: 0.85rem !important;
    }
}

/* ============================================
   RESPONSIVIDADE GLOBAL DE GRÁFICOS E DASHBOARDS
   ============================================ */

/* Gráficos ECharts - Containers responsivos */
.main-card {
    box-sizing: border-box !important;
    overflow: visible !important;
    min-width: 0 !important;
}

.main-card > div:last-child {
    width: 100% !important;
    min-width: 0 !important;
}

/* Filtros responsivos */
.filter-bar {
    flex-wrap: wrap !important;
    overflow-x: visible !important;
}

.filter-bar .filter-group {
    flex-wrap: nowrap;
}

.filter-bar input[type="date"],
.filter-bar select {
    min-width: 95px;
    flex-shrink: 0;
}

/* Ranking items responsivos */
.ranking-item-premium {
    flex-wrap: nowrap !important;
    gap: 10px !important;
}

.ranking-content-rich {
    min-width: 0 !important;
    overflow: hidden !important;
}

.brand-badge {
    width: 36px !important;
    height: 36px !important;
    flex-shrink: 0 !important;
}

.share-bar-container {
    width: 100px !important;
}

/* Datagrid responsivo */
.datagrid-card {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
}

.datagrid {
    min-width: 500px;
}

/* Group containers */
.group-container {
    width: 100% !important;
    flex: none !important;
}

/* Summary containers */
.summary-container-group {
    width: 100% !important;
}

/* Modal responsivo */
.modal-card {
    width: 95% !important;
    max-height: 85vh !important;
}

/* Hero slot responsivo */
.hero-slot .kpi-value {
    font-size: 1.4rem !important;
    word-break: break-word !important;
}

@media (max-width: 768px) {
    .hero-slot .kpi-value {
        font-size: 1.2rem !important;
    }
}

/* Page header responsivo */
.page-header .container-xl {
    flex-wrap: wrap !important;
    gap: 8px !important;
}

/* Buttons responsivos */
.btn-action {
    width: 30px !important;
    height: 30px !important;
}

/* Pagination responsivo */
.pagination-container {
    flex-wrap: wrap !important;
    gap: 8px !important;
    justify-content: center !important;
}

/* Toast responsivo */
.toast-msg {
    min-width: auto !important;
    max-width: 90vw !important;
    font-size: 0.8rem !important;
}

/* Charts min-height mobile */
@media (max-width: 768px) {
    .dashboard-grid {
        grid-template-columns: 1fr !important;
        gap: 10px !important;
    }

    .main-card {
        padding: 14px !important;
        border-radius: 10px !important;
    }

    .main-card .kpi-label {
        font-size: 0.6rem !important;
    }

    .summary-grid {
        grid-template-columns: 1fr 1fr !important;
    }

    .filter-bar {
        padding: 6px 8px !important;
        gap: 6px !important;
    }

    .filter-bar button {
        padding: 4px 8px !important;
        font-size: 0.7rem !important;
    }

    .kpi-label {
        font-size: 0.6rem !important;
    }

    .compact-kpi {
        padding: 4px 10px !important;
    }

    .compact-kpi .kpi-value {
        font-size: 1rem !important;
    }

    [id^="target-"] {
        min-height: 240px !important;
        height: 240px !important;
    }

    /* Ranking items mais legíveis */
    .ranking-item-premium {
        gap: 12px !important;
        padding: 12px 0 !important;
    }

    .brand-badge {
        width: 34px !important;
        height: 34px !important;
        font-size: 0.72rem !important;
    }

    .brand-name {
        font-size: 0.82rem !important;
    }

    .brand-value {
        font-size: 0.9rem !important;
    }

    .share-bar-container {
        width: 100px !important;
    }

    .share-percent {
        font-size: 0.68rem !important;
        width: 38px !important;
    }

    .variation-container {
        font-size: 0.7rem !important;
    }
}

/* Very small screens */
@media (max-width: 400px) {
    .dashboard-grid {
        grid-template-columns: 1fr !important;
        gap: 8px !important;
    }

    .main-card {
        padding: 12px !important;
    }

    .summary-grid {
        grid-template-columns: 1fr !important;
    }

    .filter-bar .filter-group {
        width: 100% !important;
    }

    .filter-bar input[type="date"] {
        flex: 1 !important;
    }

    .ranking-item-premium {
        gap: 8px !important;
        padding: 8px 0 !important;
    }

    .ranking-row-top {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 2px !important;
    }

    .ranking-row-bottom {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 4px !important;
    }

    .share-bar-container {
        width: 100% !important;
    }

    [id^="target-"] {
        min-height: 220px !important;
        height: 220px !important;
    }
}

/* --- 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; }
#btnNovoRegistro, #btnNovoArquivo, #btnNovaNota { background: #10b981 !important; }
.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); }

@media (max-width: 768px) {
    .datagrid-card {
        border-radius: 10px !important;
    }
}
.datagrid { display: table !important; width: 100%; border-collapse: collapse; }

@media (max-width: 768px) {
    .datagrid th, .datagrid td {
        padding: 10px !important;
        font-size: 0.75rem !important;
    }
}
.datagrid th { text-align: left; padding: 18px 20px; background: rgba(0,0,0,0.02); color: var(--text-muted); font-size: 0.72rem; 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; }

@media (max-width: 768px) {
    .datagrid th { padding: 12px 14px !important; font-size: 0.68rem !important; }
    .datagrid td { padding: 10px 14px !important; font-size: 0.82rem !important; }
}
.actions-cell { display: flex; gap: 8px; justify-content: flex-end; }

@media (max-width: 768px) {
    .actions-cell { gap: 6px !important; }
}
.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; }

@media (max-width: 768px) {
    .btn-action { width: 30px !important; height: 30px !important; }
}
.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); display: flex; flex-direction: column; }
.modal-card { overflow: hidden !important; }
.modal-card > div:not(.modal-footer):not(.modal-header):not(.modal-body) { overflow: hidden !important; }

@media (max-width: 768px) {
    .modal-card {
        width: 95% !important;
        max-height: 85vh !important;
        padding: 20px !important;
        border-radius: 16px !important;
    }
}
.form-group { margin-bottom: 22px; }

@media (max-width: 768px) {
    .form-group { margin-bottom: 16px !important; }
}
/* NUNCA usar text-transform: uppercase - labels devem estar em Title Case no HTML */
.form-label { display: block; font-size: 0.68rem; font-weight: 800; color: var(--text-muted); margin-bottom: 10px; }

@media (max-width: 768px) {
    .form-label { font-size: 0.65rem !important; margin-bottom: 8px !important; }
}
.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; }

@media (max-width: 768px) {
    .form-control { padding: 12px !important; font-size: 0.9rem !important; }
}

/* ============================================================
   LAYOUT V2 - SIDEBAR VERTICAL + WORKSPACE TABS
   ERP MILLGEST IA 360
   ============================================================ */

/* --- LAYOUT SHELL --- */
.layout-shell { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }
.layout-topbar { display: flex; align-items: center; height: 48px; background: var(--bg-card); border-bottom: 1px solid var(--border-color); padding: 0 16px; gap: 12px; flex-shrink: 0; z-index: 100; }
.layout-body { display: flex; flex: 1; overflow: hidden; }

/* --- SIDEBAR --- */
.layout-sidebar {
  width: 220px; min-width: 56px; background: var(--bg-card); border-right: 1px solid var(--border-color);
  display: flex; flex-direction: column; overflow-y: auto; overflow-x: hidden; flex-shrink: 0; transition: width 0.2s ease;
}
.layout-sidebar.collapsed { width: 56px; }
.layout-sidebar.collapsed .sidebar-label,
.layout-sidebar.collapsed .sidebar-sub-label,
.layout-sidebar.collapsed .sidebar-group-title,
.layout-sidebar.collapsed .sidebar-group-label { display: none; }
.layout-sidebar.collapsed .sidebar-item { justify-content: center; padding: 10px 0; }
.layout-sidebar.collapsed .sidebar-item i { margin: 0; }

.sidebar-logo { display: flex; align-items: center; justify-content: center; padding: 12px 16px; border-bottom: 1px solid var(--border-color); cursor: pointer; flex-shrink: 0; min-height: 56px; }
.sidebar-logo img { max-height: 36px; max-width: 100%; object-fit: contain; }
.sidebar-logo span { font-weight: 800; font-size: 0.85rem; color: var(--text-main); white-space: nowrap; }
.layout-sidebar.collapsed .sidebar-logo span { display: none; }

.sidebar-nav { flex: 1; padding: 8px 0; overflow-y: auto; }

.sidebar-group-title {
  font-size: 0.65rem; font-weight: 800; /* NUNCA usar text-transform: uppercase - Title Case no HTML */ color: var(--text-muted);
  padding: 12px 16px 6px; letter-spacing: 0.5px; white-space: nowrap;
}

.sidebar-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 16px; cursor: pointer;
  color: var(--text-muted); font-size: 0.82rem; font-weight: 500; transition: all 0.15s;
  border-left: 3px solid transparent; text-decoration: none; white-space: nowrap; position: relative;
}
.sidebar-item:hover { background: var(--primary-light); color: var(--primary); }
.sidebar-item.active { color: var(--primary); background: var(--primary-light); border-left-color: var(--primary); font-weight: 700; }
.sidebar-item i { width: 18px; text-align: center; font-size: 0.9rem; flex-shrink: 0; }
.sidebar-item .sidebar-fav-badge { position: absolute; right: 8px; font-size: 0.7rem; color: #f59e0b; }

.sidebar-fav-btn {
  margin-left: auto; padding: 2px 4px; cursor: pointer; color: var(--text-muted);
  font-size: 0.7rem; opacity: 0; transition: opacity 0.15s, color 0.15s; flex-shrink: 0;
}
.sidebar-item:hover .sidebar-fav-btn { opacity: 1; }
.sidebar-fav-btn.favorited { opacity: 1; color: #f59e0b; }
.sidebar-fav-btn:hover { color: #f59e0b; transform: scale(1.2); }
.layout-sidebar.collapsed .sidebar-fav-btn { display: none; }

.sidebar-sub { padding-left: 22px; }
.sidebar-sub .sidebar-item { font-size: 0.78rem; padding: 7px 16px; border-left: none; border-left: 2px solid transparent; }
.sidebar-sub .sidebar-item:hover { border-left-color: var(--primary); }
.sidebar-sub .sidebar-item.active { border-left-color: var(--primary); }

.sidebar-group-label {
  display: flex; align-items: center; gap: 8px; padding: 6px 12px; cursor: pointer;
  color: var(--text-muted); font-size: 0.75rem; font-weight: 600;
  letter-spacing: 0.04em; transition: all 0.15s; user-select: none;
}
.sidebar-group-label:hover { color: var(--primary); }
.sidebar-group-label.active { color: var(--primary); }
.sidebar-group-label i { font-size: 0.7rem; transition: transform 0.15s; }
.sidebar-group-label.active i { transform: rotate(90deg); }

.sidebar-subgroup { padding-left: 18px; }
.sidebar-subgroup .sidebar-item { font-size: 0.78rem; padding: 6px 16px; border-left: none; border-left: 2px solid transparent; }
.sidebar-subgroup .sidebar-item:hover { border-left-color: var(--primary); }
.sidebar-subgroup .sidebar-item.active { border-left-color: var(--primary); }

/* Sidebar footer */
.sidebar-footer { padding: 12px; border-top: 1px solid var(--border-color); flex-shrink: 0; }
.sidebar-footer-btn {
  display: flex; align-items: center; gap: 8px; padding: 8px 12px; width: 100%;
  border: none; background: transparent; color: var(--text-muted); font-size: 0.8rem;
  cursor: pointer; border-radius: 8px; transition: all 0.15s;
}
.sidebar-footer-btn:hover { background: var(--primary-light); color: var(--primary); }

/* --- WORKSPACE TABS --- */
.workspace-bar {
  display: flex; flex-wrap: nowrap; align-items: center; background: var(--bg-body); border-bottom: 1px solid var(--border-color);
  height: 38px; padding: 0 !important; gap: 2px; overflow-x: auto; flex-shrink: 0;
}
.workspace-bar::-webkit-scrollbar { height: 0; }
#workspace-tabs { display: flex; flex-wrap: nowrap; align-items: center; gap: 2px; flex: 1; overflow-x: auto; min-width: 0; }
#workspace-tabs::-webkit-scrollbar { height: 0; }

.workspace-tab {
  display: flex; align-items: center; gap: 6px; padding: 6px 14px; font-size: 0.78rem;
  font-weight: 500; color: var(--text-muted); background: transparent; border: none;
  border-radius: 8px 8px 0 0; cursor: pointer; white-space: nowrap; transition: all 0.15s;
  border-bottom: 2px solid transparent; position: relative; max-width: 220px;
  min-width: 0; /* Permite que o flex child encolha e use ellipsis */
}
.workspace-tab:hover { background: var(--bg-card); color: var(--text-main); }
.workspace-tab.active { background: var(--bg-card); color: var(--primary); border-bottom-color: var(--primary); font-weight: 700; }
.workspace-tab .tab-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}
.workspace-tab i.tab-icon { font-size: 0.8rem; }
.workspace-tab .tab-close {
  width: 16px; height: 16px; display: flex; align-items: center; justify-content: center;
  border-radius: 4px; font-size: 0.65rem; color: var(--text-muted); opacity: 0; transition: all 0.15s;
  flex-shrink: 0; /* Evita que o botão de fechar encolha */
}
.workspace-tab:hover .tab-close { opacity: 1; }
.workspace-tab .tab-close:hover { background: #ef4444; color: white; }
.workspace-tab .tab-dot { width: 6px; height: 6px; border-radius: 50%; background: #10b981; flex-shrink: 0; }

.workspace-actions { display: flex; align-items: center; gap: 4px; margin-left: auto; padding-left: 8px; flex-shrink: 0; }
.workspace-actions button {
  width: 28px; height: 28px; border: none; background: transparent; color: var(--text-muted);
  border-radius: 6px; cursor: pointer; display: flex; align-items: center; justify-content: center;
  font-size: 0.8rem; transition: all 0.15s;
}
.workspace-actions button:hover { background: var(--primary-light); color: var(--primary); }

/* --- CONTENT AREA --- */
.layout-content { flex: 1; overflow: hidden; position: relative; background: var(--bg-body); }
.layout-content iframe { width: 100%; height: 100%; border: none; }
.layout-content .content-placeholder {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  height: 100%; color: var(--text-muted); gap: 16px;
}
.layout-content .content-placeholder i { font-size: 3rem; opacity: 0.3; }

/* --- SEARCH OVERLAY (Ctrl+K) - TABLER.IO STYLE --- */
.search-overlay {
  position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
  background: rgba(15, 23, 42, 0.65); backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: none; align-items: flex-start; justify-content: center;
  z-index: 99999; padding-top: 90px;
}
.search-overlay.active { display: flex; }

.search-modal {
  background: var(--bg-card); border-radius: 16px; width: 100%; max-width: 620px;
  box-shadow: 0 25px 50px -12px rgba(0,0,0,0.4), 0 0 0 1px var(--border-color);
  overflow: hidden; position: relative;
  animation: searchPopModal 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes searchPopModal {
  from { opacity: 0; transform: scale(0.95) translateY(-10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.search-modal-top-bar {
  height: 4px; width: 100%; background: var(--primary);
}

.search-input-wrap {
  display: flex; align-items: center; gap: 14px; padding: 18px 24px;
  border-bottom: 1px solid var(--border-color); background: var(--bg-card);
}
.search-input-wrap .search-icon { color: var(--primary); font-size: 1.25rem; }
.search-input-wrap input {
  flex: 1; border: none; background: transparent; font-size: 1.05rem; font-weight: 500;
  color: var(--text-main); outline: none; font-family: 'Inter', sans-serif;
}
.search-input-wrap input::placeholder { color: var(--text-muted); opacity: 0.8; }

/* DESTAQUE EVIDENTE DA TECLA ESC NO TABLER.IO */
.kbd-esc-btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 4px 10px; border-radius: 6px; font-size: 0.75rem; font-weight: 800;
  background: #ef4444; color: #ffffff; border: none;
  box-shadow: 0 2px 8px rgba(239, 68, 68, 0.35); cursor: pointer;
  transition: all 0.15s ease; font-family: 'Inter', sans-serif; letter-spacing: 0.5px;
}
.kbd-esc-btn:hover {
  background: #dc2626; transform: scale(1.05); box-shadow: 0 4px 12px rgba(239, 68, 68, 0.5);
}
.kbd-esc-btn:active { transform: scale(0.95); }

.search-results { max-height: 380px; overflow-y: auto; padding: 10px; background: var(--bg-card); }
.search-result-item {
  display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-radius: 10px;
  cursor: pointer; transition: all 0.15s; text-decoration: none; color: var(--text-main);
  border: 1px solid transparent; margin-bottom: 2px;
}
.search-result-item:hover, .search-result-item.highlighted {
  background: var(--primary-light); border-color: rgba(59, 130, 246, 0.2); color: var(--primary);
}
.search-result-item i { width: 22px; text-align: center; color: var(--primary); font-size: 0.95rem; }
.search-result-item .sr-info { flex: 1; min-width: 0; }
.search-result-item .sr-title { font-size: 0.88rem; font-weight: 600; }
.search-result-item .sr-menu { font-size: 0.73rem; color: var(--text-muted); margin-bottom: 2px; font-weight: 500; }
.search-result-empty { padding: 40px 20px; text-align: center; color: var(--text-muted); font-size: 0.88rem; }

.sr-fav-btn {
  margin-left: auto; padding: 4px 6px; cursor: pointer; color: var(--text-muted);
  font-size: 0.8rem; opacity: 1; transition: color 0.15s, transform 0.15s; flex-shrink: 0;
  border: none; background: transparent; border-radius: 4px; display: inline-flex; align-items: center; justify-content: center;
}
.sr-fav-btn.favorited { color: #f59e0b; }
.sr-fav-btn:hover { color: #f59e0b; transform: scale(1.2); }

.search-modal-footer {
  display: flex; align-items: center; justify-content: flex-end; gap: 16px;
  padding: 10px 20px; background: var(--bg-body); border-top: 1px solid var(--border-color);
}
.search-footer-hint { font-size: 0.72rem; color: var(--text-muted); display: flex; align-items: center; gap: 4px; font-weight: 500; }
.search-footer-hint kbd {
  padding: 2px 6px; border-radius: 4px; font-size: 0.68rem; font-weight: 700;
  background: var(--bg-card); color: var(--text-main); border: 1px solid var(--border-color);
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
.search-footer-hint kbd.kbd-esc-hint {
  background: rgba(239, 68, 68, 0.15); color: #ef4444; border-color: rgba(239, 68, 68, 0.3);
}

/* Suporte ao Tema Escuro no Modal Tabler.io */
body.dark-theme .search-modal, .dark-theme .search-modal {
  background: var(--bg-card); border-color: var(--border-color);
}
body.dark-theme .search-input-wrap input, .dark-theme .search-input-wrap input {
  color: #f8fafc;
}
body.dark-theme .search-modal-footer, .dark-theme .search-modal-footer {
  background: rgba(15, 23, 42, 0.6);
}

/* --- MENU DROPDOWN MAIS USADOS (ESTILO TABLER.IO) --- */
.mais-usados-dropdown {
  position: absolute; top: calc(100% + 8px); right: 80px;
  width: 350px; background: var(--bg-card); border-radius: 12px;
  border: 1px solid var(--border-color); box-shadow: 0 15px 35px rgba(0,0,0,0.25);
  overflow: hidden; z-index: 1000; display: none;
  animation: searchPopModal 0.2s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
.mais-usados-dropdown.active { display: block; }

.mais-usados-header {
  background: #e2e8f0; color: #475569; padding: 10px 16px;
  font-weight: 700; font-size: 0.85rem; text-align: center;
  font-family: 'Outfit', sans-serif; border-bottom: 1px solid var(--border-color);
  letter-spacing: -0.01em;
}
.dark-theme .mais-usados-header, body.dark-theme .mais-usados-header {
  background: #334155; color: #f1f5f9; border-color: #475569;
}

.mais-usados-body { max-height: 380px; overflow-y: auto; padding: 6px; }
.mais-usados-item {
  display: flex; align-items: center; gap: 12px; padding: 10px 14px;
  border-radius: 8px; cursor: pointer; transition: all 0.15s;
  color: var(--text-main); font-size: 0.82rem; border: 1px solid transparent;
}
.mais-usados-item:hover {
  background: var(--primary-light); color: var(--primary);
  border-color: rgba(59, 130, 246, 0.15);
}
.mais-usados-item i { width: 20px; text-align: center; color: var(--primary); font-size: 0.9rem; flex-shrink: 0; }
.mais-usados-item .mu-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.82rem; font-weight: 500; }

/* --- TOPBAR ELEMENTS --- */
.topbar-btn {
  width: 34px; height: 34px; border: none; background: transparent; color: var(--text-muted);
  border-radius: 8px; cursor: pointer; display: flex; align-items: center; justify-content: center;
  font-size: 0.9rem; transition: all 0.15s; position: relative;
}
.topbar-btn:hover { background: var(--primary-light); color: var(--primary); }
.topbar-btn .badge-dot {
  position: absolute; top: 6px; right: 6px; width: 8px; height: 8px;
  border-radius: 50%; background: #ef4444; border: 2px solid var(--bg-card);
}

.topbar-search {
  display: flex; align-items: center; gap: 10px; padding: 6px 14px;
  background: var(--bg-body); border: 1px solid var(--border-color); border-radius: 8px;
  cursor: pointer; transition: all 0.2s ease; min-width: 200px; flex: 0 1 270px;
  user-select: none;
}
.topbar-search:hover { border-color: var(--primary); box-shadow: 0 2px 8px rgba(0,0,0,0.06); }
.topbar-search i { color: var(--primary); font-size: 0.85rem; }
.topbar-search span { font-size: 0.82rem; color: var(--text-muted); font-weight: 500; flex: 1; }
.topbar-search kbd {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 3px 7px; font-size: 0.68rem; font-weight: 700;
  font-family: 'Inter', -apple-system, sans-serif; border-radius: 6px;
  background: #e2e8f0; color: #334155; border: 1px solid #cbd5e1;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05); letter-spacing: 0.5px; line-height: 1;
}

/* Tema Escuro - Legibilidade e Destaque para Ctrl+K */
body.dark-theme .topbar-search,
.dark-theme .topbar-search {
  background: rgba(15, 23, 42, 0.7); border-color: #334155;
}
body.dark-theme .topbar-search:hover,
.dark-theme .topbar-search:hover {
  border-color: var(--primary); background: rgba(30, 41, 59, 0.9);
}
body.dark-theme .topbar-search span,
.dark-theme .topbar-search span {
  color: #94a3b8;
}
body.dark-theme .topbar-search kbd,
.dark-theme .topbar-search kbd {
  background: #1e293b; color: #38bdf8; border: 1px solid #334155;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.topbar-right { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.topbar-uen {
  display: flex; align-items: center; gap: 8px; padding: 4px 10px;
  background: var(--bg-body); border: 1px solid var(--border-color); border-radius: 8px;
  flex: 1;
  min-width: 0;
}
.topbar-uen select {
  border: none; background: transparent; color: var(--text-main); font-size: 0.8rem;
  font-weight: 600; outline: none; cursor: pointer;
  max-width: 280px; overflow: hidden; text-overflow: ellipsis;
}
.topbar-uen img { height: 22px; }

/* --- FAVORITES DRAWER --- */
.favorites-drawer {
  position: fixed; top: 48px; right: -320px; width: 300px; height: calc(100vh - 48px);
  background: var(--bg-card); border-left: 1px solid var(--border-color);
  box-shadow: -4px 0 20px rgba(0,0,0,0.1); z-index: 200; transition: right 0.25s ease;
  display: flex; flex-direction: column;
}
.favorites-drawer.open { right: 0; }
.favorites-drawer-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border-color);
}
.favorites-drawer-header h3 { margin: 0; font-size: 0.9rem; font-weight: 700; color: var(--text-main); }
.favorites-drawer-body { flex: 1; overflow-y: auto; padding: 12px; }
.fav-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 8px;
  cursor: pointer; transition: background 0.15s; color: var(--text-main); text-decoration: none;
}
.fav-item:hover { background: var(--primary-light); }
.fav-item i { width: 18px; text-align: center; color: var(--primary); font-size: 0.85rem; }
.fav-item span { font-size: 0.82rem; font-weight: 500; }

/* --- RESPONSIVE --- */
@media (max-width: 768px) {
  .layout-sidebar { position: fixed; left: -260px; top: 48px; height: calc(100vh - 48px); z-index: 300; transition: left 0.25s ease; overflow-x: visible !important; }
  .layout-sidebar.mobile-open { left: 0; }
  .workspace-tab { max-width: 120px; }
  .topbar-search { display: none; }
}

.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0,0,0,0.4);
  z-index: 299;
  animation: fadeIn 0.2s ease;
}
.sidebar-overlay.active {
  display: block;
}

.dark-theme .sidebar-overlay {
  background: rgba(0,0,0,0.6);
}

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

/* --- FILTER BAR (padrão para telas especialistas) --- */
.filter-bar {
  display: flex; flex-wrap: nowrap; align-items: center; gap: 6px; padding: 5px 10px;
  background: var(--bg-card); border: 1px solid var(--border-color);
  border-radius: 10px; margin-bottom: 12px; overflow-x: auto;
}
.filter-bar .filter-group {
  display: flex; align-items: center; gap: 3px;
}
.filter-bar label {
  font-size: 0.7rem; font-weight: 600; color: var(--text-muted); white-space: nowrap;
}
.filter-bar input[type="date"],
.filter-bar select {
  padding: 2px 6px; border: 1px solid var(--border-color); border-radius: 4px;
  background: var(--bg-body); color: var(--text-main); font-size: 0.7rem;
  min-width: 95px; height: 22px;
  max-width: 350px;
}
.filter-bar .filter-sep {
  color: var(--text-muted); font-size: 0.65rem;
}
.filter-bar button {
  padding: 3px 8px; background: var(--primary); color: white; border: none;
  border-radius: 5px; font-size: 0.7rem; font-weight: 600; cursor: pointer;
  display: flex; align-items: center; gap: 4px; white-space: nowrap;
}
.filter-bar button:hover { opacity: 0.85; }
.filter-bar .filter-time {
  font-size: 0.65rem; color: var(--text-muted); font-family: monospace; white-space: nowrap;
}

/* Custom select dentro do filter-bar */
.filter-bar .custom-select-wrap {
  min-width: 180px;
}
.filter-bar .custom-select-trigger {
  font-size: 0.75rem;
  padding: 4px 28px 4px 8px;
  border-radius: 5px;
}

/* --- CUSTOM SELECT DROPDOWN (tema-aware & estilo Tabler.io) --- */
.custom-select-wrap {
  position: relative;
  display: inline-block;
}

.custom-select-trigger {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  padding: 6px 32px 6px 12px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background: var(--bg-card);
  color: var(--text-main);
  font-size: 0.8rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 280px;
  transition: border-color 0.15s, box-shadow 0.15s;
  position: relative;
}

.custom-select-trigger:hover {
  border-color: var(--primary);
}

.custom-select-wrap.open .custom-select-trigger {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.custom-select-trigger::after {
  content: '';
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid var(--text-muted);
  pointer-events: none;
  transition: transform 0.15s ease;
}

.custom-select-wrap.open .custom-select-trigger::after {
  border-top-color: var(--primary);
  transform: translateY(-50%) rotate(180deg);
}

.custom-select-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 9999;
  min-width: 100%;
  max-height: 220px;
  overflow-y: auto;
  border-radius: 4px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12);
  padding: 4px 0;
}

.custom-select-wrap.open .custom-select-dropdown {
  display: block;
}

.custom-select-option {
  padding: 8px 12px;
  cursor: pointer;
  font-size: 0.8rem;
  color: var(--text-main);
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
  font-weight: 500;
}

.custom-select-option:hover {
  background: var(--primary-light);
  color: var(--primary);
}

.custom-select-option.selected {
  background: var(--primary);
  color: #fff;
  font-weight: 700;
}

.custom-select-dropdown::-webkit-scrollbar {
  width: 6px;
}

.custom-select-dropdown::-webkit-scrollbar-track {
  background: transparent;
}

.custom-select-dropdown::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 3px;
}

/* Overrides para o seletor de empresa (UEN) na topbar */
.topbar-uen .custom-select-wrap {
  flex-grow: 1;
  width: 100%;
}

.topbar-uen .custom-select-trigger {
  background: transparent !important;
  border: none !important;
  max-width: 100% !important;
  width: 100% !important;
  padding: 0 24px 0 8px !important;
  font-size: 0.8rem !important;
  font-weight: 800 !important;
  color: var(--text-main) !important;
}

.topbar-uen .custom-select-dropdown {
  top: calc(100% + 8px) !important;
  bottom: auto !important;
  min-width: 100% !important;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15) !important;
}

/* ============================================================
   MODAL DE CONEXÃO EXPIRADA / SESSÃO (ESTILO ELEGANTE TABLER.IO)
   ============================================================ */
.session-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
    animation: sessionFadeIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

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

.session-modal-card {
    background: var(--bg-card, #ffffff);
    border-radius: 16px;
    width: 100%;
    max-width: 440px;
    overflow: hidden;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.35), 0 0 0 1px var(--border-color, rgba(226, 232, 240, 0.8));
    animation: sessionPopModal 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
    position: relative;
    box-sizing: border-box;
}

@keyframes sessionPopModal {
    from { opacity: 0; transform: scale(0.9) translateY(12px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.session-modal-top-bar {
    height: 5px;
    width: 100%;
    background: var(--primary, #3b82f6);
}

.session-modal-body {
    padding: 32px 28px 28px 28px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-sizing: border-box;
}

.session-modal-icon-badge {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    margin-bottom: 20px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.06);
    position: relative;
    background: var(--primary-light, rgba(59, 130, 246, 0.15));
    color: var(--primary, #3b82f6);
}

.session-modal-title {
    font-family: 'Outfit', 'Inter', -apple-system, sans-serif;
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--text-main, #1e293b);
    margin: 0 0 6px 0;
    letter-spacing: -0.02em;
}

.session-modal-subtitle {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted, #64748b);
    margin: 0 0 20px 0;
}

.session-modal-box {
    background: var(--bg-body, rgba(248, 250, 252, 0.8));
    border: 1px dashed var(--border-color, #cbd5e1);
    border-radius: 12px;
    padding: 16px;
    width: 100%;
    margin-bottom: 24px;
    box-sizing: border-box;
}

.session-modal-box p {
    margin: 0;
    font-size: 0.88rem;
    color: var(--text-main, #334155);
    line-height: 1.5;
}

.session-modal-btn {
    width: 100%;
    padding: 14px 20px;
    border-radius: 10px;
    border: none;
    background: var(--primary, #3b82f6);
    color: #ffffff;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: all 0.2s ease;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.15);
}

.session-modal-btn:hover {
    filter: brightness(1.08);
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.22);
}

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

/* Suporte completo ao tema escuro do ERP */
body.dark-theme .session-modal-card,
.dark-theme .session-modal-card {
    background: var(--bg-card, #1e293b);
    border-color: var(--border-color, #334155);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.6);
}

body.dark-theme .session-modal-title,
.dark-theme .session-modal-title {
    color: var(--text-main, #f8fafc);
}

body.dark-theme .session-modal-subtitle,
.dark-theme .session-modal-subtitle {
    color: var(--text-muted, #94a3b8);
}

body.dark-theme .session-modal-box,
.dark-theme .session-modal-box {
    background: rgba(15, 23, 42, 0.5);
    border-color: rgba(255, 255, 255, 0.12);
}

body.dark-theme .session-modal-box p,
.dark-theme .session-modal-box p {
    color: var(--text-main, #cbd5e1);
}

/* ==========================================================================
   REGRAS UNIVERSAIS DE RESPONSIVIDADE 100% (SMARTPHONES & TABLETS)
   ========================================================================== */

/* 1. DISPOSITIVOS MÓVEIS (SMARTPHONES < 768px) */
@media (max-width: 768px) {
    html, body {
        overflow-x: hidden !important;
        width: 100% !important;
        max-width: 100% !important;
    }

    .dashboard-container,
    .main-container,
    .content-area,
    .container-fluid {
        padding: 8px 10px !important;
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
        overflow-x: hidden !important;
    }

    /* BARRA DE FILTROS RESPONSIVA 100% EM SMARTPHONES */
    .filter-bar {
        display: flex !important;
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 8px !important;
        padding: 10px !important;
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
        overflow-x: visible !important;
        border-radius: 12px !important;
    }

    .filter-bar > div,
    .filter-bar .filter-group {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: wrap !important;
        align-items: center !important;
        gap: 6px !important;
        width: 100% !important;
        min-width: 0 !important;
        flex: 1 1 auto !important;
    }

    .filter-bar input[type="date"],
    .filter-bar select,
    .filter-bar .form-select,
    .filter-bar .form-control {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        flex: 1 1 100% !important;
        height: 38px !important;
        font-size: 0.85rem !important;
        padding: 6px 10px !important;
        box-sizing: border-box !important;
        border-radius: 6px !important;
    }

    .filter-bar .filter-sep {
        display: none !important;
    }

    .filter-bar button,
    .filter-bar .btn-primary-sm,
    .filter-bar .btn {
        width: 100% !important;
        height: 40px !important;
        justify-content: center !important;
        font-size: 0.9rem !important;
        font-weight: 700 !important;
        box-sizing: border-box !important;
        border-radius: 6px !important;
    }

    .filter-bar .filter-time {
        display: block !important;
        width: 100% !important;
        text-align: center !important;
        margin-top: 2px !important;
        font-size: 0.72rem !important;
    }

    #section-title {
        font-size: 0.9rem !important;
        white-space: normal !important;
        word-break: break-word !important;
    }

    /* PAINEL HERO E GROUP SPLIT */
    .group-split {
        flex-direction: column !important;
        width: 100% !important;
        max-width: 100% !important;
        overflow: hidden !important;
    }

    .group-hero-panel {
        width: 100% !important;
        max-width: 100% !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: center !important;
        text-align: center !important;
        border-right: none !important;
        border-bottom: 1px solid var(--border-color) !important;
        padding: 12px 10px !important;
        box-sizing: border-box !important;
    }

    .group-hero-panel .group-illustration {
        height: 70px !important;
        width: auto !important;
        max-width: 120px !important;
        margin: 4px auto !important;
    }

    .hero-value-inner {
        width: 100% !important;
        max-width: 100% !important;
        padding: 6px 10px !important;
        text-align: center !important;
        box-sizing: border-box !important;
    }

    .hero-kpi-value {
        font-size: 1.4rem !important;
        white-space: normal !important;
        word-break: break-word !important;
        text-align: center !important;
    }

    /* CARDS PRINCIPAIS DE GRÁFICOS (1 COLUNA TOTALMENTE ESPAÇOSA NO CELULAR) */
    .dashboard-grid,
    .dash-grid-main,
    .dash-grid-bottom,
    .dash-grid,
    .geo-grid,
    .chart-grid,
    .gauges-container {
        display: flex !important;
        flex-direction: column !important;
        grid-template-columns: 1fr !important;
        gap: 12px !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }

    /* CARDS DE RESUMO E KPIS (2 COLUNAS LIMPAS NO CELULAR) */
    .summary-grid,
    .group-content.summary-grid,
    .operational-grid,
    .shortcuts-grid,
    .widget-grid,
    .recent-grid {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 8px !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }

    /* LINHA DE 6 KPIS EM METAS (REARRANJO RESPONSIVO) */
    div[style*="repeat(6, 1fr)"],
    div[style*="repeat(6,1fr)"],
    .kpi-row-6 {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 8px !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }

    .main-card,
    .widget-card,
    .recent-card,
    .summary-card,
    .dash-card,
    .mini-card,
    .gauge-card,
    .operational-card {
        padding: 14px 12px !important;
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
        overflow: hidden !important;
        border-radius: 12px !important;
    }

    .card-value,
    .widget-value,
    .kpi-value {
        font-size: 1.2rem !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
    }

    /* TABELAS E GRAFICOS */
    .table-responsive {
        width: 100% !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        margin-bottom: 12px !important;
    }

    [id^="target-"],
    .dash-chart,
    .gauge-visual {
        min-height: 220px !important;
        width: 100% !important;
    }
}

/* 2. DISPOSITIVOS PEQUENOS (SMARTPHONES ESTREITOS < 480px) */
@media (max-width: 480px) {
    .summary-grid,
    .group-content.summary-grid,
    .operational-grid,
    .shortcuts-grid,
    div[style*="repeat(6, 1fr)"],
    div[style*="repeat(6,1fr)"] {
        grid-template-columns: 1fr 1fr !important;
        gap: 6px !important;
    }

    .hero-kpi-value {
        font-size: 1.25rem !important;
    }

    .ranking-item-premium {
        flex-wrap: wrap !important;
        gap: 8px !important;
    }

    .share-bar-container {
        width: 90px !important;
    }
}

/* 3. TABLETS (769px até 1024px) */
@media (min-width: 769px) and (max-width: 1024px) {
    .dashboard-container {
        padding: 12px 16px !important;
    }

    .filter-bar {
        flex-wrap: wrap !important;
        gap: 8px !important;
        padding: 8px 12px !important;
    }

    .filter-bar input[type="date"],
    .filter-bar select {
        min-width: 120px !important;
    }

    .group-hero-panel {
        width: 200px !important;
        min-width: 180px !important;
    }

    .summary-grid {
        grid-template-columns: repeat(3, 1fr) !important;
    }

    .dashboard-grid,
    .dash-grid-main,
    .dash-grid-bottom,
    .chart-grid {
        grid-template-columns: 1fr 1fr !important;
        gap: 12px !important;
    }

    div[style*="repeat(6, 1fr)"],
    div[style*="repeat(6,1fr)"] {
        grid-template-columns: repeat(3, 1fr) !important;
    }
}

/* ============================================================
   Ajuste do layout dos formulários de cadastro e páginas (Cadastro/Edição/Consulta)
   Ocupar 100% da largura, alinhar botões do cabeçalho e rodapé
   ============================================================ */
/* Reset global de margens e largura para páginas carregadas dentro de iframes */
html, body {
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
    max-width: none !important;
}

.page-wrapper {
    max-width: none !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
}

.page-body {
    max-width: none !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* Alinhamento dos cabeçalhos dos formulários */
.page-header {
    padding: 12px 0 !important;
    margin: 0 !important;
    width: 100% !important;
}

.page-header .container-xl,
.page-header .container-fluid {
    max-width: none !important;
    width: 100% !important;
    padding-left: 16px !important;
    padding-right: 16px !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
}

/* Garante que o formulário ocupe toda a largura disponível */
form {
    width: 100% !important;
    max-width: none !important;
    margin: 0 !important;
}

/* Ajustes nos elementos principais do formulário para esticar sem dentes laterais */
.form-header-fields {
    margin-left: 0 !important;
    margin-right: 0 !important;
    margin-top: 0 !important;
    border-radius: 0 !important;
    padding-left: 16px !important;
    padding-right: 16px !important;
}

.tabs-container {
    margin-left: 0 !important;
    margin-right: 0 !important;
    border-radius: 0 !important;
    border-left: none !important;
    border-right: none !important;
}

.tab-content {
    padding-left: 16px !important;
    padding-right: 16px !important;
}

/* Alinhamento perfeito dos botões de Salvar/Voltar no rodapé e no cabeçalho */
.form-footer {
    max-width: none !important;
    width: 100% !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    border-radius: 0 !important;
    padding-left: 16px !important;
    padding-right: 16px !important;
    box-sizing: border-box !important;
}




