/* Bride Era R14.7.158.4 — auditoria integral do modo escuro.
   Carregado por último: normaliza superfícies claras residuais e contraste sem
   alterar o tema claro. Elementos que precisam permanecer claros (QR/código,
   amostras de cor e previews gráficos) são explicitamente preservados. */

/* --------------------------------------------------------------------------
   1. Tokens finais do painel escuro
   -------------------------------------------------------------------------- */
html[data-panel-theme="dark"]{
  color-scheme:dark;
  --paper:#0f0d0d;
  --white:#1d1a19;
  --ink-900:#fff8f4;
  --ink-800:#f3e9e4;
  --ink-700:#ddd0c9;
  --muted-600:#c2b4ad;
  --muted-500:#a5968f;
  --line:#403734;
  --line-strong:#584943;
  --blush-50:#171414;
  --blush-100:#211c1a;
  --blush-200:#312724;
  --blush-300:#4a3832;
  --champagne-100:#28221d;
  --champagne-200:#3a3026;
  --sage-100:#1c261f;
  --ok-100:#1b2a20;
  --warn-100:#302718;
  --danger-100:#321f1e;
  --info-100:#1d2832;
  --panel:#1d1a19;
  --panel-bg:#1d1a19;
  --surface:#1d1a19;
  --surface-1:#1d1a19;
  --surface-2:#25201e;
  --surface-3:#2f2825;
  --card:#1d1a19;
  --card-bg:#1d1a19;
  --bg:#0f0d0d;
  --background:#0f0d0d;
  --soft:#282321;
  --note:#25201e;
  --text:#fff8f4;
  --ink:#fff8f4;
  --muted:#c2b4ad;
  --subtle:#a5968f;
  --border:#403734;
  --border-strong:#584943;
  --input-bg:#151313;
  --field-bg:#151313;
  --on-surface:#f3e9e4;
  --card-border:#403734;
}

html[data-panel-theme="dark"] body.app,
html[data-panel-theme="dark"] body.app :is(.app-main,.app-content,#view){
  background:#0f0d0d!important;
  color:#f3e9e4!important;
}

/* --------------------------------------------------------------------------
   2. Tipografia — elimina texto escuro/quase invisível em superfícies escuras
   -------------------------------------------------------------------------- */
html[data-panel-theme="dark"] body.app #view :is(h1,h2,h3,h4,h5,h6),
html[data-panel-theme="dark"] body.app #modalRoot :is(h1,h2,h3,h4,h5,h6),
html[data-panel-theme="dark"] body.app .app-sidebar :is(h1,h2,h3,h4,h5,h6){
  color:#fff8f4!important;
}
html[data-panel-theme="dark"] body.app #view :is(p,li,label,legend,dt,dd),
html[data-panel-theme="dark"] body.app #modalRoot :is(p,li,label,legend,dt,dd){
  color:#e7dad4;
}
html[data-panel-theme="dark"] body.app #view :is(.muted,.sub,.desc,.description,.meta,.helper,.hint,.caption,.subtitle,.small-muted),
html[data-panel-theme="dark"] body.app #modalRoot :is(.muted,.sub,.desc,.description,.meta,.helper,.hint,.caption,.subtitle,.small-muted),
html[data-panel-theme="dark"] body.app #view small,
html[data-panel-theme="dark"] body.app #modalRoot small{
  color:#c2b4ad!important;
  opacity:1;
}
html[data-panel-theme="dark"] body.app #view :is(b,strong),
html[data-panel-theme="dark"] body.app #modalRoot :is(b,strong){
  color:inherit;
}

/* --------------------------------------------------------------------------
   3. Superfícies recorrentes. A lista cobre componentes antigos e módulos das
      sprints novas que ainda continham branco/creme literal.
   -------------------------------------------------------------------------- */
