/* ==========================================================================
   OSPrimeApp 5.8+ — Sidebar & Navegação Lateral Moderna (Glassmorphism & SaaS Pro)
   Refatorado para máxima estabilidade, alinhamento pixel-perfect e responsividade.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. ESTRUTURA GERAL DA SIDEBAR (DESKTOP)
   -------------------------------------------------------------------------- */

/* Controles exclusivos do modo mobile - ocultos por padrão e no desktop */
.mobile-drawer-close-btn,
.mobile-menu-btn,
.mobile-backdrop {
  display: none !important;
}

@media (min-width: 769px) {
  :root {
    --desktop-sidebar-w: 248px;
  }
  .mobile-drawer-close-btn,
  .mobile-menu-btn,
  .mobile-backdrop {
    display: none !important;
  }
}

@media (min-width: 769px) and (max-width: 1399px) {
  :root {
    --desktop-sidebar-w: 218px;
  }

  html body.premium-ui .sidebar {
    padding: 12px 6px 12px !important;
  }

  html body.premium-ui .sidebar .brand {
    gap: 8px !important;
    padding: 2px 2px 10px !important;
  }

  html body.premium-ui .sidebar .brand b {
    font-size: 13.5px !important;
  }

  html body.premium-ui .sidebar .brand small {
    font-size: 10px !important;
  }

  html body.premium-ui .side-nav button {
    padding: 6px 8px !important;
    font-size: 12px !important;
    gap: 8px !important;
  }

  html body.premium-ui .side-nav .nav-icon {
    width: 18px !important;
    height: 18px !important;
  }
}

