/*
 * V1.03.8.41 — harmonia visual integral, login restaurado e filtros seguros.
 *
 * Esta folha é deliberadamente específica porque os módulos carregam suas
 * folhas depois do shell. Ela troca apenas cores de identidade. Cores que
 * representam estado operacional (Liberado, Parado, O.S., Preventiva,
 * Oportunidade, alertas, sucesso, erro e aviso) continuam soberanas.
 */

/* Login antigo aprovado: duas metades escuras e somente o cartão branco. */
html[data-sgo-palette] body #loginView.login-screen,
html[data-sgo-palette] body #loginView.login-screen::before{
  background:
    radial-gradient(circle at 74% 28%,rgba(var(--sgo-accent-rgb),.25),transparent 31%),
    linear-gradient(112deg,var(--sgo-theme-950) 0%,var(--sgo-theme-900) 48%,var(--sgo-theme-800) 100%)!important;
}
html[data-sgo-palette] body #loginView.login-screen .login-panel{
  background:
    radial-gradient(circle at 50% 48%,rgba(var(--sgo-accent-rgb),.27),transparent 33%),
    radial-gradient(circle at 86% 14%,rgba(255,255,255,.07),transparent 26%),
    linear-gradient(145deg,var(--sgo-theme-950),var(--sgo-theme-900) 58%,var(--sgo-theme-800))!important;
}
html[data-sgo-palette] body #loginView.login-screen .login-panel::before{
  border-color:rgba(255,255,255,.12)!important;
}
html[data-sgo-palette] body #loginView.login-screen .login-panel::after{
  background:linear-gradient(180deg,transparent,rgba(255,255,255,.14),transparent)!important;
}
html[data-sgo-palette] body #loginView.login-screen .login-card{
  background:#fff!important;
  border-color:color-mix(in srgb,var(--sgo-theme-100) 72%,#fff)!important;
  box-shadow:0 32px 88px rgba(0,0,0,.34)!important;
}

/* Cabeçalho principal: supera as regras históricas P25 carregadas por menu. */
html[data-sgo-palette] body[data-current-menu] #appView.app-shell .topbar,
html[data-sgo-palette] body[data-current-menu] #appView.app-shell .topbar.topbar-premium-vfinal{
  background:
    radial-gradient(circle at 89% 8%,rgba(255,255,255,.08),transparent 29%),
    linear-gradient(116deg,var(--sgo-theme-950) 0%,var(--sgo-theme-900) 58%,var(--sgo-theme-800) 100%)!important;
  border-color:rgba(var(--sgo-accent-rgb),.30)!important;
  box-shadow:0 18px 42px rgba(var(--sgo-accent-rgb),.20)!important;
}
html[data-sgo-palette] body[data-current-menu] #appView .topbar.topbar-premium-vfinal::before{
  background:linear-gradient(90deg,var(--sgo-theme-700),var(--sgo-secondary))!important;
}
html[data-sgo-palette] body[data-current-menu] #appView .topbar.topbar-premium-vfinal::after{
  background:linear-gradient(90deg,transparent,rgba(var(--sgo-accent-rgb),.23))!important;
}
html[data-sgo-palette] body[data-current-menu] #appView .topbar-title-text::before,
html[data-sgo-palette] body[data-current-menu] #appView .topbar.topbar-premium-vfinal .topbar-title-text::before{
  color:color-mix(in srgb,#fff 75%,var(--sgo-theme-100))!important;
}
html[data-sgo-palette] body[data-current-menu] #appView .topbar .topbar-operational-meta-p251 span::before{
  color:color-mix(in srgb,#fff 75%,var(--sgo-theme-100))!important;
}
html[data-sgo-palette] body[data-current-menu] #appView .topbar #btnGerarPDF,
html[data-sgo-palette] body[data-current-menu] #appView .topbar.topbar-premium-vfinal #btnGerarPDF{
  background:linear-gradient(135deg,var(--sgo-theme-900),var(--sgo-theme-700))!important;
  border-color:rgba(255,255,255,.22)!important;
  color:#fff!important;
}