html[data-panel-theme="dark"] body.app :is(#view,#modalRoot) :where(
  .panel,.panel-soft,.card,.kpi,.stat-card,.metric-card,.mini-card,.summary-card,.info-card,.result-card,.list-card,.settings-card,
  .box,.content-box,.section-box,.widget,.module-card,.feature-card,.action-card,.insight-card,.recommendation-card,.alert-card,.data-card,
  .task,.table-card,.guest-pill,.seat,.mood-item,.dropzone,.video-card,.tl-item,.check-item,.budget-card,.payment-card,.contract-card,
  .agenda-card,.calendar-card,.timeline-card,.notification-card,.conversation-card,.chat-list,.chat-window,.chat-thread,.chat-messages,
  .vendor-card,.eco-card,.pro-card,.exp-card,.supplier-kpi,.addon-subscription-card,.note-card,.history-stat,.reports-kpis>div,
  .cfg-espaco>summary,.cat-box,.cat-item,.planta-props,.kb-card,.medalha,.cenario,.opt,.paleta-card,.cal-dia,
  .md-topbar,.md-hero,.md-kpi,.md-quick,.md-secao,.md-mini-btn,.md-item,.md-forn-item,.md-missao-item,.md-oc-item,.md-kit-item,.md-planob-item,
  .dossie-dia-view,.dd-card,
  .bs133-kpi,.bs133-health,.bs133-mini-grid>div,.bs133-forecast,.bs133-shortcuts>button,
  .off134-score,.off134-kpis>div,.off134-shortcut,.off134-checks>div,.off134-data>div,
  .be155-install,.be156-week,.be156-day,.be156-ins,.be156-act,.be157-uso,.be157-uso-pop,.be157-bru-grid>div,
  [class*="-card"],[class*="_card"],[class*="-panel"],[class*="_panel"],[class*="-box"],[class*="_box"]
){
  border-color:var(--line)!important;
}

/* Só força fundo em famílias de superfície conhecidas. O guardião JS abaixo
   cobre os casos hardcoded restantes após medir a cor realmente renderizada. */
html[data-panel-theme="dark"] body.app :is(#view,#modalRoot) :where(
  .panel,.panel-soft,.card,.kpi,.stat-card,.metric-card,.mini-card,.summary-card,.info-card,.result-card,.list-card,.settings-card,
  .content-box,.section-box,.widget,.module-card,.feature-card,.action-card,.insight-card,.recommendation-card,.data-card,
  .task,.table-card,.guest-pill,.seat,.mood-item,.dropzone,.video-card,.tl-item,.check-item,
  .agenda-card,.calendar-card,.timeline-card,.notification-card,.conversation-card,.chat-list,.chat-window,.chat-thread,.chat-messages,
  .vendor-card,.eco-card,.pro-card,.exp-card,.supplier-kpi,.addon-subscription-card,.note-card,
  .cfg-espaco>summary,.cat-box,.cat-item,.planta-props,.kb-card,.medalha,.cenario,.opt,.cal-dia,
  .md-kpi,.md-quick,.md-secao,.md-mini-btn,.md-item,.md-forn-item,.md-missao-item,.md-oc-item,.md-kit-item,.md-planob-item,.dd-card
){
  background-color:#1d1a19!important;
  color:#f3e9e4!important;
}