@media (min-width: 769px) {
  html body.premium-ui .sidebar {
    position: fixed !important;
    left: 0 !important;
    top: 0 !important;
    bottom: 0 !important;
    height: 100vh !important;
    width: var(--desktop-sidebar-w) !important;
    min-width: var(--desktop-sidebar-w) !important;
    max-width: var(--desktop-sidebar-w) !important;
    box-sizing: border-box !important;
    display: flex !important;
    flex-direction: column !important;
    padding: 16px 10px 14px !important;
    background: linear-gradient(180deg, rgba(12, 20, 36, 0.96) 0%, rgba(8, 14, 25, 0.98) 100%) !important;
    background-image: radial-gradient(ellipse 90% 45% at 50% -12%, rgba(56, 189, 248, 0.12), transparent 70%),
                      linear-gradient(180deg, rgba(12, 20, 36, 0.96) 0%, rgba(8, 14, 25, 0.98) 100%) !important;
    border-right: 1px solid rgba(255, 255, 255, 0.07) !important;
    box-shadow: 4px 0 28px rgba(0, 0, 0, 0.28) !important;
    backdrop-filter: blur(24px) saturate(180%) !important;
    -webkit-backdrop-filter: blur(24px) saturate(180%) !important;
    color-scheme: dark !important;
    z-index: 99 !important;
    overflow: hidden !important;
  }

  html body.premium-ui .main {
    margin-left: var(--desktop-sidebar-w) !important;
    width: calc(100% - var(--desktop-sidebar-w)) !important;
  }

  /* --------------------------------------------------------------------------
     2. CABEÇALHO / MARCA DA LOJA (.brand)
     -------------------------------------------------------------------------- */
  html body.premium-ui .sidebar .brand {
    flex: 0 0 auto !important;
    display: flex !important;
    align-items: center !important;
    gap: 12px !important;
    padding: 2px 4px 14px !important;
    margin: 0 0 10px !important;
    min-height: 48px !important;
    border: 0 !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08) !important;
    background: transparent !important;
    box-shadow: none !important;
    box-sizing: border-box !important;
  }

  html body.premium-ui .sidebar .brand .brand-mark {
    width: 38px !important;
    height: 38px !important;
    min-width: 38px !important;
    border-radius: 11px !important;
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.2), rgba(56, 189, 248, 0.1)) !important;
    border: 1px solid rgba(56, 189, 248, 0.28) !important;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.15) !important;
    display: grid !important;
    place-items: center !important;
    overflow: hidden !important;
    transition: transform 0.2s ease, border-color 0.2s ease !important;
    flex-shrink: 0 !important;
  }

  html body.premium-ui .sidebar .brand:hover .brand-mark {
    transform: scale(1.04);
    border-color: rgba(56, 189, 248, 0.5) !important;
  }

  html body.premium-ui .sidebar .brand .brand-mark img {
    width: 24px !important;
    height: 24px !important;
    object-fit: contain !important;
    display: block !important;
    user-select: none !important;
    -webkit-user-drag: none !important;
  }

  html body.premium-ui .sidebar .brand .brand-mark img[src=""] {
    display: none !important;
  }

  html body.premium-ui .sidebar .brand div {
    min-width: 0 !important;
    flex: 1 1 auto !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: center !important;
    gap: 2px !important;
    overflow: hidden !important;
  }

  html body.premium-ui .sidebar .brand b {
    color: #f8fafc !important;
    font-size: 14.5px !important;
    font-weight: 750 !important;
    letter-spacing: -0.015em !important;
    line-height: 1.2 !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    display: block !important;
  }

  html body.premium-ui .sidebar .brand small {
    color: #94a3b8 !important;
    font-size: 10.5px !important;
    font-weight: 500 !important;
    letter-spacing: 0.01em !important;
    line-height: 1.2 !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    display: block !important;
  }

  /* --------------------------------------------------------------------------
     3. MENU RÁPIDO & FILTRO DE BUSCA (.desktop-premium-menu)
     -------------------------------------------------------------------------- */
  html body.premium-ui .desktop-premium-menu {
    display: flex !important;
    flex-direction: column !important;
    flex: 0 0 auto !important;
    gap: 8px !important;
    margin: 0 0 10px !important;
    padding: 0 !important;
    border: none !important;
    background: transparent !important;
    box-shadow: none !important;
  }

  /* Oculta título duplicado para visual limpo */
  html body.premium-ui .desktop-premium-title {
    display: none !important;
  }

  /* Grid 2x2 de atalhos rápidos compactos */
  html body.premium-ui .desktop-premium-actions {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 6px !important;
  }

  html body.premium-ui .desktop-premium-actions button {
    height: 33px !important;
    min-height: 33px !important;
    width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
    padding: 0 8px !important;
    border-radius: 9px !important;
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
    background: rgba(255, 255, 255, 0.03) !important;
    color: #cbd5e1 !important;
    display: inline-flex !important;
    align-items: center !important;
    gap: 7px !important;
    font-size: 11.5px !important;
    font-weight: 600 !important;
    cursor: pointer !important;
    box-shadow: none !important;
    transition: all 0.16s ease !important;
  }

  html body.premium-ui .desktop-premium-actions button b {
    width: 18px !important;
    height: 18px !important;
    min-width: 18px !important;
    flex: 0 0 18px !important;
    border-radius: 5px !important;
    background: rgba(255, 255, 255, 0.06) !important;
    display: grid !important;
    place-items: center !important;
  }

  html body.premium-ui .desktop-premium-actions button b svg {
    width: 12px !important;
    height: 12px !important;
    fill: none !important;
    stroke: currentColor !important;
    stroke-width: 1.9 !important;
    stroke-linecap: round !important;
    stroke-linejoin: round !important;
    display: block !important;
  }

  html body.premium-ui .desktop-premium-actions button span {
    flex: 1 1 auto !important;
    min-width: 0 !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
    line-height: 1 !important;
  }

  html body.premium-ui .desktop-premium-actions button:hover {
    background: rgba(255, 255, 255, 0.07) !important;
    border-color: rgba(255, 255, 255, 0.16) !important;
    color: #ffffff !important;
    transform: translateY(-1px) !important;
  }

  /* Botão "Nova OS" em destaque */
  html body.premium-ui .desktop-premium-actions button:first-child {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%) !important;
    border-color: rgba(59, 130, 246, 0.5) !important;
    color: #ffffff !important;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3) !important;
  }

  html body.premium-ui .desktop-premium-actions button:first-child b {
    background: rgba(0, 0, 0, 0.18) !important;
    color: #ffffff !important;
  }

  html body.premium-ui .desktop-premium-actions button:first-child:hover {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%) !important;
    border-color: rgba(96, 165, 250, 0.6) !important;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.42) !important;
  }

  /* Campo de busca no menu */
  html body.premium-ui .desktop-premium-search {
    height: 33px !important;
    min-height: 33px !important;
    box-sizing: border-box !important;
    border-radius: 9px !important;
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
    background: rgba(255, 255, 255, 0.03) !important;
    display: flex !important;
    align-items: center !important;
    gap: 7px !important;
    padding: 0 9px !important;
    color: #94a3b8 !important;
    transition: all 0.18s ease !important;
    cursor: text !important;
  }

  html body.premium-ui .desktop-premium-search:focus-within {
    border-color: rgba(56, 189, 248, 0.45) !important;
    background: rgba(15, 23, 42, 0.6) !important;
    box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.15) !important;
  }

  html body.premium-ui .desktop-premium-search span {
    font-size: 13px !important;
    line-height: 1 !important;
    color: #64748b !important;
    transition: color 0.18s ease !important;
    flex-shrink: 0 !important;
  }

  html body.premium-ui .desktop-premium-search:focus-within span {
    color: #38bdf8 !important;
  }

  html body.premium-ui .desktop-premium-search input {
    flex: 1 1 auto !important;
    min-width: 0 !important;
    border: 0 !important;
    outline: 0 !important;
    background: transparent !important;
    color: #f1f5f9 !important;
    font-size: 12px !important;
    font-weight: 500 !important;
    padding: 0 !important;
    box-shadow: none !important;
  }

  html body.premium-ui .desktop-premium-search input::placeholder {
    color: #64748b !important;
    font-weight: 450 !important;
  }

  /* --------------------------------------------------------------------------
     4. LISTA DE NAVEGAÇÃO & SCROLLBAR (#nav / .side-nav)
     -------------------------------------------------------------------------- */
  html body.premium-ui .sidebar nav,
  html body.premium-ui .side-nav {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    display: block !important;
    padding: 2px 2px 10px !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    scrollbar-width: thin !important;
    scrollbar-color: rgba(255, 255, 255, 0.1) transparent !important;
  }

  html body.premium-ui .sidebar nav::-webkit-scrollbar,
  html body.premium-ui .side-nav::-webkit-scrollbar {
    width: 4px !important;
    display: block !important;
  }

  html body.premium-ui .sidebar nav::-webkit-scrollbar-track,
  html body.premium-ui .side-nav::-webkit-scrollbar-track {
    background: transparent !important;
  }

  html body.premium-ui .sidebar nav::-webkit-scrollbar-thumb,
  html body.premium-ui .side-nav::-webkit-scrollbar-thumb {
    border-radius: 999px !important;
    background: rgba(255, 255, 255, 0.1) !important;
    transition: background 0.2s ease !important;
  }

  html body.premium-ui .sidebar nav:hover::-webkit-scrollbar-thumb,
  html body.premium-ui .side-nav:hover::-webkit-scrollbar-thumb {
    background: rgba(56, 189, 248, 0.28) !important;
  }

  /* --------------------------------------------------------------------------
     5. TÍTULOS DE SEÇÃO RECOLHÍVEIS (.nav-section-title)
     -------------------------------------------------------------------------- */
  html body.premium-ui .side-nav .nav-section-title,
  html body.premium-ui .sidebar nav .nav-section-title {
    min-height: 24px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 8px !important;
    margin: 14px 2px 4px !important;
    padding: 3px 6px !important;
    border: 0 !important;
    border-radius: 6px !important;
    background: transparent !important;
    box-shadow: none !important;
    color: #64748b !important;
    font-size: 10px !important;
    font-weight: 750 !important;
    letter-spacing: 0.08em !important;
    line-height: 1.2 !important;
    text-transform: uppercase !important;
    cursor: pointer !important;
    user-select: none !important;
    transition: color 0.18s ease !important;
  }

  html body.premium-ui .side-nav .nav-section-title:first-child,
  html body.premium-ui .sidebar nav .nav-section-title:first-child {
    margin-top: 2px !important;
  }

  html body.premium-ui .side-nav .nav-section-title:hover,
  html body.premium-ui .sidebar nav .nav-section-title:hover {
    color: #94a3b8 !important;
  }

  html body.premium-ui .side-nav .nav-section-title > span {
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }

  /* Linha sutil separadora */
  html body.premium-ui .side-nav .nav-section-title .desktop-section-line {
    display: block !important;
    flex: 1 1 auto !important;
    width: auto !important;
    height: 1px !important;
    background: linear-gradient(90deg, rgba(255, 255, 255, 0.08) 0%, transparent 100%) !important;
    transition: background 0.18s ease !important;
  }

  html body.premium-ui .side-nav .nav-section-title:hover .desktop-section-line {
    background: linear-gradient(90deg, rgba(56, 189, 248, 0.22) 0%, transparent 100%) !important;
  }

  /* Chevron minimalista giratório */
  html body.premium-ui .side-nav .nav-section-title .desktop-section-chevron {
    display: block !important;
    width: 6px !important;
    height: 6px !important;
    flex: 0 0 6px !important;
    border: 0 !important;
    border-right: 1.5px solid currentColor !important;
    border-bottom: 1.5px solid currentColor !important;
    transform: rotate(45deg) translate(-1px, -1px) !important;
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.2s ease !important;
    opacity: 0.65 !important;
    margin-right: 2px !important;
  }

  html body.premium-ui .side-nav .nav-section-title.desktop-section-collapsed .desktop-section-chevron {
    transform: rotate(-45deg) translate(-1px, 1px) !important;
    opacity: 0.4 !important;
  }

  /* --------------------------------------------------------------------------
     6. BOTÕES / ITENS DE NAVEGAÇÃO (.nav-item)
     -------------------------------------------------------------------------- */
  html body.premium-ui .sidebar nav button,
  html body.premium-ui .side-nav button {
    position: relative !important;
    width: 100% !important;
    min-height: 38px !important;
    box-sizing: border-box !important;
    margin: 0 0 2px !important;
    padding: 6px 10px !important;
    border: 1px solid transparent !important;
    border-radius: 10px !important;
    background: transparent !important;
    color: #94a3b8 !important;
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
    font-size: 13px !important;
    font-weight: 500 !important;
    line-height: 1.2 !important;
    text-align: left !important;
    box-shadow: none !important;
    cursor: pointer !important;
    overflow: visible !important;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease !important;
  }

  /* Hover suave com leve deslocamento lateral */
  html body.premium-ui .sidebar nav button:hover,
  html body.premium-ui .side-nav button:hover {
    background: rgba(255, 255, 255, 0.05) !important;
    border-color: rgba(255, 255, 255, 0.06) !important;
    color: #f8fafc !important;
    transform: translateX(2.5px) !important;
  }

  /* Item Ativo com brilho neon elegante e indicador lateral */
  html body.premium-ui .sidebar nav button.active,
  html body.premium-ui .side-nav button.active {
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.18) 0%, rgba(56, 189, 248, 0.10) 100%) !important;
    border-color: rgba(56, 189, 248, 0.32) !important;
    color: #ffffff !important;
    font-weight: 650 !important;
    box-shadow: 0 2px 10px rgba(37, 99, 235, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.1) !important;
    transform: none !important;
  }

  /* Barra indicadora vertical no item ativo */
  html body.premium-ui .sidebar nav button.active::before,
  html body.premium-ui .side-nav button.active::before {
    content: '' !important;
    position: absolute !important;
    left: 0 !important;
    top: 7px !important;
    bottom: 7px !important;
    width: 3.5px !important;
    border-radius: 0 4px 4px 0 !important;
    background: #38bdf8 !important;
    box-shadow: 0 0 10px rgba(56, 189, 248, 0.8) !important;
  }

  /* Remove seta antiga '›' */
  html body.premium-ui .sidebar nav button.active::after,
  html body.premium-ui .side-nav button.active::after {
    content: none !important;
    display: none !important;
  }

  /* Ícones estilizados em moldura micro-glass */
  html body.premium-ui .nav-icon,
  html body.premium-ui .desktop-nav-icon {
    width: 26px !important;
    height: 26px !important;
    min-width: 26px !important;
    flex: 0 0 26px !important;
    border-radius: 7px !important;
    background: rgba(255, 255, 255, 0.02) !important;
    border: 1px solid rgba(255, 255, 255, 0.04) !important;
    color: #94a3b8 !important;
    display: grid !important;
    place-items: center !important;
    transition: all 0.16s ease !important;
  }

  html body.premium-ui .nav-icon svg,
  html body.premium-ui .desktop-nav-icon svg {
    width: 16px !important;
    height: 16px !important;
    fill: none !important;
    stroke: currentColor !important;
    stroke-width: 1.8 !important;
    stroke-linecap: round !important;
    stroke-linejoin: round !important;
    display: block !important;
  }

  html body.premium-ui .sidebar nav button:hover .nav-icon,
  html body.premium-ui .sidebar nav button:hover .desktop-nav-icon,
  html body.premium-ui .side-nav button:hover .nav-icon,
  html body.premium-ui .side-nav button:hover .desktop-nav-icon {
    color: #38bdf8 !important;
    background: rgba(56, 189, 248, 0.1) !important;
    border-color: rgba(56, 189, 248, 0.22) !important;
  }

  html body.premium-ui .sidebar nav button.active .nav-icon,
  html body.premium-ui .sidebar nav button.active .desktop-nav-icon,
  html body.premium-ui .side-nav button.active .nav-icon,
  html body.premium-ui .side-nav button.active .desktop-nav-icon {
    color: #38bdf8 !important;
    background: rgba(56, 189, 248, 0.22) !important;
    border-color: rgba(56, 189, 248, 0.45) !important;
    box-shadow: 0 0 10px rgba(56, 189, 248, 0.3) !important;
  }

  html body.premium-ui .sidebar nav button > span:not(.nav-icon):not(.desktop-nav-icon),
  html body.premium-ui .side-nav button > span:not(.nav-icon):not(.desktop-nav-icon) {
    flex: 1 1 auto !important;
    min-width: 0 !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
    color: inherit !important;
    font-size: 13px !important;
    font-weight: inherit !important;
    line-height: 1.2 !important;
  }

  /* Badges de notificação modernas (pills com gradiente vermelho e sombra) */
  html body.premium-ui .sidebar .nav-badge,
  html body.premium-ui .side-nav .nav-badge,
  html body.premium-ui .nav-alert-badge {
    margin-left: auto !important;
    flex: 0 0 auto !important;
    min-width: 19px !important;
    height: 19px !important;
    box-sizing: border-box !important;
    padding: 0 6px !important;
    border-radius: 999px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 10px !important;
    font-weight: 800 !important;
    color: #ffffff !important;
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%) !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
    box-shadow: 0 2px 6px rgba(239, 68, 68, 0.4) !important;
  }

  html body.premium-ui .sidebar .nav-badge.hidden,
  html body.premium-ui .side-nav .nav-badge.hidden,
  html body.premium-ui .nav-alert-badge.hidden {
    display: none !important;
  }

  /* --------------------------------------------------------------------------
     7. RODAPÉ DO USUÁRIO (.session-box)
     -------------------------------------------------------------------------- */
  html body.premium-ui .sidebar .session-box {
    position: relative !important;
    left: auto !important;
    right: auto !important;
    bottom: auto !important;
    flex: 0 0 auto !important;
    margin-top: 8px !important;
    padding: 10px 11px !important;
    border-radius: 13px !important;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.04) 0%, rgba(255, 255, 255, 0.01) 100%) !important;
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2) !important;
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) auto !important;
    align-items: center !important;
    column-gap: 8px !important;
    row-gap: 2px !important;
    backdrop-filter: blur(12px) !important;
    box-sizing: border-box !important;
  }

  html body.premium-ui .sidebar .session-box span#sessionName {
    grid-area: 1 / 1 / 2 / 2 !important;
    min-width: 0 !important;
    max-width: 100% !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
    color: #f8fafc !important;
    font-size: 12.5px !important;
    font-weight: 700 !important;
    letter-spacing: -0.01em !important;
    display: block !important;
  }

  html body.premium-ui .sidebar .session-box small#sessionRole {
    grid-area: 2 / 1 / 3 / 2 !important;
    min-width: 0 !important;
    max-width: 100% !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
    color: #94a3b8 !important;
    font-size: 10.5px !important;
    font-weight: 500 !important;
    display: block !important;
    line-height: 1.3 !important;
  }

  /* Ponto de status verde conectado (alinhado verticalmente inline) */
  html body.premium-ui .sidebar .session-box small#sessionRole::before {
    content: '' !important;
    display: inline-block !important;
    vertical-align: middle !important;
    margin-right: 5px !important;
    margin-top: -2px !important;
    width: 6px !important;
    height: 6px !important;
    min-width: 6px !important;
    border-radius: 50% !important;
    background: #22c55e !important;
    box-shadow: 0 0 6px rgba(34, 197, 94, 0.8) !important;
  }

  /* Botão "Sair" moderno e discreto */
  html body.premium-ui .sidebar .session-box button#logoutBtn,
  html body.premium-ui .sidebar .session-box .btn-logout {
    grid-area: 1 / 2 / 3 / 3 !important;
    align-self: center !important;
    justify-self: end !important;
    float: none !important;
    margin: 0 !important;
    padding: 6px 11px !important;
    border: 1px solid rgba(239, 68, 68, 0.22) !important;
    border-radius: 8px !important;
    background: rgba(239, 68, 68, 0.08) !important;
    color: #fca5a5 !important;
    font-size: 11.5px !important;
    font-weight: 650 !important;
    cursor: pointer !important;
    transition: all 0.18s ease !important;
    white-space: nowrap !important;
  }

  html body.premium-ui .sidebar .session-box button#logoutBtn:hover,
  html body.premium-ui .sidebar .session-box .btn-logout:hover {
    background: rgba(239, 68, 68, 0.22) !important;
    color: #ffffff !important;
    border-color: rgba(239, 68, 68, 0.45) !important;
    transform: translateY(-1px) !important;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.35) !important;
  }

  /* Botão de alternância para o Modo Celular dentro da session-box */
  html body.premium-ui .sidebar .session-box .btn-mobile-sidebar-switch {
    grid-column: 1 / -1 !important;
    width: 100% !important;
    box-sizing: border-box !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
  }
}

