/* ============================================================
   PROFINANCE HUB V55.44 — TEMA CLARO CONFORTÁVEL
   Escopo visual apenas:
   - cabeçalho permanece escuro nos dois temas;
   - tema claro começa abaixo do cabeçalho;
   - reduz branco puro em fundos e superfícies;
   - preserva identidade roxo/azul/laranja e layouts existentes.
   Não altera Monitor Work/Modo TV nem regras funcionais.
   ============================================================ */

html[data-theme="light"]{
  --pf44-page:#e4e8ef;
  --pf44-page-2:#dde2ea;
  --pf44-surface:#f0f2f6;
  --pf44-surface-2:#e9edf3;
  --pf44-surface-3:#e3e8f0;
  --pf44-input:#f7f8fa;
  --pf44-line:#c5cedb;
  --pf44-line-strong:#b6c0cf;
  --pf44-ink:#252b39;
  --pf44-muted:#5f6878;
  --pf44-purple:#7754d7;
  --pf44-blue:#2587e8;
  --pf44-orange:#f5792a;
  --pf44-green:#1fa978;

  /* Atualiza variáveis já usadas pelas páginas, sem tocar no tema escuro. */
  --bg:var(--pf44-page)!important;
  --bg-alt:var(--pf44-page-2)!important;
  --bg2:var(--pf44-page-2)!important;
  --bg-elev:var(--pf44-surface-2)!important;
  --surface:var(--pf44-surface)!important;
  --surface-2:var(--pf44-surface-2)!important;
  --card:var(--pf44-surface)!important;
  --card-alt:var(--pf44-surface-2)!important;
  --card2:var(--pf44-surface-2)!important;
  --border:var(--pf44-line)!important;
  --line:var(--pf44-line)!important;
  --line-dark:var(--pf44-line)!important;
  --text:var(--pf44-ink)!important;
  --text-dim:var(--pf44-muted)!important;
  --text-faint:#7b8595!important;
  --dim:var(--pf44-muted)!important;
  --faint:#7b8595!important;
  --soft:var(--pf44-surface-2)!important;
}