/* Heróis/áreas grandes ficam escuras, mas mantêm profundidade visual. */
html[data-panel-theme="dark"] body.app :is(#view,#modalRoot) :where(
  [class*="-hero"],[class*="_hero"],.md-topbar,.md-hero,.dossie-dia-view,.bs133-dashboard-entry,.off134-hero
){
  border-color:#4a3d38!important;
  color:#f3e9e4!important;
}
html[data-panel-theme="dark"] body.app :is(#view,#modalRoot) :where(
  .md-topbar,.md-hero,.dossie-dia-view,.off134-hero
){
  background:linear-gradient(135deg,#211c1a,#181514)!important;
}

/* --------------------------------------------------------------------------
   4. Formulários, tabelas, abas, accordions, menus e popovers
   -------------------------------------------------------------------------- */
html[data-panel-theme="dark"] body.app :is(#view,#modalRoot,.app-sidebar) :where(input,select,textarea,[contenteditable="true"]){
  background:#151313!important;
  color:#fff8f4!important;
  border-color:#584943!important;
  caret-color:#fff8f4;
  box-shadow:none!important;
}
html[data-panel-theme="dark"] body.app :is(#view,#modalRoot,.app-sidebar) :where(input,textarea)::placeholder{color:#9f918a!important;opacity:1}
html[data-panel-theme="dark"] body.app :is(#view,#modalRoot,.app-sidebar) select option{background:#171414!important;color:#fff8f4!important}
html[data-panel-theme="dark"] body.app :is(#view,#modalRoot) :where(fieldset,details,summary){border-color:#403734!important}

html[data-panel-theme="dark"] body.app :is(#view,#modalRoot) :where(.tbl-wrap,table,.table,.tbl){background:#1d1a19!important;color:#eee2dc!important;border-color:#403734!important}
html[data-panel-theme="dark"] body.app :is(#view,#modalRoot) :where(table,.table,.tbl) :is(th,td){border-color:#403734!important}
html[data-panel-theme="dark"] body.app :is(#view,#modalRoot) :where(table,.table,.tbl) th{background:#292320!important;color:#e5d7d0!important}
html[data-panel-theme="dark"] body.app :is(#view,#modalRoot) :where(table,.table,.tbl) td{background:#1d1a19!important;color:#eee2dc!important}
html[data-panel-theme="dark"] body.app :is(#view,#modalRoot) :where(table,.table,.tbl) tr:hover td{background:#282321!important}

html[data-panel-theme="dark"] body.app :is(
  .modal,.modal-box,.modal-card,.drawer,.drawer-card,.mobile-sheet-card,.top-popover,.topbar-popover,.notification-popover,.conversation-popover,
  .r143-quick-shell,.r143-popup-compose,.r143-popup-messages
){
  background:#1b1817!important;
  color:#f3e9e4!important;
  border-color:#443a36!important;
  box-shadow:0 24px 70px rgba(0,0,0,.46)!important;
}
html[data-panel-theme="dark"] body.app :is(.modal-head,.modal-footer,.drawer-head,.mobile-sheet-head){background:#1b1817!important;border-color:#403734!important}

html[data-panel-theme="dark"] body.app :is(#view,#modalRoot,.app-sidebar) :where(.chip,.tab,.tabs button,.segmented button,.filter-chip,.pill,.btn-ghost,.btn-soft,.btn-icon){
  background:#292421!important;
  color:#f3e9e4!important;
  border-color:#51443f!important;
}
html[data-panel-theme="dark"] body.app :is(#view,#modalRoot,.app-sidebar) :where(.chip,.tab,.tabs button,.segmented button,.filter-chip,.pill,.btn-ghost,.btn-soft,.btn-icon):hover{background:#342e2b!important;color:#fff8f4!important}

/* --------------------------------------------------------------------------
   5. Status e avisos: continuam distinguíveis, mas não viram cartões claros.
   -------------------------------------------------------------------------- */
html[data-panel-theme="dark"] body.app :where(.badge-ok,.status-ok,.success,.is-success,.ok-100){background:#1d2a21!important;color:#bfe0c6!important;border-color:#395744!important}
html[data-panel-theme="dark"] body.app :where(.badge-warn,.status-warn,.warning,.is-warning,.warn-100){background:#302718!important;color:#efd8a0!important;border-color:#63532e!important}
html[data-panel-theme="dark"] body.app :where(.badge-danger,.status-danger,.danger,.is-danger,.danger-100,.error){background:#321f1e!important;color:#f3b7b1!important;border-color:#65403d!important}
html[data-panel-theme="dark"] body.app :where(.badge-info,.status-info,.info,.is-info,.info-100){background:#1d2832!important;color:#bdd4e8!important;border-color:#3b5369!important}
html[data-panel-theme="dark"] body.app :where(.badge-neutral,.status-neutral){background:#2c2725!important;color:#e4d8d2!important;border-color:#504541!important}

/* --------------------------------------------------------------------------
   6. Componentes conhecidos que ainda possuíam blocos claros isolados.
   -------------------------------------------------------------------------- */
html[data-panel-theme="dark"] body.app :is(#view,#modalRoot) :where(
  .budget-row.head,.seat,.table-drop,.guest-pool,.guest-pill,.mood-ph,.timeline::before,
  .md-faixa-colab,.md-badge-hoje,.md-banner-hoje,.md-kit-item,.md-planob-item,
  .dd-card,.r147133-lock-grid>div,.bs133-actions>article>span,.bs133-actions>article>strong,.bs133-mini-grid>div,.bs133-forecast,.bs133-shortcuts>button,
  .off134-checks>div,.off134-shortcut,.off134-data>div,
  .be156-day,.be156-ins,.be156-act,.be156-ex button,.be156-styles button,.be157-uso,.be157-uso-pop,.be157-bru-grid>div
){
  background-color:#25201e!important;
  color:#f3e9e4!important;
  border-color:#463c38!important;
}

/* Corrige estilos inline claros comuns gerados por templates antigos. */
html[data-panel-theme="dark"] body.app :is(#view,#modalRoot) [style*="background:#fff" i],
html[data-panel-theme="dark"] body.app :is(#view,#modalRoot) [style*="background: #fff" i],
html[data-panel-theme="dark"] body.app :is(#view,#modalRoot) [style*="background:white" i],
html[data-panel-theme="dark"] body.app :is(#view,#modalRoot) [style*="background: white" i],
html[data-panel-theme="dark"] body.app :is(#view,#modalRoot) [style*="background-color:#fff" i],
html[data-panel-theme="dark"] body.app :is(#view,#modalRoot) [style*="background-color: #fff" i]{
  background:#211d1b!important;
  color:#f3e9e4!important;
  border-color:#463c38!important;
}

/* --------------------------------------------------------------------------
   7. Guardião de contraste em runtime (classes aplicadas por bride-r1471584.js)
   -------------------------------------------------------------------------- */
html[data-panel-theme="dark"] body.app [data-be1584-dark-surface="1"]{
  background:#211d1b!important;
  background-image:linear-gradient(135deg,#24201e,#1b1817)!important;
  color:#f3e9e4!important;
  border-color:#463c38!important;
  box-shadow:none;
}
html[data-panel-theme="dark"] body.app [data-be1584-dark-text="primary"]{color:#fff8f4!important;text-shadow:none!important;opacity:1!important}
html[data-panel-theme="dark"] body.app [data-be1584-dark-text="muted"]{color:#c8bbb4!important;text-shadow:none!important;opacity:1!important}
html[data-panel-theme="dark"] body.app [data-be1584-dark-border="1"]{border-color:#463c38!important}

/* --------------------------------------------------------------------------
   8. Exceções funcionais: estes elementos precisam manter a própria cor/clareza.
   QR branco é necessário para leitura; previews e amostras de cor representam
   conteúdo do usuário e não devem ser adulterados pelo tema do painel.
   -------------------------------------------------------------------------- */
html[data-panel-theme="dark"] body.app :is(
  [data-be-keep-light],.be-keep-light,.qr-code,.qrcode,[class*="qrcode" i],[class*="qr-code" i],
  .barcode,.wallet-code,.color-swatch,.swatch,.palette-swatch,.paleta-cor,.color-preview,
  .theme-preview,.tema-preview,.site-preview,.convite-preview,.paper-preview,.print-preview
){
  color-scheme:light;
}
html[data-panel-theme="dark"] body.app :is(.qr-code,.qrcode,[class*="qrcode" i],[class*="qr-code" i],.barcode,.wallet-code){
  background:#fff!important;
  color:#111!important;
}

/* Raio-X permanece explicitamente legível mesmo após a normalização global. */
html[data-panel-theme="dark"] body.app .be1581-ray-card{background:linear-gradient(135deg,#332725,#251e1d)!important;border-color:#5a4640!important}
html[data-panel-theme="dark"] body.app .be1581-ray-card :is(h3,b,strong){color:#fffaf7!important}
html[data-panel-theme="dark"] body.app .be1581-ray-card :is(p,small,span:not(.badge)){color:#f0dfd8!important;opacity:1!important}

@media(max-width:820px){
  html[data-panel-theme="dark"] body.app .mobile-app-nav{background:rgba(20,18,17,.98)!important;border-color:#4a403b!important}
  html[data-panel-theme="dark"] body.app .app-sidebar{background:linear-gradient(180deg,#171414,#111010)!important}
}