/* --------------------------------------------------------------------------
   8. COMPATIBILIDADE COM SEÇÕES RECOLHIDAS, BUSCA E PERMISSÕES (JS GUARANTEES)
   -------------------------------------------------------------------------- */
/* Itens com .hidden (não autorizados ou desativados) NUNCA aparecem */
html body.premium-ui #nav .hidden,
html body.premium-ui .side-nav .hidden,
html body.premium-ui .sidebar .hidden {
  display: none !important;
}

@media (min-width: 769px) {
  /* Itens recolhidos ficam ocultos */
  html body.premium-ui .side-nav .nav-item.desktop-section-item-hidden,
  html body.premium-ui .sidebar nav button.desktop-section-item-hidden {
    display: none !important;
  }

  /* Na busca ativa, itens correspondentes se revelam mesmo em seção recolhida */
  html body.premium-ui .side-nav.desktop-searching .nav-item.desktop-section-item-hidden:not(.desktop-search-hidden):not(.hidden),
  html body.premium-ui .sidebar nav.desktop-searching button.desktop-section-item-hidden:not(.desktop-search-hidden):not(.hidden) {
    display: flex !important;
  }

  /* Itens filtrados pela busca somem */
  html body.premium-ui .sidebar nav button.desktop-search-hidden,
  html body.premium-ui .sidebar nav .nav-section-title.desktop-search-hidden,
  html body.premium-ui .side-nav .desktop-search-hidden {
    display: none !important;
  }

  /* Menu mobile nunca deve vazar no desktop */
  html body.premium-ui .premium-mobile-menu {
    display: none !important;
  }
}