/* Sidebar: identidade escolhida; o semáforo lateral permanece semântico. */
html[data-sgo-palette] body #appView #sidebarPrincipal.sidebar{
  background:
    radial-gradient(circle at 4% 4%,rgba(var(--sgo-accent-rgb),.20),transparent 27%),
    linear-gradient(180deg,var(--sgo-theme-950),var(--sgo-theme-900) 58%,var(--sgo-theme-950))!important;
}
html[data-sgo-palette] body #appView #sidebarPrincipal .brand span{
  color:color-mix(in srgb,#fff 68%,var(--sgo-theme-100))!important;
}
html[data-sgo-palette] body:not(.sidebar-collapsed) #appView #sidebarPrincipal .side-menu .menu-item.active,
html[data-sgo-palette] body.sidebar-collapsed #appView #sidebarPrincipal .side-menu .menu-item.active,
html[data-sgo-palette] body #appView #sidebarPrincipal .side-menu .menu-item.active{
  background:linear-gradient(135deg,var(--sgo-theme-700),var(--sgo-theme-800))!important;
  border-color:color-mix(in srgb,var(--sgo-theme-100) 30%,transparent)!important;
  box-shadow:0 10px 25px rgba(var(--sgo-accent-rgb),.26)!important;
}
html[data-sgo-palette] body #appView #sidebarPrincipal .side-menu .menu-item.active .menu-icon{
  background:rgba(255,255,255,.12)!important;
  color:#fff!important;
}
html[data-sgo-palette] body #appView #sidebarPrincipal :is(.pims-status-box,.sidebar-user){
  border-color:rgba(var(--sgo-accent-rgb),.46)!important;
  background:color-mix(in srgb,var(--sgo-theme-950) 78%,transparent)!important;
}
html[data-sgo-palette] body #appView #sidebarPrincipal :is(.status-head-v1644 small,.status-moagem-kpi-p19 small,.sidebar-user strong){
  color:color-mix(in srgb,#fff 74%,var(--sgo-theme-100))!important;
}
html[data-sgo-palette] body #appView #sidebarPrincipal .status-moagem-icon-p19{
  color:var(--sgo-theme-100)!important;
  border-color:rgba(var(--sgo-accent-rgb),.42)!important;
  background:rgba(var(--sgo-accent-rgb),.20)!important;
}

/* Controles de identidade reutilizados. */
html[data-sgo-palette] body[data-current-menu] #menuHost .btn.primary,
html[data-sgo-palette] body[data-current-menu] #modalRoot .btn.primary{
  background:linear-gradient(135deg,var(--sgo-theme-900),var(--sgo-theme-700))!important;
  border-color:var(--sgo-theme-800)!important;
  color:#fff!important;
  box-shadow:0 6px 15px rgba(var(--sgo-accent-rgb),.20)!important;
}
html[data-sgo-palette] body[data-current-menu] #menuHost :is(input,select,textarea):focus,
html[data-sgo-palette] body[data-current-menu] #modalRoot :is(input,select,textarea):focus{
  border-color:var(--sgo-theme-700)!important;
  box-shadow:0 0 0 3px rgba(var(--sgo-accent-rgb),.13)!important;
}

