/* Dark Flow Futures — CRM theme integrity guard v2
   Final dark-mode-only visual guard. Loaded after all CRM/Mission Control styles.
   Goal: no white/light legacy surface may leak into dark mode.
   Light mode remains untouched. Trading/execution logic is not affected. */

html[data-df-theme="dark"]{
  --df-dark-bg:#06080d;
  --df-dark-panel:#0d141d;
  --df-dark-panel-2:#101720;
  --df-dark-panel-3:#141c26;
  --df-dark-line:rgba(148,163,184,.15);
  --df-dark-line-soft:rgba(148,163,184,.09);
  --df-dark-text:#e7ecf3;
  --df-dark-strong:#f7f9fc;
  --df-dark-muted:#8f9caf;
  --df-dark-good:#73d7ab;
  --df-dark-warn:#dfbd76;
  --df-dark-bad:#ef96a0;
  --df-dark-info:#91b4f4;
}

/* Admin / Brain Controls: eliminate every hard-coded light-era container. */
html[data-df-theme="dark"] #engineControlCard,
html[data-df-theme="dark"] .admin-nav,
html[data-df-theme="dark"] .control-field,
html[data-df-theme="dark"] .series-control-card,
html[data-df-theme="dark"] .admin-stat,
html[data-df-theme="dark"] .account-admin-card,
html[data-df-theme="dark"] .account-admin-icon,
html[data-df-theme="dark"] .admin-safety-note{
  background:linear-gradient(180deg,#0f151d,#0a0f16)!important;
  border-color:var(--df-dark-line)!important;
  color:var(--df-dark-text)!important;
  box-shadow:none!important;
}

html[data-df-theme="dark"] .admin-nav-btn{
  color:#a7b3c3!important;
  background:transparent!important;
}
html[data-df-theme="dark"] .admin-nav-btn:hover{
  background:rgba(101,146,232,.055)!important;
  color:var(--df-dark-strong)!important;
}
html[data-df-theme="dark"] .admin-nav-btn.active{
  background:#142033!important;
  color:var(--df-dark-strong)!important;
  box-shadow:inset 0 0 0 1px rgba(101,146,232,.22)!important;
}

html[data-df-theme="dark"] .control-security{
  border-top-color:var(--df-dark-line)!important;
}
html[data-df-theme="dark"] .admin-section-heading p,
html[data-df-theme="dark"] .control-field small,
html[data-df-theme="dark"] .strategy-card small,
html[data-df-theme="dark"] .series-control-head small,
html[data-df-theme="dark"] .admin-stat span,
html[data-df-theme="dark"] .admin-stat small,
html[data-df-theme="dark"] .account-admin-card p{
  color:var(--df-dark-muted)!important;
}
html[data-df-theme="dark"] .admin-stat strong,
html[data-df-theme="dark"] .account-admin-card strong,
html[data-df-theme="dark"] .account-admin-icon{
  color:var(--df-dark-strong)!important;
}

/* Engine card is generated by JS with inline light colors; explicitly neutralize them. */
html[data-df-theme="dark"] #engineControlCard[style],
html[data-df-theme="dark"] #engineControlCard [style*="color:#0f172a"],
html[data-df-theme="dark"] #engineControlCard [style*="color:#334155"]{
  color:var(--df-dark-strong)!important;
}
html[data-df-theme="dark"] #engineControlCard [style*="color:#64748b"],
html[data-df-theme="dark"] #engineControlCard [style*="color:#475569"]{
  color:var(--df-dark-muted)!important;
}
html[data-df-theme="dark"] #engineControlCard strong[style*="color:#166534"]{color:var(--df-dark-good)!important}
html[data-df-theme="dark"] #engineControlCard strong[style*="color:#991b1b"]{color:var(--df-dark-bad)!important}

/* Inputs/selects/code remain dark even when legacy component CSS tries to brighten them. */
html[data-df-theme="dark"] input,
html[data-df-theme="dark"] select,
html[data-df-theme="dark"] textarea,
html[data-df-theme="dark"] pre,
html[data-df-theme="dark"] code{
  background:#090e14!important;
  color:var(--df-dark-strong)!important;
  border-color:#263446!important;
}
html[data-df-theme="dark"] select{color-scheme:dark!important}