/* --------------------------------------------------------------------------
   9. TELAS COM ALTURA COMPACTA (Laptops 1366x768 ou escala de display 125%/150%)
   -------------------------------------------------------------------------- */
@media (min-width: 769px) and (max-height: 780px) {
  html body.premium-ui .sidebar {
    padding: 8px 6px !important;
  }

  html body.premium-ui .sidebar .brand {
    margin-bottom: 4px !important;
    padding-bottom: 6px !important;
    min-height: 38px !important;
  }

  html body.premium-ui .desktop-premium-actions {
    display: none !important;
  }

  html body.premium-ui .desktop-premium-menu {
    margin-bottom: 4px !important;
  }

  html body.premium-ui .side-nav .nav-section-title,
  html body.premium-ui .sidebar nav .nav-section-title {
    margin: 8px 2px 2px !important;
    padding: 2px 4px !important;
  }

  html body.premium-ui .sidebar nav button,
  html body.premium-ui .side-nav button {
    min-height: 33px !important;
    padding: 4px 6px !important;
    font-size: 12px !important;
  }

  html body.premium-ui .sidebar .session-box {
    margin-top: 4px !important;
    padding: 6px 8px !important;
  }

  html body.premium-ui .sidebar .session-box .btn-mobile-sidebar-switch {
    margin: 4px 0 2px !important;
    padding: 5px 8px !important;
    font-size: 11px !important;
  }

  html body.premium-ui .sidebar .session-box span#sessionName {
    font-size: 11.5px !important;
  }

  html body.premium-ui .sidebar .session-box small#sessionRole {
    font-size: 9.5px !important;
  }

  html body.premium-ui .sidebar .session-box button#logoutBtn,
  html body.premium-ui .sidebar .session-box .btn-logout {
    padding: 4px 8px !important;
    font-size: 10px !important;
  }
}