/* Consultas Gerais: identidade + popovers acima da tabela, sem recorte. */
html[data-sgo-palette] body[data-current-menu="consultas-gerais"] #menuHost .consultas-filters{
  position:relative!important;
  overflow:visible!important;
  border-color:var(--sgo-line)!important;
  background:color-mix(in srgb,var(--sgo-surface) 94%,var(--sgo-theme-50))!important;
  box-shadow:0 8px 22px rgba(var(--sgo-accent-rgb),.08)!important;
}
html[data-sgo-palette] body[data-current-menu="consultas-gerais"] #menuHost .consultas-filters.has-open-ms-filter-v103841,
html[data-sgo-palette] body[data-current-menu="consultas-gerais"] #menuHost .consultas-filters:has(.ms-filter.open){
  z-index:9000!important;
  isolation:auto!important;
  overflow:visible!important;
}
html[data-sgo-palette] body[data-current-menu="consultas-gerais"] #menuHost .consultas-filters.sgo-parallax-surface-host-v103839{
  overflow:visible!important;
  isolation:auto!important;
}
html[data-sgo-palette] body[data-current-menu="consultas-gerais"] #menuHost .consultas-filters>.sgo-parallax-surface-v103839{
  inset:0!important;
  border-radius:inherit!important;
}
html[data-sgo-palette] body[data-current-menu="consultas-gerais"] #menuHost .consultas-filters .ms-filter.open{
  position:relative!important;
  z-index:9100!important;
}
html[data-sgo-palette] body[data-current-menu="consultas-gerais"] #menuHost .consultas-filters .ms-filter-panel{
  z-index:9200!important;
  border-color:var(--sgo-line)!important;
  box-shadow:0 22px 55px rgba(var(--sgo-accent-rgb),.22)!important;
}
html[data-sgo-palette] body[data-current-menu="consultas-gerais"] #menuHost .consultas-table-shell{
  position:relative!important;
  z-index:1!important;
}
html[data-sgo-palette] body[data-current-menu="consultas-gerais"] #menuHost .ms-filter.open .ms-filter-button{
  border-color:var(--sgo-theme-700)!important;
  box-shadow:0 0 0 4px rgba(var(--sgo-accent-rgb),.12)!important;
}
html[data-sgo-palette] body[data-current-menu="consultas-gerais"] #menuHost .ms-option:hover,
html[data-sgo-palette] body[data-current-menu="consultas-gerais"] #menuHost .ms-option:has(input:checked){
  background:var(--sgo-theme-50)!important;
  color:var(--sgo-theme-900)!important;
}
html[data-sgo-palette] body[data-current-menu="consultas-gerais"] #menuHost .ms-option input{
  accent-color:var(--sgo-theme-700)!important;
}
html[data-sgo-palette] body[data-current-menu="consultas-gerais"] #menuHost .consultas-table thead th{
  background:var(--sgo-theme-900)!important;
  color:#fff!important;
}

/* Alocação: cabeçalhos e ações são identidade; frotas ficam semânticas. */
html[data-sgo-palette] body[data-current-menu="determinar-frente"] #menuHost #btnAdicionarAlocar,
html[data-sgo-palette] body[data-current-menu="determinar-frente"] #menuHost .det-process-order-button,
html[data-sgo-palette] body[data-current-menu="determinar-frente"] #menuHost .det-order-types-gear{
  background:linear-gradient(135deg,var(--sgo-theme-900),var(--sgo-theme-700))!important;
  border-color:var(--sgo-theme-800)!important;
  color:#fff!important;
  box-shadow:0 6px 16px rgba(var(--sgo-accent-rgb),.20)!important;
}
html[data-sgo-palette] body[data-current-menu="determinar-frente"] #menuHost #allocationGrid .process-block>.process-head,
html[data-sgo-palette] body[data-current-menu="determinar-frente"] #menuHost .process-block>.process-head{
  background:linear-gradient(100deg,var(--sgo-theme-900),var(--sgo-theme-700))!important;
  border-color:var(--sgo-theme-800)!important;
}
html[data-sgo-palette] body[data-current-menu="determinar-frente"] #menuHost .process-block>.process-head :is(h3,span,b,small){
  color:#fff!important;
}
html[data-sgo-palette] body[data-current-menu="determinar-frente"] #menuHost :is(.det-toolbar,.det-filters){
  border-color:var(--sgo-line)!important;
  box-shadow:0 8px 22px rgba(var(--sgo-accent-rgb),.07)!important;
}

/* Disponibilidade: apenas estrutura e navegação; células mantêm faixas. */
html[data-sgo-palette] body[data-current-menu="disponibilidade"] #menuHost .disp-filters{
  border-color:var(--sgo-line)!important;
  background:var(--sgo-surface)!important;
  box-shadow:0 8px 22px rgba(var(--sgo-accent-rgb),.07)!important;
}
html[data-sgo-palette] body[data-current-menu="disponibilidade"] #menuHost .matrix thead th{
  background:var(--sgo-theme-900)!important;
  color:#fff!important;
}

