/* SGP432D Compare PRO: centralized foreground/background contrast layer.
   Applies to live, archive, paito, heatmap, analysis, tools and compare tables.
   Intentionally preserves user-painted paito cells and result number cards. */
body:not(.light){--sgp-cell:#14263c;--sgp-cell-alt:#1b3049;--sgp-head:#234567;--sgp-ink:#f5f9ff;--sgp-sub:#d4e3f3;--sgp-grid:#55708d}
body.light{--sgp-cell:#ffffff;--sgp-cell-alt:#edf3fa;--sgp-head:#dce9f7;--sgp-ink:#15283f;--sgp-sub:#334d68;--sgp-grid:#a8bdd2}
/* Unpainted table surfaces: dark backgrounds get bright numbers and vice versa. */
body:not(.light) .panel table:not(.cmp-table) th,
body:not(.light) .ana-table th,
body:not(.light) .sgptbl th,body:not(.light) .sgpheat th,
body:not(.light) .mini-heatmap-table th{background:var(--sgp-head)!important;color:var(--sgp-ink)!important;border-color:var(--sgp-grid)!important}
body.light .panel table:not(.cmp-table) th,
body.light .ana-table th,
body.light .sgptbl th,body.light .sgpheat th,
body.light .mini-heatmap-table th{background:var(--sgp-head)!important;color:var(--sgp-ink)!important;border-color:var(--sgp-grid)!important}
body:not(.light) .panel table:not(.cmp-table) td:not([style*="background"]):not(.manual-colored),
body:not(.light) .ana-table td,body:not(.light) .sgptbl td,
body:not(.light) .sgpheat td:not([style*="background"]):not(.manual-colored),
body:not(.light) .mini-heatmap-table td:not([style*="background"]):not(.manual-colored){background:var(--sgp-cell)!important;color:var(--sgp-ink)!important;border-color:var(--sgp-grid)!important}
body.light .panel table:not(.cmp-table) td:not([style*="background"]):not(.manual-colored),
body.light .ana-table td,body.light .sgptbl td,
body.light .sgpheat td:not([style*="background"]):not(.manual-colored),
body.light .mini-heatmap-table td:not([style*="background"]):not(.manual-colored){background:var(--sgp-cell)!important;color:var(--sgp-ink)!important;border-color:var(--sgp-grid)!important}
body:not(.light) .panel table:not(.cmp-table) td:not([style*="background"]):not(.manual-colored) :is(span,strong,b,small,a),
body:not(.light) .sgptbl td :is(span,strong,b,small),
body:not(.light) .ana-table td :is(span,strong,b,small){color:var(--sgp-ink)!important}
body.light .panel table:not(.cmp-table) td:not([style*="background"]):not(.manual-colored) :is(span,strong,b,small,a),
body.light .sgptbl td :is(span,strong,b,small),
body.light .ana-table td :is(span,strong,b,small){color:var(--sgp-ink)!important}
/* Keep manual paito digit backgrounds and select foreground for readability. */
body .paitodigit:not(.manual-colored){background:#fff!important;color:#111827!important;-webkit-text-fill-color:#111827!important}
body .paitodigit.manual-colored{color:#111827!important;-webkit-text-fill-color:#111827!important;text-shadow:0 0 2px #fff,0 0 5px #fff!important}
/* Dark mode must follow the actual site toggle, not OS preference. */
body:not(.light) .cmp{--cmp-surface:#172438;--cmp-line:#526681;color:#edf3fb}
body:not(.light) .cmp :is(.cmp-panel,.cmp-field,.cmp-periods fieldset,.cmp-metrics>div){background:#172438;color:#edf3fb;border-color:#526681}
body:not(.light) .cmp :is(h1,h2,h3,.cmp-metrics strong,.cmp-barrow>b){color:#f5f9ff}
body:not(.light) .cmp :is(p,label,small,.cmp-note,.cmp-legend,.cmp-empty,.cmp-actions span,.cmp-periods fieldset>span){color:#d2e0f1}
body:not(.light) .cmp :is(input,select){background:#20354f!important;color:#fff!important;border-color:#7186a0!important}
body:not(.light) .cmp-panel :is(td,th){background:#172438!important;color:#f5f9ff!important;border-color:#526681!important}
body:not(.light) .cmp-panel thead th{background:#29425f!important}
body:not(.light) .cmp-panel .cmp-positive{color:#8af0be!important}
body:not(.light) .cmp-panel .cmp-negative{color:#ffb5a6!important}
body.light .cmp{--cmp-surface:#fff;--cmp-line:#b8c9dc;color:#17283d}
body.light .cmp :is(.cmp-panel,.cmp-field,.cmp-periods fieldset,.cmp-metrics>div){background:#fff;color:#17283d;border-color:#b8c9dc}
body.light .cmp-panel :is(td,th){background:#fff!important;color:#17283d!important;border-color:#cbd5e1!important}
body.light .cmp-panel thead th{background:#e9f1fa!important;color:#213d5b!important}
body.light .cmp :is(input,select){background:#fff!important;color:#17283d!important}
body.light .cmp-panel .cmp-positive{color:#086344!important}
body.light .cmp-panel .cmp-negative{color:#a8321b!important}
/* Historical analysis cards and tools follow theme instead of hardcoded dark. */
body.light .ana-panel{background:#fff!important;color:#17283d!important}
body.light .ana-panel :is(h1,h2,h3,p,label){color:#17283d!important}
body.light .ana-panel :is(.ana-filters,.ana-search){background:#f0f5fb!important;color:#17283d!important;border-color:#b8c9dc!important}
body.light .ana-panel :is(.ana-stats>div,.ana-formula){background:#eaf3ff!important;color:#17283d!important;border-color:#bfd5ef!important}
body.light .ana-panel .ana-stats :is(small,strong){color:#173e72!important}
body.light .sgptools{color:#17283d!important}
body.light .sgptools :is(h1,h2,h3,p,label,span,strong){color:#17283d}
body.light .sgpstat{background:#eef4fb!important;color:#17283d!important;border-color:#a9bfd7!important}
body.light .sgpalert{background:#fff3d6!important;color:#513600!important}
body.light .mini-heatmap-panel,body.light .mini-heatmap-panel .sectionhead h2{color:#17283d!important}
body.light .mini-heatmap-panel :is(.sectionhead p,.mini-heatmap-caption){color:#334d68!important}
body.light .sgpheat td strong,body.light .mini-heatmap-table td strong{color:inherit;text-shadow:none}
/* Buttons and fixed dark result cards retain a contrasting white foreground. */
body .panel.result .balls span,body .panel.result .resultsub strong{color:#fff!important;-webkit-text-fill-color:#fff!important}
body.light .archive-pagination a,body:not(.light) .archive-pagination a{color:#fff!important}