/* --------------------------------------------------------------------------
   10. VERSÃO MOBILE APERFEIÇOADA (@media max-width: 768px)
   -------------------------------------------------------------------------- */
@media (max-width: 768px) {
  /* Menu desktop nunca deve vazar no mobile */
  html body.premium-ui .desktop-premium-menu {
    display: none !important;
  }

  html body.premium-ui .sidebar {
    z-index: 9998 !important;
    background: linear-gradient(180deg, rgba(14, 23, 40, 0.98), rgba(8, 14, 25, 0.99)) !important;
    backdrop-filter: blur(28px) !important;
    -webkit-backdrop-filter: blur(28px) !important;
    border: 1px solid rgba(56, 189, 248, 0.2) !important;
    border-radius: 24px !important;
    box-shadow: 0 -16px 48px rgba(0, 0, 0, 0.6) !important;
    padding: 14px !important;
  }

  html body.premium-ui .sidebar .brand {
    border-bottom: 1px solid rgba(255, 255, 255, 0.08) !important;
    padding-bottom: 10px !important;
    margin-bottom: 10px !important;
  }

  html body.premium-ui .premium-mobile-menu {
    border-radius: 16px !important;
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
    background: rgba(255, 255, 255, 0.03) !important;
    padding: 10px !important;
    margin-bottom: 10px !important;
  }

  html body.premium-ui .sidebar nav button,
  html body.premium-ui .side-nav button {
    min-height: 44px !important;
    border-radius: 12px !important;
    border: 1px solid rgba(255, 255, 255, 0.06) !important;
    background: rgba(255, 255, 255, 0.03) !important;
    color: #e2e8f0 !important;
    padding: 8px 12px !important;
    font-size: 13px !important;
    font-weight: 600 !important;
  }

  html body.premium-ui .sidebar nav button.active,
  html body.premium-ui .side-nav button.active {
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.3) 0%, rgba(56, 189, 248, 0.2) 100%) !important;
    border-color: rgba(56, 189, 248, 0.5) !important;
    color: #ffffff !important;
  }

  html body.premium-ui .sidebar .session-box {
    margin-top: 10px !important;
    padding: 10px 12px !important;
    border-radius: 14px !important;
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
    background: rgba(255, 255, 255, 0.04) !important;
  }
}