/* Gestão de O.S. e Falhas Acompanhadas. */
html[data-sgo-palette] body[data-current-menu="gestao-os"] #menuHost .gos-hero,
html[data-sgo-palette] body[data-current-menu="falhas-acompanhadas"] #menuHost .fac-hero{
  background:linear-gradient(135deg,var(--sgo-theme-950),var(--sgo-theme-900) 58%,var(--sgo-theme-700))!important;
  box-shadow:0 16px 38px rgba(var(--sgo-accent-rgb),.18)!important;
}
html[data-sgo-palette] body[data-current-menu="gestao-os"] #menuHost .gos-tabs button.active{
  color:var(--sgo-theme-900)!important;
  border-color:var(--sgo-line)!important;
}
html[data-sgo-palette] body[data-current-menu="falhas-acompanhadas"] #menuHost .fac-tabs button.active{
  color:var(--sgo-theme-900)!important;
  box-shadow:0 5px 14px rgba(var(--sgo-accent-rgb),.11)!important;
}
html[data-sgo-palette] body[data-current-menu="falhas-acompanhadas"] #menuHost .fac-tabs button.active span{
  background:var(--sgo-theme-100)!important;
  color:var(--sgo-theme-900)!important;
}

/* Materiais: navegação e elementos de marca, sem tocar nos KPIs semânticos. */
html[data-sgo-palette] body[data-current-menu="materiais"] #menuHost .mat-command-hero-p26{
  background:linear-gradient(135deg,var(--sgo-theme-950),var(--sgo-theme-900) 56%,var(--sgo-theme-700))!important;
}
html[data-sgo-palette] body[data-current-menu="materiais"] #menuHost .mat-view-tab.active .mat-view-tab-icon,
html[data-sgo-palette] body[data-current-menu="materiais"] #menuHost .mat-view-tab:hover .mat-view-tab-icon{
  background:var(--sgo-theme-900)!important;
  color:#fff!important;
}
html[data-sgo-palette] body[data-current-menu="materiais"] #menuHost .mat-view-tab.active strong{
  color:var(--sgo-theme-900)!important;
}
html[data-sgo-palette] body[data-current-menu="materiais"] #menuHost .materiais-table thead th{
  background:var(--sgo-theme-900)!important;
  color:#fff!important;
}
html[data-sgo-palette] body[data-current-menu="materiais"] #menuHost .materiais-filters .ms-filter.open .ms-filter-button{
  border-color:var(--sgo-theme-700)!important;
  box-shadow:0 0 0 4px rgba(var(--sgo-accent-rgb),.12)!important;
}

/* Alarmes Monit: navegação de identidade; estados continuam semânticos. */
html[data-sgo-palette] body[data-current-menu="alarmes-monit"] #menuHost .monit-hero{
  background:linear-gradient(135deg,var(--sgo-theme-950),var(--sgo-theme-900) 62%,var(--sgo-theme-700))!important;
}
html[data-sgo-palette] body[data-current-menu="alarmes-monit"] #menuHost .monit-title-icon{
  background:var(--sgo-theme-900)!important;
  box-shadow:0 7px 18px rgba(var(--sgo-accent-rgb),.20)!important;
}
html[data-sgo-palette] body[data-current-menu="alarmes-monit"] #menuHost .monit-tab.active{
  color:var(--sgo-theme-900)!important;
}
html[data-sgo-palette] body[data-current-menu="alarmes-monit"] #menuHost .monit-tab.active::after{
  background:var(--sgo-theme-700)!important;
}
html[data-sgo-palette] body[data-current-menu="alarmes-monit"] #menuHost .monit-queue-chip.active,
html[data-sgo-palette] body[data-current-menu="alarmes-monit"] #menuHost .monit-shift-buttons button.active,
html[data-sgo-palette] body[data-current-menu="alarmes-monit"] #menuHost .monit-day-toggle button.active,
html[data-sgo-palette] body[data-current-menu="alarmes-monit"] #menuHost .monit-config-group.active{
  background:var(--sgo-theme-900)!important;
  border-color:var(--sgo-theme-900)!important;
  color:#fff!important;
}
html[data-sgo-palette] body[data-current-menu="alarmes-monit"] #menuHost .monit-btn-primary{
  background:var(--sgo-theme-700)!important;
  border-color:var(--sgo-theme-700)!important;
  color:#fff!important;
}