/* Generic legacy light-surface guard for dynamically emitted CRM blocks. */
html[data-df-theme="dark"] .tab div[style*="background:#fff"],
html[data-df-theme="dark"] .tab div[style*="background: #fff"],
html[data-df-theme="dark"] .tab div[style*="background:#ffffff"],
html[data-df-theme="dark"] .tab div[style*="background: #ffffff"],
html[data-df-theme="dark"] .tab div[style*="background:#f8fafc"],
html[data-df-theme="dark"] .tab div[style*="background: #f8fafc"],
html[data-df-theme="dark"] .tab div[style*="background:#f9fafb"],
html[data-df-theme="dark"] .tab div[style*="background:#f1f5f9"],
html[data-df-theme="dark"] .tab section[style*="background:#fff"],
html[data-df-theme="dark"] .tab section[style*="background:#f8fafc"],
html[data-df-theme="dark"] .tab article[style*="background:#fff"],
html[data-df-theme="dark"] .tab article[style*="background:#f8fafc"]{
  background:var(--df-dark-panel)!important;
  color:var(--df-dark-text)!important;
  border-color:var(--df-dark-line)!important;
}

/* CSS-class surfaces that historically used #fff/#f8fafc. */
html[data-df-theme="dark"] .panel,
html[data-df-theme="dark"] .card,
html[data-df-theme="dark"] .form-panel,
html[data-df-theme="dark"] .firm-section,
html[data-df-theme="dark"] .broker-card,
html[data-df-theme="dark"] .strategy-route-panel,
html[data-df-theme="dark"] .strategy-route-card,
html[data-df-theme="dark"] .strategy-broker-card,
html[data-df-theme="dark"] .strategy-series-card,
html[data-df-theme="dark"] .ej-health-panel,
html[data-df-theme="dark"] .ej-comparison-panel,
html[data-df-theme="dark"] .ej-errors-panel,
html[data-df-theme="dark"] .ej-cycle-panel{
  background:linear-gradient(180deg,rgba(15,21,29,.97),rgba(10,15,22,.97))!important;
  border-color:var(--df-dark-line)!important;
  color:var(--df-dark-text)!important;
}

/* Tables must never render a bright sheet in dark mode. */
html[data-df-theme="dark"] table,
html[data-df-theme="dark"] .data-table-wrap,
html[data-df-theme="dark"] .account-table-wrap,
html[data-df-theme="dark"] .ej-table-wrap,
html[data-df-theme="dark"] .ej-cycle-table-wrap{
  background:#090e14!important;
  color:var(--df-dark-text)!important;
  border-color:var(--df-dark-line)!important;
}
html[data-df-theme="dark"] table thead,
html[data-df-theme="dark"] table thead tr,
html[data-df-theme="dark"] table thead th{
  background:#101720!important;
  color:#aab6c6!important;
  border-color:var(--df-dark-line-soft)!important;
}
html[data-df-theme="dark"] table tbody,
html[data-df-theme="dark"] table tbody tr,
html[data-df-theme="dark"] table tbody td{
  background:#0a1017!important;
  color:#c9d3df!important;
  border-color:var(--df-dark-line-soft)!important;
}

/* Status chips retain meaning but use dark translucent fills instead of pale blocks. */
html[data-df-theme="dark"] .control-chip{background:#141c26!important;color:#b8c4d3!important}
html[data-df-theme="dark"] .control-chip.safe{background:rgba(63,199,139,.10)!important;color:var(--df-dark-good)!important}
html[data-df-theme="dark"] .control-chip.warn{background:rgba(213,166,78,.10)!important;color:var(--df-dark-warn)!important}
html[data-df-theme="dark"] .admin-safety-note{color:var(--df-dark-info)!important}

/* Dark mode means dark: prevent browser/default canvas flashes on the CRM shell. */
html[data-df-theme="dark"],
html[data-df-theme="dark"] body,
html[data-df-theme="dark"] main,
html[data-df-theme="dark"] .tab{
  background-color:var(--df-dark-bg)!important;
  color:var(--df-dark-text)!important;
}
