/* HORIZON SGE 29.9.1 — HOTFIX dark mode baseado na homologação visual real.
   Carregado por último: corrige superfícies que permaneciam claras e mantém os painéis institucionais azuis. */
:is(#horizon-sge-app.hsg-dark,#horizon-sge-app[data-hsg-theme="dark"],body.hsg-dark #horizon-sge-app){
 --d-bg:#07111f;--d-bg2:#091727;--d-surface:#0f1e30;--d-surface2:#14273b;--d-surface3:#1a3048;
 --d-border:#2a425b;--d-text:#edf5fd;--d-muted:#9eb3c8;--d-blue:#72b9f6;
 color-scheme:dark;color:var(--d-text)!important;background:var(--d-bg)!important;
}
:is(#horizon-sge-app.hsg-dark,#horizon-sge-app[data-hsg-theme="dark"],body.hsg-dark #horizon-sge-app) #system-container{
 background:var(--d-bg)!important;color:var(--d-text)!important;
}
/* Fundo geral: escuro com a mesma textura pontilhada discreta usada no claro. */
:is(#horizon-sge-app.hsg-dark,#horizon-sge-app[data-hsg-theme="dark"],body.hsg-dark #horizon-sge-app) #system-container .main-content{
 background-color:var(--d-bg)!important;
 background-image:radial-gradient(circle,rgba(114,185,246,.055) 1px,transparent 1.2px),linear-gradient(180deg,#081421 0%,#07111f 100%)!important;
 background-size:24px 24px,100% 100%!important;color:var(--d-text)!important;
}
:is(#horizon-sge-app.hsg-dark,#horizon-sge-app[data-hsg-theme="dark"],body.hsg-dark #horizon-sge-app) :where(.view-section,.content-area){background:transparent!important;color:var(--d-text)!important}

/* Barra superior inteira, incluindo os elementos que na captura permaneciam brancos. */
:is(#horizon-sge-app.hsg-dark,#horizon-sge-app[data-hsg-theme="dark"],body.hsg-dark #horizon-sge-app) #system-container .top-header{
 background:var(--d-surface)!important;border:1px solid var(--d-border)!important;border-radius:16px!important;
 padding:10px 12px!important;color:var(--d-text)!important;box-shadow:0 8px 22px rgba(0,0,0,.13)!important;
}
:is(#horizon-sge-app.hsg-dark,#horizon-sge-app[data-hsg-theme="dark"],body.hsg-dark #horizon-sge-app) #page-title{color:var(--d-text)!important}
:is(#horizon-sge-app.hsg-dark,#horizon-sge-app[data-hsg-theme="dark"],body.hsg-dark #horizon-sge-app) .top-header :where(.menu-toggle,.h29-sidebar-resize,.icon-btn,.h29-notification-trigger,#hsgThemeToggle,.hx-search,.hx-clock,.profile-trigger){
 background:var(--d-surface2)!important;color:#dcecff!important;border-color:var(--d-border)!important;box-shadow:none!important;
}
:is(#horizon-sge-app.hsg-dark,#horizon-sge-app[data-hsg-theme="dark"],body.hsg-dark #horizon-sge-app) .top-header :where(.menu-toggle,.h29-sidebar-resize,.icon-btn,.h29-notification-trigger,#hsgThemeToggle,.hx-search,.hx-clock,.profile-trigger):hover{
 background:var(--d-surface3)!important;border-color:#3d6588!important;
}
:is(#horizon-sge-app.hsg-dark,#horizon-sge-app[data-hsg-theme="dark"],body.hsg-dark #horizon-sge-app) .top-header .hx-search kbd{background:#0b1827!important;color:#9fb8d0!important;border-color:#314a62!important}
:is(#horizon-sge-app.hsg-dark,#horizon-sge-app[data-hsg-theme="dark"],body.hsg-dark #horizon-sge-app) .top-header :where(.profile-name,.profile-name strong){color:var(--d-text)!important}
:is(#horizon-sge-app.hsg-dark,#horizon-sge-app[data-hsg-theme="dark"],body.hsg-dark #horizon-sge-app) .top-header .profile-name small{color:var(--d-muted)!important}

/* Cards principais do dashboard: continuam identificáveis por cor, porém sem fundos claros. */
:is(#horizon-sge-app.hsg-dark,#horizon-sge-app[data-hsg-theme="dark"],body.hsg-dark #horizon-sge-app) #system-container .dashboard-link-card{
 color:var(--d-text)!important;box-shadow:none!important;
}
:is(#horizon-sge-app.hsg-dark,#horizon-sge-app[data-hsg-theme="dark"],body.hsg-dark #horizon-sge-app) #system-container .dashboard-link-card.tone-blue{background:linear-gradient(145deg,#10263c,#153752)!important;border-color:#2d638c!important}
:is(#horizon-sge-app.hsg-dark,#horizon-sge-app[data-hsg-theme="dark"],body.hsg-dark #horizon-sge-app) #system-container .dashboard-link-card.tone-teal{background:linear-gradient(145deg,#102b2e,#153b3e)!important;border-color:#2e686a!important}
:is(#horizon-sge-app.hsg-dark,#horizon-sge-app[data-hsg-theme="dark"],body.hsg-dark #horizon-sge-app) #system-container .dashboard-link-card.tone-rose{background:linear-gradient(145deg,#30202a,#432832)!important;border-color:#6d3b4c!important}
:is(#horizon-sge-app.hsg-dark,#horizon-sge-app[data-hsg-theme="dark"],body.hsg-dark #horizon-sge-app) #system-container .dashboard-link-card.tone-amber{background:linear-gradient(145deg,#302a1c,#413820)!important;border-color:#685a31!important}
:is(#horizon-sge-app.hsg-dark,#horizon-sge-app[data-hsg-theme="dark"],body.hsg-dark #horizon-sge-app) #system-container .dashboard-link-card :where(h3,.card-link-hint){color:#b8cce0!important}
:is(#horizon-sge-app.hsg-dark,#horizon-sge-app[data-hsg-theme="dark"],body.hsg-dark #horizon-sge-app) #system-container .dashboard-link-card.tone-blue .number{color:#77bdf8!important}
:is(#horizon-sge-app.hsg-dark,#horizon-sge-app[data-hsg-theme="dark"],body.hsg-dark #horizon-sge-app) #system-container .dashboard-link-card.tone-teal .number{color:#72d4c9!important}
:is(#horizon-sge-app.hsg-dark,#horizon-sge-app[data-hsg-theme="dark"],body.hsg-dark #horizon-sge-app) #system-container .dashboard-link-card.tone-rose .number{color:#ff9caf!important}
:is(#horizon-sge-app.hsg-dark,#horizon-sge-app[data-hsg-theme="dark"],body.hsg-dark #horizon-sge-app) #system-container .dashboard-link-card.tone-amber .number{color:#f5ca72!important}

/* Central de inteligência: os quatro indicadores também usam tons escuros equivalentes. */
:is(#horizon-sge-app.hsg-dark,#horizon-sge-app[data-hsg-theme="dark"],body.hsg-dark #horizon-sge-app) #system-container .hsg-inteligencia-panel{background:transparent!important;color:var(--d-text)!important}
:is(#horizon-sge-app.hsg-dark,#horizon-sge-app[data-hsg-theme="dark"],body.hsg-dark #horizon-sge-app) #system-container .hsg-int-head :where(h3,strong){color:var(--d-text)!important}
:is(#horizon-sge-app.hsg-dark,#horizon-sge-app[data-hsg-theme="dark"],body.hsg-dark #horizon-sge-app) #system-container .hsg-int-head small{color:var(--d-muted)!important}
:is(#horizon-sge-app.hsg-dark,#horizon-sge-app[data-hsg-theme="dark"],body.hsg-dark #horizon-sge-app) #system-container .hsg-int-grid>div{border-color:var(--d-border)!important;color:var(--d-text)!important}
:is(#horizon-sge-app.hsg-dark,#horizon-sge-app[data-hsg-theme="dark"],body.hsg-dark #horizon-sge-app) #system-container .hsg-int-grid>div:nth-child(1){background:linear-gradient(145deg,#10263c,#153752)!important}
:is(#horizon-sge-app.hsg-dark,#horizon-sge-app[data-hsg-theme="dark"],body.hsg-dark #horizon-sge-app) #system-container .hsg-int-grid>div:nth-child(2){background:linear-gradient(145deg,#102b2e,#153b3e)!important}
:is(#horizon-sge-app.hsg-dark,#horizon-sge-app[data-hsg-theme="dark"],body.hsg-dark #horizon-sge-app) #system-container .hsg-int-grid>div:nth-child(3){background:linear-gradient(145deg,#30202a,#432832)!important}
:is(#horizon-sge-app.hsg-dark,#horizon-sge-app[data-hsg-theme="dark"],body.hsg-dark #horizon-sge-app) #system-container .hsg-int-grid>div:nth-child(4){background:linear-gradient(145deg,#302a1c,#413820)!important}
:is(#horizon-sge-app.hsg-dark,#horizon-sge-app[data-hsg-theme="dark"],body.hsg-dark #horizon-sge-app) #system-container .hsg-int-grid span{color:var(--d-muted)!important}

/* Superfícies recorrentes que ainda escapavam do tema escuro. */
:is(#horizon-sge-app.hsg-dark,#horizon-sge-app[data-hsg-theme="dark"],body.hsg-dark #horizon-sge-app) #system-container :where(.table-wrapper,.table-header,.card,.content-card,.dashboard-card,.panel,.widget,.action-bar,.page-header,.search-bar,.filters-bar,.filter-card,.profile-dropdown,.h29-notification-panel,.h29-appearance-panel,.modal,.modal-content,.h32-dialog,.library-toolbar,.library-card,.library-editor,.tonico-panel,.tonico-messages,.tonico-form){
 background:var(--d-surface)!important;color:var(--d-text)!important;border-color:var(--d-border)!important;
}
:is(#horizon-sge-app.hsg-dark,#horizon-sge-app[data-hsg-theme="dark"],body.hsg-dark #horizon-sge-app) #system-container :where(.table-header,.filters-bar,.action-bar,.library-toolbar){background:var(--d-surface2)!important}
:is(#horizon-sge-app.hsg-dark,#horizon-sge-app[data-hsg-theme="dark"],body.hsg-dark #horizon-sge-app) #system-container :where(h1,h2,h3,h4,h5,h6,strong,b){color:var(--d-text)!important}
:is(#horizon-sge-app.hsg-dark,#horizon-sge-app[data-hsg-theme="dark"],body.hsg-dark #horizon-sge-app) #system-container :where(p,small,label,.muted,.text-muted,.form-hint){color:var(--d-muted)!important}
:is(#horizon-sge-app.hsg-dark,#horizon-sge-app[data-hsg-theme="dark"],body.hsg-dark #horizon-sge-app) #system-container table{background:var(--d-surface)!important;color:var(--d-text)!important}
:is(#horizon-sge-app.hsg-dark,#horizon-sge-app[data-hsg-theme="dark"],body.hsg-dark #horizon-sge-app) #system-container table th{background:var(--d-surface3)!important;color:#c4d5e5!important;border-color:var(--d-border)!important}
:is(#horizon-sge-app.hsg-dark,#horizon-sge-app[data-hsg-theme="dark"],body.hsg-dark #horizon-sge-app) #system-container table td{background:var(--d-surface)!important;color:#dce7f3!important;border-color:var(--d-border)!important}
:is(#horizon-sge-app.hsg-dark,#horizon-sge-app[data-hsg-theme="dark"],body.hsg-dark #horizon-sge-app) #system-container table tbody tr:hover td{background:var(--d-surface2)!important}
:is(#horizon-sge-app.hsg-dark,#horizon-sge-app[data-hsg-theme="dark"],body.hsg-dark #horizon-sge-app) #system-container :where(input:not([type=checkbox]):not([type=radio]),select,textarea){background:#0a1828!important;color:var(--d-text)!important;border-color:#334d66!important}
:is(#horizon-sge-app.hsg-dark,#horizon-sge-app[data-hsg-theme="dark"],body.hsg-dark #horizon-sge-app) #system-container :where(input,textarea)::placeholder{color:#70869d!important}

/* Mantém os dois banners institucionais azuis — não os transforma em cinza/escuro. */
:is(#horizon-sge-app.hsg-dark,#horizon-sge-app[data-hsg-theme="dark"],body.hsg-dark #horizon-sge-app) #system-container :where(.h29-welcome,.hsg29-control-panel){color:#fff!important}
:is(#horizon-sge-app.hsg-dark,#horizon-sge-app[data-hsg-theme="dark"],body.hsg-dark #horizon-sge-app) #system-container :where(.h29-welcome,.hsg29-control-panel) :where(h1,h2,h3,p,span,strong){color:#fff!important}

/* Componentes com estilo inline branco ainda encontrados nas telas legadas. */
:is(#horizon-sge-app.hsg-dark,#horizon-sge-app[data-hsg-theme="dark"],body.hsg-dark #horizon-sge-app) #system-container [style*="background:#fff"],
:is(#horizon-sge-app.hsg-dark,#horizon-sge-app[data-hsg-theme="dark"],body.hsg-dark #horizon-sge-app) #system-container [style*="background: #fff"],
:is(#horizon-sge-app.hsg-dark,#horizon-sge-app[data-hsg-theme="dark"],body.hsg-dark #horizon-sge-app) #system-container [style*="background:white"],
:is(#horizon-sge-app.hsg-dark,#horizon-sge-app[data-hsg-theme="dark"],body.hsg-dark #horizon-sge-app) #system-container [style*="background: white"]{background:var(--d-surface)!important;color:var(--d-text)!important;border-color:var(--d-border)!important}

/* Evita animações pesadas durante a troca de tema. */
#horizon-sge-app.hsg-theme-switching-2991 #system-container *,#horizon-sge-app.hsg-theme-switching-2991 #system-container *::before,#horizon-sge-app.hsg-theme-switching-2991 #system-container *::after{transition:none!important;animation:none!important}

@media(max-width:900px){
 :is(#horizon-sge-app.hsg-dark,#horizon-sge-app[data-hsg-theme="dark"],body.hsg-dark #horizon-sge-app) #system-container .top-header{border-radius:12px!important}
}
