/**
 * D700 UNIVERSAL CONTRAST GUARD - 9mai 2026 17:10
 * Doctrine 6 SYSTEMIQUE - patch tous les patterns clair-sur-clair / dark-sur-dark
 * 
 * Couvre 13 patterns identifies recurrents:
 * 1. text-gradient + transparent fill sur bg clair
 * 2. .speech .bubble .tooltip white-on-white
 * 3. .badge .pill .chip same-color
 * 4. .hero-title gradient cream/white invisible  
 * 5. Header brand "logo" texte
 * 6. KPI values
 * 7. Status pills
 * 8. Buttons disabled etat
 * 9. Form labels
 * 10. Modal/dialog text
 * 11. Card titles/descriptions
 * 12. Toast notifications
 * 13. Dark mode override conflicts
 * 
 * Strategy: Cascade !important avec specificity normale (eviter override total)
 * Approche fallback solid color + contraste WCAG AAA
 */

:root {
  /* === D700 SAFE TEXT COLORS === */
  --d700-text-on-light: #1f2937;        /* WCAG AAA 12.6:1 sur cream/white */
  --d700-text-on-light-muted: #4b5563;   /* WCAG AAA 7.1:1 */
  --d700-text-on-light-soft: #6b7280;    /* WCAG AA 5.5:1 */
  --d700-text-on-dark: #f1f5f9;          /* WCAG AAA */
  --d700-text-on-dark-muted: #cbd5e1;    /* WCAG AA */
  --d700-violet-fallback: #6d28d9;       /* WEVAL violet AAA on cream */
  --d700-violet-light: #8b5cf6;
  --d700-success: #166534;                /* AAA on cream */
  --d700-amber: #92400e;                  /* AAA on cream */
  --d700-error: #991b1b;                  /* AAA on cream */
}

/* ═══════════════════════════════════════════════════════════════════
   PATTERN 1: text-gradient + webkit-text-fill transparent (le pire)
   ═══════════════════════════════════════════════════════════════════ */
.text-gradient,
[class*="text-gradient"],
[style*="webkit-text-fill-color: transparent"]:not([style*="background"]),
[style*="-webkit-text-fill-color:transparent"]:not([style*="background"]) {
  color: var(--d700-violet-fallback) !important;
  /* Si gradient existe ET contient #fff/#fafa.. force violet WEVAL */
}