/* --------------------------------------------------------------------------
   11. TEMA CLARO (LIGHT THEME) REFINADO (html body.theme-light)
   -------------------------------------------------------------------------- */
@media (min-width: 769px) {
  html body.theme-light .sidebar {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.96) 0%, rgba(248, 250, 252, 0.98) 100%) !important;
    border-right: 1px solid #e2e8f0 !important;
    box-shadow: 4px 0 24px rgba(15, 23, 42, 0.04) !important;
    color-scheme: light !important;
  }

  html body.theme-light .sidebar .brand {
    border-bottom: 1px solid #eef2f6 !important;
  }

  html body.theme-light .sidebar .brand .brand-mark {
    background: #f8fafc !important;
    border-color: #cbd5e1 !important;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04) !important;
  }

  html body.theme-light .sidebar .brand b {
    color: #0f172a !important;
  }

  html body.theme-light .sidebar .brand small {
    color: #64748b !important;
  }

  html body.theme-light .desktop-premium-actions button {
    background: #ffffff !important;
    border-color: #e2e8f0 !important;
    color: #334155 !important;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03) !important;
  }

  html body.theme-light .desktop-premium-actions button b {
    background: #f1f5f9 !important;
  }

  html body.theme-light .desktop-premium-actions button:hover {
    background: #f8fafc !important;
    border-color: #cbd5e1 !important;
    color: #0f172a !important;
  }

  html body.theme-light .desktop-premium-actions button:first-child {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%) !important;
    border-color: #2563eb !important;
    color: #ffffff !important;
  }

  html body.theme-light .desktop-premium-search {
    background: #ffffff !important;
    border-color: #e2e8f0 !important;
    color: #64748b !important;
  }

  html body.theme-light .desktop-premium-search input {
    color: #0f172a !important;
  }

  html body.theme-light .desktop-premium-search input::placeholder {
    color: #94a3b8 !important;
  }

  html body.theme-light .side-nav .nav-section-title,
  html body.theme-light .sidebar nav .nav-section-title {
    color: #64748b !important;
  }

  html body.theme-light .side-nav .nav-section-title .desktop-section-line {
    background: #e2e8f0 !important;
  }

  html body.theme-light .sidebar nav button,
  html body.theme-light .side-nav button {
    color: #475569 !important;
  }

  html body.theme-light .sidebar nav button:hover,
  html body.theme-light .side-nav button:hover {
    background: #f1f5f9 !important;
    border-color: #e2e8f0 !important;
    color: #0f172a !important;
  }

  html body.theme-light .sidebar nav button.active,
  html body.theme-light .side-nav button.active {
    background: #eff6ff !important;
    border-color: #bfdbfe !important;
    color: #2563eb !important;
    box-shadow: 0 1px 3px rgba(37, 99, 235, 0.08) !important;
  }

  html body.theme-light .sidebar nav button.active::before,
  html body.theme-light .side-nav button.active::before {
    background: #2563eb !important;
    box-shadow: 0 0 8px rgba(37, 99, 235, 0.4) !important;
  }

  html body.theme-light .nav-icon,
  html body.theme-light .desktop-nav-icon {
    background: #f8fafc !important;
    border-color: #e2e8f0 !important;
    color: #64748b !important;
  }

  html body.theme-light .sidebar nav button:hover .nav-icon,
  html body.theme-light .side-nav button:hover .nav-icon {
    color: #2563eb !important;
    background: #eff6ff !important;
    border-color: #bfdbfe !important;
  }

  html body.theme-light .sidebar nav button.active .nav-icon,
  html body.theme-light .side-nav button.active .nav-icon {
    color: #2563eb !important;
    background: #dbeafe !important;
    border-color: #93c5fd !important;
    box-shadow: none !important;
  }

  html body.theme-light .sidebar .session-box {
    background: #ffffff !important;
    border-color: #e2e8f0 !important;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.03) !important;
  }

  html body.theme-light .sidebar .session-box span#sessionName {
    color: #0f172a !important;
  }

  html body.theme-light .sidebar .session-box small#sessionRole {
    color: #64748b !important;
  }

  html body.theme-light .sidebar .session-box button#logoutBtn {
    background: #fee2e2 !important;
    color: #dc2626 !important;
    border-color: #fecaca !important;
  }

  html body.theme-light .sidebar .session-box button#logoutBtn:hover {
    background: #fca5a5 !important;
    color: #991b1b !important;
  }
}

/* --------------------------------------------------------------------------
   12. ACESSIBILIDADE & FOCO VISUAL
   -------------------------------------------------------------------------- */
html body.premium-ui .sidebar nav button:focus-visible,
html body.premium-ui .side-nav button:focus-visible,
html body.premium-ui .desktop-premium-actions button:focus-visible,
html body.premium-ui .sidebar .session-box button:focus-visible {
  outline: none !important;
  border-color: #38bdf8 !important;
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.35) !important;
}