/* A página clara deixa de ser branca. O gradiente é discreto para não cansar. */
html[data-theme="light"] body:not([data-module="monitor-work"]){
  color:var(--pf44-ink)!important;
  background:
    radial-gradient(900px 520px at 2% -8%,rgba(119,84,215,.13),transparent 60%),
    radial-gradient(820px 500px at 100% 0,rgba(37,135,232,.10),transparent 60%),
    radial-gradient(740px 480px at 82% 105%,rgba(245,121,42,.075),transparent 62%),
    linear-gradient(180deg,#e8ebf1 0%,#e1e5ec 52%,#e7e9ef 100%)!important;
}

/* ============================================================
   CABEÇALHO — SEMPRE O VISUAL ESCURO
   ============================================================ */
html[data-theme="light"] :is(.pf-global-header,.pf-dedicated-header,.pf-theme-inline-bar,header.topbar,header.top,.portal > header.topbar,body > .topbar){
  background:linear-gradient(100deg,rgba(15,10,36,.98),rgba(30,20,66,.98) 58%,rgba(21,19,55,.98))!important;
  border-color:rgba(155,123,255,.28)!important;
  border-bottom-color:rgba(245,121,42,.34)!important;
  color:#fff!important;
  box-shadow:0 10px 28px rgba(12,8,31,.20)!important;
  backdrop-filter:blur(16px)!important;
  -webkit-backdrop-filter:blur(16px)!important;
}
html[data-theme="light"] :is(.pf-global-header,.pf-dedicated-header,header.topbar,header.top,.portal > header.topbar,body > .topbar) :is(.user-name,.role,.who,.identity,.session-chip,.pf-global-copy b,strong,b,span,label){
  color:#fff!important;
}
html[data-theme="light"] :is(.pf-global-header,.pf-dedicated-header,header.topbar,header.top,.portal > header.topbar,body > .topbar) :is(.pf-global-copy small,.role,small){
  color:#ffad76!important;
}
html[data-theme="light"] :is(.pf-global-header,.pf-dedicated-header,header.topbar,header.top,.portal > header.topbar,body > .topbar) :is(.pf-home-link,.pf-nav-icon,.pf-tool-select,.pf-nav-monitor,.profile-btn,.tool-btn,.quick-btn,.nav-btn,.session-logout,.logout,button,a.btn){
  background:#211743!important;
  border-color:rgba(155,123,255,.38)!important;
  color:#fff!important;
  box-shadow:0 8px 20px rgba(8,8,18,.16)!important;
}
html[data-theme="light"] :is(.pf-global-header,.pf-dedicated-header,header.topbar,header.top,.portal > header.topbar,body > .topbar) :is(.pf-home-link,.pf-nav-icon,.pf-tool-select,.pf-nav-monitor,.profile-btn,.tool-btn,.quick-btn,.nav-btn,.session-logout,.logout,button,a.btn):hover{
  border-color:#f5792a!important;
  filter:none!important;
}
html[data-theme="light"] :is(.pf-global-header,.pf-dedicated-header,header.topbar,header.top,.portal > header.topbar,body > .topbar) select{
  background-color:#211743!important;
  color:#fff!important;
}
html[data-theme="light"] :is(.pf-theme-header-toggle,#pf-fixed-theme-toggle,[data-theme-toggle]){
  background:linear-gradient(145deg,#2b1d55,#1b123b)!important;
  color:#fff!important;
  border-color:rgba(169,140,255,.42)!important;
  box-shadow:0 8px 20px rgba(23,16,55,.20)!important;
}

/* ============================================================
   SUPERFÍCIES — OFF-WHITE/CINZA, NÃO BRANCO PURO
   ============================================================ */
html[data-theme="light"] body:not([data-module="monitor-work"]) :is(
  .hero-card,.hero-stats,.tool-section,.panel,.box,.widget,.section,.section-card,
  .filters,.toolbar,.table-wrap,.services,.receipt,.article-card,.assistant-card,
  .hero-main,.drawer-panel,.material-card,.viewer,.viewer-panel,.history-item,
  .modal-panel,.access-box,.mini-report,.mini-content,.workflow-card,.link-card,
  .client-row,.summary-card,.simple-chart,.analysis-card,.source-panel,
  .central-alert-banner,.report-content,.report-card,.report-table,.stage,
  .slide-stage,.admin-area,.summary-box,.doc,.board,.customer-success-board
){
  background:
    radial-gradient(circle at 96% 0,rgba(37,135,232,.055),transparent 35%),
    radial-gradient(circle at 0 100%,rgba(119,84,215,.055),transparent 42%),
    linear-gradient(150deg,#f1f3f6 0%,#eaedf2 100%)!important;
  border-color:var(--pf44-line)!important;
  box-shadow:0 12px 30px rgba(41,47,65,.085)!important;
}

html[data-theme="light"] body:not([data-module="monitor-work"]) :is(
  .card,.kpi,.stat-card,.dash-kpi,.dashboard-card,.quality-card,.contract,
  .check-card,.sound-card,.admin-panel,.permission,.integration-card,.action-card,
  .operation-card,.module-card,.tool-card,.info-card,.client,.contract-history-stat
){
  background:
    radial-gradient(circle at 94% -4%,rgba(37,135,232,.075),transparent 38%),
    linear-gradient(150deg,#f2f3f6 0%,#e9edf3 72%,#edf0f5 100%)!important;
  border-color:var(--pf44-line)!important;
  box-shadow:0 11px 28px rgba(42,48,66,.09)!important;
}

/* Mantém variação de cor entre cards, porém em base menos branca. */
html[data-theme="light"] body:not([data-module="monitor-work"]) :is(.card,.kpi,.stat-card,.tool-card,.module-card,.info-card):nth-of-type(4n+1){
  background:linear-gradient(145deg,#f1f2f5,#e9e5f4)!important;
}
html[data-theme="light"] body:not([data-module="monitor-work"]) :is(.card,.kpi,.stat-card,.tool-card,.module-card,.info-card):nth-of-type(4n+2){
  background:linear-gradient(145deg,#f0f2f5,#e3edf5)!important;
}
html[data-theme="light"] body:not([data-module="monitor-work"]) :is(.card,.kpi,.stat-card,.tool-card,.module-card,.info-card):nth-of-type(4n+3){
  background:linear-gradient(145deg,#f0f2f4,#e5efeb)!important;
}
html[data-theme="light"] body:not([data-module="monitor-work"]) :is(.card,.kpi,.stat-card,.tool-card,.module-card,.info-card):nth-of-type(4n){
  background:linear-gradient(145deg,#f1f2f4,#f0e8e2)!important;
}

/* Clientes: conserva a diferenciação visual, tirando o branco forte. */
html[data-theme="light"] body[data-module="clientes"] #clientList .client{
  background:linear-gradient(105deg,#f2f3f6 0%,#ebe8f3 58%,#e5edf4 100%)!important;
  border-color:#c3cad6!important;
}
html[data-theme="light"] body[data-module="clientes"] #clientList .client:nth-child(3n+2){
  background:linear-gradient(105deg,#f2f3f5 0%,#f0e8e2 58%,#ece8f1 100%)!important;
}
html[data-theme="light"] body[data-module="clientes"] #clientList .client:nth-child(3n){
  background:linear-gradient(105deg,#f1f2f4 0%,#e4eee9 58%,#e7ebf3 100%)!important;
}

/* Modais/drawers continuam claros, mas não estourados. */
html[data-theme="light"] body:not([data-module="monitor-work"]) :is(.modal,.drawer,.contract-history-modal,.viewer){
  color:var(--pf44-ink)!important;
  background:linear-gradient(155deg,#f2f3f6 0%,#e9edf3 100%)!important;
  border-color:var(--pf44-line)!important;
  box-shadow:0 28px 70px rgba(35,39,54,.18)!important;
}
html[data-theme="light"] body:not([data-module="monitor-work"]) :is(.modal-head,.panel-head,.section-head,.page-head){
  background:linear-gradient(105deg,rgba(119,84,215,.105),rgba(37,135,232,.065) 50%,rgba(245,121,42,.075))!important;
  border-color:var(--pf44-line)!important;
}

/* Formulários: quase branco somente onde ajuda a leitura/digitação. */
html[data-theme="light"] body:not([data-module="monitor-work"]) :is(input:not([type="checkbox"]):not([type="radio"]),select,textarea){
  background:linear-gradient(180deg,#f8f9fa,#f3f5f8)!important;
  color:var(--pf44-ink)!important;
  border-color:var(--pf44-line-strong)!important;
  box-shadow:inset 0 1px 0 rgba(255,255,255,.45)!important;
}
html[data-theme="light"] body:not([data-module="monitor-work"]) :is(input:not([type="checkbox"]):not([type="radio"]),select,textarea):focus{
  border-color:#7754d7!important;
  box-shadow:0 0 0 3px rgba(119,84,215,.13)!important;
}

/* Tabelas: cabeçalho levemente colorido, linhas em cinza confortável. */
html[data-theme="light"] body:not([data-module="monitor-work"]) table{color:#2b3342!important}
html[data-theme="light"] body:not([data-module="monitor-work"]) table thead th{
  background:linear-gradient(180deg,#ddd8ea,#d9e4ed)!important;
  color:#352a52!important;
  border-color:#b9c2cf!important;
}
html[data-theme="light"] body:not([data-module="monitor-work"]) table tbody td{
  color:#424b5b!important;
  border-color:#cbd2dc!important;
  background:rgba(240,242,246,.44)!important;
}
html[data-theme="light"] body:not([data-module="monitor-work"]) table tbody tr:nth-child(even) td{
  background:rgba(228,232,239,.58)!important;
}

/* Textos: garante leitura sobre as superfícies novas. */
html[data-theme="light"] body:not([data-module="monitor-work"]) :is(h1,h2,h3,h4,h5,strong,b,.title,.section-title,.panel-title,.identity-name,.name){
  color:var(--pf44-ink)!important;
  text-shadow:none!important;
}
html[data-theme="light"] body:not([data-module="monitor-work"]) :is(p,small,.lead,.subtitle,.muted,.dim,.hint,.help,.description,.meta,.mono,.field label,.field small){
  color:var(--pf44-muted)!important;
}
/* Reaplica texto claro somente no cabeçalho depois das regras gerais acima. */
html[data-theme="light"] :is(.pf-global-header,.pf-dedicated-header,header.topbar,header.top,.portal > header.topbar,body > .topbar) :is(h1,h2,h3,h4,h5,strong,b,.title,.user-name,.who,.identity){color:#fff!important}
html[data-theme="light"] :is(.pf-global-header,.pf-dedicated-header,header.topbar,header.top,.portal > header.topbar,body > .topbar) :is(p,small,.role,.meta,.muted){color:#ffad76!important}

/* Overlay menos pesado, mas mantém foco no modal. */
html[data-theme="light"] body:not([data-module="monitor-work"]) .overlay{
  background:rgba(31,34,47,.48)!important;
  backdrop-filter:blur(8px)!important;
}

/* HOME: reduz branco do conjunto principal sem apagar as cores dos módulos. */
html[data-theme="light"] body[data-module="portal"] .portal :is(.hero-card,.hero-stats,.tool-section,.central-launchpad){
  background:linear-gradient(150deg,#eef0f4 0%,#e7eaf0 58%,#e9edf2 100%)!important;
  border-color:#c3cad6!important;
}
html[data-theme="light"] body[data-module="portal"] .portal .tool-section .card{
  background:
    radial-gradient(circle at 92% 2%,color-mix(in srgb,var(--accent) 13%,transparent),transparent 42%),
    linear-gradient(150deg,color-mix(in srgb,var(--accent) 5%,#eff1f4) 0%,#eef0f4 58%,color-mix(in srgb,var(--accent2) 5%,#e8edf2) 100%)!important;
}

/* Login continua escuro — tema claro só interessa ao Hub depois do acesso. */
html[data-theme="light"] body[data-module="portal"] #loginScreen{
  background:#0f0a24!important;
  color:#fbf8ff!important;
}
html[data-theme="light"] body[data-module="portal"] #loginScreen :is(.login-shell,.login-brand,.login-panel-shell,.login-panel){
  color:#fbf8ff!important;
}
html[data-theme="light"] body[data-module="portal"] #loginScreen :is(h1,h2,h3,strong,b,label){color:#fbf8ff!important}
html[data-theme="light"] body[data-module="portal"] #loginScreen :is(p,small,.lead,.login-security-copy){color:#d0c6df!important}
html[data-theme="light"] body[data-module="portal"] #loginScreen :is(input,select,textarea){
  background:#1b1240!important;color:#fbf8ff!important;border-color:#4a3c73!important;
}

@media (prefers-reduced-motion:reduce){
  html[data-theme="light"] body:not([data-module="monitor-work"]) *{transition:none!important}
}