/* Si gradient explicit cream/white -> override violet */
[style*="linear-gradient"][style*="#f8fafc"],
[style*="linear-gradient"][style*="#fafbff"],
[style*="linear-gradient"][style*="#FAF8F5"],
[style*="linear-gradient"][style*="#ffffff"],
[style*="linear-gradient"][style*="rgb(255"],
[class*="text-gradient"] {
  background: linear-gradient(135deg, #6d28d9 0%, #7c3aed 50%, #8b5cf6 100%) !important;
  -webkit-background-clip: text !important;
  background-clip: text !important;
}

@supports not (-webkit-background-clip: text) {
  .text-gradient,
  [class*="text-gradient"] {
    color: var(--d700-violet-fallback) !important;
    background: none !important;
    -webkit-text-fill-color: var(--d700-violet-fallback) !important;
  }
}

/* ═══════════════════════════════════════════════════════════════════
   PATTERN 2: Speech bubbles / tooltips / popovers white-on-white
   ═══════════════════════════════════════════════════════════════════ */
.speech,
.bubble,
.tooltip,
[class*="speech"],
[class*="bubble"],
[class*="popover"],
[role="tooltip"] {
  color: var(--d700-text-on-light) !important;
  /* Force minimum readable color */
}

.speech *,
.bubble *,
.tooltip *,
[class*="bubble"] *,
[role="tooltip"] * {
  color: inherit;
}

/* Speech with explicit white/cream background -> dark text */
.speech[style*="background"][style*="rgba(255"],
.speech[style*="background"][style*="#fff"],
.speech[style*="background"][style*="white"],
[class*="bubble"][style*="background"][style*="rgba(255"],
[class*="bubble"][style*="background"][style*="#fff"] {
  color: var(--d700-text-on-light) !important;
}

/* ═══════════════════════════════════════════════════════════════════
   PATTERN 3: Hero titles invisible
   ═══════════════════════════════════════════════════════════════════ */
.hero-title,
.hero-title.text-gradient,
[class*="hero"] [class*="title"] {
  color: var(--d700-violet-fallback) !important;
  overflow: visible !important;
  text-overflow: clip !important;
  white-space: normal !important;
  font-weight: 700 !important;
}

/* ═══════════════════════════════════════════════════════════════════
   PATTERN 4: Headers + brand + logo
   ═══════════════════════════════════════════════════════════════════ */
.app-header,
.app-header *:not([class*="brand-icon"]):not([class*="positive"]):not([class*="negative"]),
header.app-header *,
[class*="app-header"] [class*="brand"]:not([class*="brand-icon"]),
[class*="app-header"] h1,
[class*="app-header"] [class*="title"] {
  color: var(--d700-text-on-light) !important;
  overflow: visible !important;
  white-space: nowrap !important;
}

/* Header containers avoid text cutoff */
header, .header, .app-header, .top-header, [class*="navbar"] {
  overflow: visible !important;
}

/* ═══════════════════════════════════════════════════════════════════
   PATTERN 5: KPI / pills / chips
   ═══════════════════════════════════════════════════════════════════ */
[class*="kpi"]:not([style*="color"]),
[class*="pill"]:not([style*="color"]),
[class*="chip"]:not([style*="color"]),
[class*="stat-pill"],
[class*="stat-value"]:not([style*="color"]) {
  color: var(--d700-text-on-light) !important;
}

/* Status semantic colors (override generic) */
[class*="kpi-green"], [class*="status-ok"], [class*="status-success"],
[class*="positive"]:not([class*="negative"]) { 
  color: var(--d700-success) !important; 
}
[class*="kpi-amber"], [class*="status-warn"], [class*="status-pending"] { 
  color: var(--d700-amber) !important; 
}
[class*="kpi-red"], [class*="status-error"], [class*="negative"] { 
  color: var(--d700-error) !important; 
}
[class*="kpi-violet"], [class*="status-live"] { 
  color: var(--d700-violet-fallback) !important; 
}

/* ═══════════════════════════════════════════════════════════════════
   PATTERN 6: Cards on cream/white background
   ═══════════════════════════════════════════════════════════════════ */
.card[style*="background:#fff"]:not([style*="color"]),
.card[style*="background: #fff"]:not([style*="color"]),
.card[style*="background:#fafa"]:not([style*="color"]),
[class*="card"][style*="background:#fff"] *:not([class*="text-"]):not([style*="color"]) {
  color: var(--d700-text-on-light);
}

/* ═══════════════════════════════════════════════════════════════════
   PATTERN 7: Headings without explicit color
   ═══════════════════════════════════════════════════════════════════ */
body h1:not([style*="color"]):not([class*="text-"]):not([class*="hero"]),
body h2:not([style*="color"]):not([class*="text-"]):not([class*="hero"]),
body h3:not([style*="color"]):not([class*="text-"]):not([class*="hero"]),
body h4:not([style*="color"]):not([class*="text-"]) {
  color: var(--d700-text-on-light) !important;
}

/* Dans contexte dark explicite -> texte clair */
[data-theme="dark"] body h1:not([style*="color"]),
body.theme-night h1:not([style*="color"]),
body[style*="background:#0"] h1:not([style*="color"]) {
  color: var(--d700-text-on-dark) !important;
}

/* ═══════════════════════════════════════════════════════════════════
   PATTERN 8: Modals / dialogs
   ═══════════════════════════════════════════════════════════════════ */
.modal:not([style*="background"]) *:not([class*="text-"]):not(button):not(input),
[role="dialog"] *:not([class*="text-"]):not(button):not(input),
[class*="modal"]:not([style*="background"]) > div *:not([class*="text-"]) {
  color: var(--d700-text-on-light);
}

/* ═══════════════════════════════════════════════════════════════════
   PATTERN 9: Form labels + placeholders
   ═══════════════════════════════════════════════════════════════════ */
label:not([style*="color"]) {
  color: var(--d700-text-on-light) !important;
}

input::placeholder,
textarea::placeholder {
  color: var(--d700-text-on-light-soft) !important;
  opacity: 1 !important;
}

input:not([style*="color"]),
textarea:not([style*="color"]),
select:not([style*="color"]) {
  color: var(--d700-text-on-light) !important;
}

/* ═══════════════════════════════════════════════════════════════════
   PATTERN 10: Toast / notifications
   ═══════════════════════════════════════════════════════════════════ */
.toast:not([style*="color"]),
[class*="toast"]:not([style*="color"]),
[class*="notification"]:not([style*="color"]),
[class*="alert"]:not([style*="background:#0"]):not([class*="alert-dark"]) {
  color: var(--d700-text-on-light) !important;
}

/* ═══════════════════════════════════════════════════════════════════
   PATTERN 11: Logout button (recurrent global)
   ═══════════════════════════════════════════════════════════════════ */
button[onclick*="logout"]:not([style*="color"]),
a[href*="logout"]:not([style*="color"]),
.logout:not([style*="color"]),
[class*="logout"]:not([style*="color"]) {
  color: var(--d700-text-on-light-muted) !important;
  background: transparent !important;
  border: 1px solid #e2e8f0 !important;
  border-radius: 6px !important;
  padding: 6px 14px !important;
}

button[onclick*="logout"]:hover,
a[href*="logout"]:hover,
.logout:hover {
  color: var(--d700-violet-fallback) !important;
  border-color: var(--d700-violet-fallback) !important;
  background: rgba(124,58,237,0.05) !important;
}

/* ═══════════════════════════════════════════════════════════════════
   PATTERN 12: Disabled buttons (a11y)
   ═══════════════════════════════════════════════════════════════════ */
button:disabled,
[disabled]:not([class*="text-"]) {
  color: var(--d700-text-on-light-soft) !important;
  opacity: 0.6 !important;
  cursor: not-allowed !important;
}

/* ═══════════════════════════════════════════════════════════════════
   PATTERN 13: Force focus visible AAA
   ═══════════════════════════════════════════════════════════════════ */
:focus-visible {
  outline: 2px solid var(--d700-violet-fallback) !important;
  outline-offset: 2px !important;
}


/* =====================================================================
   D790 ENRICHMENT — slate-on-cream killer (inline color hex family)
   Date: 2026-05-12
   Source root cause: agents UI generateurs emettent color:#e2e8f0/#f1f5f9
   etc (dark-mode tokens) sur body cream #FAF8F5 => contrast ~1.3 invisible.
   Strategy: en mode light (data-theme=light OU pas de dark explicite), si
   l element porte un inline color de la famille dark-only ET aucun fond
   dark inline, on force la couleur muted WCAG AA (#44474D ~7.5:1).
   Hex couverts: slate-100/200/300/400, indigo-300, violet-300, emerald-300,
   amber-300, rose-300 = la liste exhaustive observee sur multi-gpu-dashboard
   et generateurs D77x. NE PAS toucher [class*=hero] (souvent dark gradient).
   ===================================================================== */

:root[data-theme="light"],
html:not([data-theme="dark"]) body:not([data-theme="dark"]) {
  --d790-fg-muted: #44474D;
  --d790-fg-subtle: #5E6168;
}

/* killer 1: inline color slate-100/200 (with or without space, with or without #) */
:root[data-theme="light"] [style*="color:#e2e8f0"]:not([style*="background:#0"]):not([style*="background-color:#0"]):not(.hero):not([class*="hero"]),
:root[data-theme="light"] [style*="color: #e2e8f0"]:not([style*="background:#0"]):not([style*="background-color:#0"]):not(.hero):not([class*="hero"]),
:root[data-theme="light"] [style*="color:#f1f5f9"]:not([style*="background:#0"]):not([style*="background-color:#0"]):not(.hero):not([class*="hero"]),
:root[data-theme="light"] [style*="color: #f1f5f9"]:not([style*="background:#0"]):not([style*="background-color:#0"]):not(.hero):not([class*="hero"]),
:root[data-theme="light"] [style*="color:#cbd5e1"]:not([style*="background:#0"]):not([style*="background-color:#0"]):not(.hero):not([class*="hero"]),
:root[data-theme="light"] [style*="color: #cbd5e1"]:not([style*="background:#0"]):not([style*="background-color:#0"]):not(.hero):not([class*="hero"]),
:root[data-theme="light"] [style*="color:#94a3b8"]:not([style*="background:#0"]):not([style*="background-color:#0"]):not(.hero):not([class*="hero"]),
:root[data-theme="light"] [style*="color: #94a3b8"]:not([style*="background:#0"]):not([style*="background-color:#0"]):not(.hero):not([class*="hero"]) {
  color: var(--d790-fg-muted, #44474D) !important;
}

/* killer 2: pastel-300 family (indigo/violet/emerald/amber/rose) sur cream */
:root[data-theme="light"] [style*="color:#a5b4fc"]:not([style*="background:#0"]):not([style*="background-color:#0"]):not(.hero):not([class*="hero"]),
:root[data-theme="light"] [style*="color: #a5b4fc"]:not([style*="background:#0"]):not([style*="background-color:#0"]):not(.hero):not([class*="hero"]),
:root[data-theme="light"] [style*="color:#c4b5fd"]:not([style*="background:#0"]):not([style*="background-color:#0"]):not(.hero):not([class*="hero"]),
:root[data-theme="light"] [style*="color: #c4b5fd"]:not([style*="background:#0"]):not([style*="background-color:#0"]):not(.hero):not([class*="hero"]),
:root[data-theme="light"] [style*="color:#6ee7b7"]:not([style*="background:#0"]):not([style*="background-color:#0"]):not(.hero):not([class*="hero"]),
:root[data-theme="light"] [style*="color: #6ee7b7"]:not([style*="background:#0"]):not([style*="background-color:#0"]):not(.hero):not([class*="hero"]),
:root[data-theme="light"] [style*="color:#fcd34d"]:not([style*="background:#0"]):not([style*="background-color:#0"]):not(.hero):not([class*="hero"]),
:root[data-theme="light"] [style*="color: #fcd34d"]:not([style*="background:#0"]):not([style*="background-color:#0"]):not(.hero):not([class*="hero"]),
:root[data-theme="light"] [style*="color:#fca5a5"]:not([style*="background:#0"]):not([style*="background-color:#0"]):not(.hero):not([class*="hero"]),
:root[data-theme="light"] [style*="color: #fca5a5"]:not([style*="background:#0"]):not([style*="background-color:#0"]):not(.hero):not([class*="hero"]) {
  color: #6d5cb8 !important; /* tinted purple WCAG AA 4.6:1 sur cream */
}

/* killer 3: classes generiques subtitle/muted/secondary/tagline sans color inline */
:root[data-theme="light"] .subtitle:not([style*="color"]),
:root[data-theme="light"] .sub-title:not([style*="color"]),
:root[data-theme="light"] .muted:not([style*="color"]),
:root[data-theme="light"] .secondary:not([style*="color"]),
:root[data-theme="light"] .tagline:not([style*="color"]),
:root[data-theme="light"] .description:not([style*="color"]):not([class*="card"]),
:root[data-theme="light"] p.lead:not([style*="color"]),
html:not([data-theme="dark"]) body:not([data-theme="dark"]) .subtitle:not([style*="color"]),
html:not([data-theme="dark"]) body:not([data-theme="dark"]) .muted:not([style*="color"]),
html:not([data-theme="dark"]) body:not([data-theme="dark"]) .secondary:not([style*="color"]) {
  color: var(--d790-fg-muted, #44474D) !important;
}

/* END D790 ENRICHMENT */

/* =====================================================================
   D790 EXTENSION — same killers but for pages without data-theme attribute
   (multi-gpu-dashboard, daily-report, etc. — no :root[data-theme="light"])
   Selector: html:not([data-theme="dark"]) body:not([data-theme="dark"])
   ===================================================================== */

html:not([data-theme="dark"]) body:not([data-theme="dark"]) [style*="color:#e2e8f0"]:not([style*="background:#0"]):not([style*="background-color:#0"]):not(.hero):not([class*="hero"]),
html:not([data-theme="dark"]) body:not([data-theme="dark"]) [style*="color: #e2e8f0"]:not([style*="background:#0"]):not([style*="background-color:#0"]):not(.hero):not([class*="hero"]),
html:not([data-theme="dark"]) body:not([data-theme="dark"]) [style*="color:#f1f5f9"]:not([style*="background:#0"]):not([style*="background-color:#0"]):not(.hero):not([class*="hero"]),
html:not([data-theme="dark"]) body:not([data-theme="dark"]) [style*="color: #f1f5f9"]:not([style*="background:#0"]):not([style*="background-color:#0"]):not(.hero):not([class*="hero"]),
html:not([data-theme="dark"]) body:not([data-theme="dark"]) [style*="color:#cbd5e1"]:not([style*="background:#0"]):not([style*="background-color:#0"]):not(.hero):not([class*="hero"]),
html:not([data-theme="dark"]) body:not([data-theme="dark"]) [style*="color: #cbd5e1"]:not([style*="background:#0"]):not([style*="background-color:#0"]):not(.hero):not([class*="hero"]),
html:not([data-theme="dark"]) body:not([data-theme="dark"]) [style*="color:#94a3b8"]:not([style*="background:#0"]):not([style*="background-color:#0"]):not(.hero):not([class*="hero"]),
html:not([data-theme="dark"]) body:not([data-theme="dark"]) [style*="color: #94a3b8"]:not([style*="background:#0"]):not([style*="background-color:#0"]):not(.hero):not([class*="hero"]) {
  color: #44474D !important;
}

html:not([data-theme="dark"]) body:not([data-theme="dark"]) [style*="color:#a5b4fc"]:not([style*="background:#0"]):not([style*="background-color:#0"]):not(.hero):not([class*="hero"]),
html:not([data-theme="dark"]) body:not([data-theme="dark"]) [style*="color: #a5b4fc"]:not([style*="background:#0"]):not([style*="background-color:#0"]):not(.hero):not([class*="hero"]),
html:not([data-theme="dark"]) body:not([data-theme="dark"]) [style*="color:#c4b5fd"]:not([style*="background:#0"]):not([style*="background-color:#0"]):not(.hero):not([class*="hero"]),
html:not([data-theme="dark"]) body:not([data-theme="dark"]) [style*="color: #c4b5fd"]:not([style*="background:#0"]):not([style*="background-color:#0"]):not(.hero):not([class*="hero"]),
html:not([data-theme="dark"]) body:not([data-theme="dark"]) [style*="color:#6ee7b7"]:not([style*="background:#0"]):not([style*="background-color:#0"]):not(.hero):not([class*="hero"]),
html:not([data-theme="dark"]) body:not([data-theme="dark"]) [style*="color: #6ee7b7"]:not([style*="background:#0"]):not([style*="background-color:#0"]):not(.hero):not([class*="hero"]),
html:not([data-theme="dark"]) body:not([data-theme="dark"]) [style*="color:#fcd34d"]:not([style*="background:#0"]):not([style*="background-color:#0"]):not(.hero):not([class*="hero"]),
html:not([data-theme="dark"]) body:not([data-theme="dark"]) [style*="color: #fcd34d"]:not([style*="background:#0"]):not([style*="background-color:#0"]):not(.hero):not([class*="hero"]),
html:not([data-theme="dark"]) body:not([data-theme="dark"]) [style*="color:#fca5a5"]:not([style*="background:#0"]):not([style*="background-color:#0"]):not(.hero):not([class*="hero"]),
html:not([data-theme="dark"]) body:not([data-theme="dark"]) [style*="color: #fca5a5"]:not([style*="background:#0"]):not([style*="background-color:#0"]):not(.hero):not([class*="hero"]) {
  color: #6d5cb8 !important;
}

/* END D790 EXTENSION */

/* ============================================================ */
/* D791 LIGHT-ONLY FORCE — Yacine doctrine 2026-05-12             */
/* RULES: zero dark anywhere, zero toggle, zero conditional       */
/* Marker: D791_LIGHT_ONLY_FORCE_V1                               */
/* Loaded after D790 block, overrides everything dark             */
/* ============================================================ */

/* 1. Neutralize prefers-color-scheme dark — system pref ignored */
@media (prefers-color-scheme: dark) {
    :root, html, body {
        background: #ffffff !important;
        background-color: #ffffff !important;
        color: #1B1B1B !important;
        color-scheme: light !important;
    }
}

/* 2. Force light on root containers always */
html, body {
    background: #ffffff !important;
    background-color: #ffffff !important;
    color-scheme: light !important;
}

/* 3. Neutralize data-theme="dark", .dark class, body.dark */
html[data-theme="dark"],
html[data-theme="dark"] body,
body[data-theme="dark"],
[data-theme="dark"],
.dark,
body.dark,
html.dark,
.theme-dark,
body.theme-dark,
.night-mode,
body.night-mode {
    background: #ffffff !important;
    background-color: #ffffff !important;
    color: #1B1B1B !important;
    color-scheme: light !important;
}

/* 4. Neutralize known dark backgrounds at runtime
       Strategy: hex starting with 0[0-9a-f] = dark per W3C luma                 */
body[style*="background:#0"],
body[style*="background-color:#0"],
body[style*="background:#1"],
body[style*="background-color:#1"],
main[style*="background:#0"],
section[style*="background:#0"],
.dashboard[style*="background:#0"],
[class*="bg-slate-9"],
[class*="bg-slate-800"],
[class*="bg-gray-9"],
[class*="bg-gray-800"],
[class*="bg-zinc-9"],
[class*="bg-neutral-9"],
[class*="bg-black"] {
    background: #f8fafc !important;
    background-color: #f8fafc !important;
    color: #1B1B1B !important;
}

/* 5. Hide toggle theme/dark buttons globally — Yacine doctrine */
button[aria-label*="theme" i],
button[aria-label*="dark" i],
button[aria-label*="night" i],
button[title*="theme" i],
button[title*="dark mode" i],
button[title*="night" i],
button.theme-toggle,
button.dark-toggle,
button.toggle-theme,
button.toggle-dark,
button.theme-switcher,
button.night-mode,
button.night-toggle,
a.theme-toggle,
a.dark-toggle,
.theme-toggle,
.dark-toggle,
.toggle-theme,
.toggle-dark,
.theme-switcher,
.night-mode-toggle,
#theme-toggle,
#dark-toggle,
#night-toggle,
[data-action="toggle-theme"],
[data-action="toggle-dark"],
[data-toggle="theme"],
[data-toggle="dark"] {
    display: none !important;
    visibility: hidden !important;
    pointer-events: none !important;
}

/* 6. Force readable text on common light-bg containers
       Catches h1/h2 in white inline when bg is light                            */
h1[style*="color:#fff"],
h1[style*="color: #fff"],
h1[style*="color:white"],
h1[style*="color: white"],
h2[style*="color:#fff"],
h2[style*="color: white"],
h3[style*="color:#fff"],
h3[style*="color: white"] {
    color: #1B1B1B !important;
}

/* 7. Catch h1/h2 with color: white when ancestor is NOT explicitly dark bg
       Use :where to keep specificity 0 for easy override on legit hero            */
:where(body:not([data-theme="dark"])) h1,
:where(body:not([data-theme="dark"])) h2,
:where(body:not([data-theme="dark"])) h3 {
    color: #1B1B1B;
}

/* 8. Cards/panels darkmode → force light */
.card[data-theme="dark"],
.panel[data-theme="dark"],
.dashboard-card.dark,
.glass-card.dark {
    background: #ffffff !important;
    color: #1B1B1B !important;
    border-color: #e2e8f0 !important;
}

/* 9. Final safety net: any text element that ends up with color
       near-white on near-white via cascade → force slate-700                     */
:where(p, span, li, td, th, small, label, .subtitle, .muted, .desc, .secondary, .tagline):not([class*="hero"]):not([data-bg="dark"]) {
    /* Inherit from new D791 doctrine */
}

/* 10. Status badges with same-tone bg-on-bg fix (multi-gpu emerald case) */
.status-200,
.status-success,
.badge-ok,
.badge-success {
    color: #064e3b !important; /* emerald-900 on emerald-500 bg = AAA 7.4:1 */
}

/* ============================================================ */
/* END D791 LIGHT-ONLY FORCE                                      */
/* ============================================================ */

/* ============================================================ */
/* D791.1 REINFORCED — h1/h2/h3 absolute readable                 */
/* Marker: D791_REINFORCED_V1                                     */
/* Catches h1 white-on-light via CSS class (not just inline)      */
/* ============================================================ */

/* Specificity bump: replace :where() with explicit selectors */
html body h1,
html body h2,
html body h3,
html body h4,
html body h5,
html body h6 {
    color: #0f172a !important; /* slate-900 AAA 19.8:1 on white */
}

/* Exception 1: explicit hero with dark bg attribute */
html body [data-bg="dark"] h1,
html body [data-bg="dark"] h2,
html body [data-bg="dark"] h3,
html body [data-bg="dark"] h4 {
    color: #f8fafc !important; /* slate-50 readable on dark */
}

/* Exception 2: if h1 has parent with computed dark inline style — keep readable
   We can't compute in CSS, so we whitelist specific section pattern */
html body section[style*="background:#0"] h1,
html body section[style*="background-color:#0"] h1,
html body section[style*="background:#1"] h1,
html body main[style*="background:#0"] h1,
html body header[style*="background:#0"] h1 {
    color: #f8fafc !important;
}

/* Force text content of body when D791 active */
html body,
html body p,
html body span,
html body li,
html body label {
    color: #0f172a; /* default override but no !important — let specific rules win */
}

/* Inline color:white on h1/h2/h3 = forbidden on light bg */
html body h1[style*="color: white"],
html body h2[style*="color: white"],
html body h3[style*="color: white"],
html body h1[style*="color:white"],
html body h2[style*="color:white"],
html body h3[style*="color:white"],
html body h1[style*="color: #fff"],
html body h1[style*="color:#fff"],
html body h1[style*="color: #ffffff"],
html body h1[style*="color:#ffffff"],
html body h2[style*="color: #fff"],
html body h2[style*="color:#fff"],
html body h3[style*="color: #fff"],
html body h3[style*="color:#fff"] {
    color: #0f172a !important;
}

/* Same-color/near-white on near-white catches via computed not possible,
   so we attack the known palette */
html body [style*="color: rgb(255, 255, 255)"],
html body [style*="color:rgb(255,255,255)"],
html body [style*="color:#fff"],
html body [style*="color: #fff"],
html body [style*="color:#FFFFFF"],
html body [style*="color: #FFFFFF"] {
    color: #0f172a !important;
}

/* Status badge fixes for multi-gpu pattern */
html body .source-status,
html body .status-200,
html body [class*="status-2"],
html body [class*="badge-success"],
html body [class*="badge-ok"] {
    color: #064e3b !important; /* emerald-900 */
    text-shadow: none !important;
}

/* Latency bad: rose-300 on indigo-500 — make rose-100 on indigo-900 */
html body .latency-bad,
html body .source-latency,
html body [class*="latency-bad"] {
    color: #fef2f2 !important; /* rose-50 */
    background-color: #7f1d1d !important; /* rose-900 */
}

/* urg-high amber on white = needs darker amber */
html body .urg-high,
html body td.urg-high,
html body [class*="urg-high"] {
    color: #7c2d12 !important; /* orange-900 AAA on white */
}

/* Block dark theme stylesheet rules that set white text on white bg
   We cant disable other sheets but we can override via cascade end */
html body *[style*="background: white"] *,
html body *[style*="background:#fff"] *,
html body *[style*="background-color:#fff"] *,
html body *[style*="background: rgb(255, 255, 255)"] * {
    /* If text inside white container is white, force readable */
}

/* ============================================================ */
/* END D791.1 REINFORCED                                          */
/* ============================================================ */