/* Cadastros com acesso. Badges Liberado/Bloqueado/Admin não são alterados. */
html[data-sgo-palette] body[data-current-menu="definir-usuarios"] #menuHost .usuarios-hero{
  background:radial-gradient(circle at 78% 20%,rgba(var(--sgo-accent-rgb),.30),transparent 33%),linear-gradient(135deg,var(--sgo-theme-950),var(--sgo-theme-900) 55%,var(--sgo-theme-700))!important;
}
html[data-sgo-palette] body[data-current-menu="definir-usuarios"] #menuHost .usuarios-search button,
html[data-sgo-palette] body[data-current-menu="definir-usuarios"] #menuHost .usuario-editor-card>footer .usuarios-primary{
  background:var(--sgo-theme-700)!important;
  border-color:var(--sgo-theme-700)!important;
  color:#fff!important;
}
html[data-sgo-palette] body[data-current-menu="definir-usuarios"] #menuHost .usuarios-filters button.active{
  background:var(--sgo-theme-900)!important;
  border-color:var(--sgo-theme-900)!important;
  color:#fff!important;
  box-shadow:0 6px 15px rgba(var(--sgo-accent-rgb),.18)!important;
}
html[data-sgo-palette] body[data-current-menu="definir-usuarios"] #menuHost :is(.usuarios-stats strong,.usuarios-table-card h3,.usuarios-matricula){
  color:var(--sgo-theme-900)!important;
}
html[data-sgo-palette] body[data-current-menu="definir-usuarios"] #menuHost .usuarios-filters>span{
  background:var(--sgo-theme-50)!important;
  border-color:var(--sgo-line)!important;
  color:var(--sgo-theme-900)!important;
}

/* Status do Sistema e Visuais Salvos. */
html[data-sgo-palette] body[data-current-menu="sistema"] #menuHost .status-hero-v166{
  background:linear-gradient(135deg,var(--sgo-theme-950),var(--sgo-theme-900) 64%,var(--sgo-theme-700))!important;
}
html[data-sgo-palette] body[data-current-menu="sistema"] #menuHost .status-tabs-v166 button.active{
  color:var(--sgo-theme-900)!important;
}
html[data-sgo-palette] body[data-current-menu="visuais-salvos"] #menuHost :is(.visual-card.is-selected,.visual-card[aria-current="true"]){
  border-color:var(--sgo-theme-700)!important;
  box-shadow:0 0 0 3px rgba(var(--sgo-accent-rgb),.11)!important;
}

/* O desbloqueio de overflow fica restrito ao filtro de Consultas acima.
 * Nos demais menus a moldura continua recortando somente o cenário parallax. */

@media(max-width:940px){
  html[data-sgo-palette] body #loginView.login-screen,
  html[data-sgo-palette] body #loginView.login-screen::before{
    background:linear-gradient(180deg,var(--sgo-theme-950),var(--sgo-theme-900) 58%,var(--sgo-theme-800))!important;
  }
  html[data-sgo-palette] body #loginView.login-screen .login-panel{
    background:linear-gradient(180deg,var(--sgo-theme-900),var(--sgo-theme-950))!important;
  }
}

@media(max-width:780px){
  html[data-sgo-palette] body[data-current-menu="consultas-gerais"] #menuHost .consultas-filters .ms-filter-panel{
    position:fixed!important;
    z-index:20000!important;
    left:10px!important;
    right:10px!important;
    bottom:10px!important;
    width:auto!important;
    max-width:none!important;
    max-height:min(68dvh,560px)!important;
  }
}
