/* PML V101 - Theme contrast repair. Loaded on every page; no forced theme.
   All rules follow html[data-theme] so the existing toggle updates in place. */
html[data-theme="light"] body.admin-page {
  --pml-v101-ink:#192c46;
  --pml-v101-subtle:#445b75;
  --pml-v101-line:#ccd9e9;
  --pml-v101-card:#fff;
  --pml-v101-soft:#f1f5fb;
}
html[data-theme="dark"] body.admin-page {
  --pml-v101-ink:#edf4ff;
  --pml-v101-subtle:#b2c5df;
  --pml-v101-line:#334865;
  --pml-v101-card:#111f34;
  --pml-v101-soft:#1b2a42;
}
/* Global form focus/disabled affordance: readable in both modes. */
html[data-theme="light"] body.admin-page .card h1,
html[data-theme="light"] body.admin-page .card h2,
html[data-theme="light"] body.admin-page .card h3,
html[data-theme="light"] body.admin-page .page-head h1,
html[data-theme="light"] body.admin-page .pml-v98-batch h1,
html[data-theme="light"] body.admin-page .pml-v98-batch h2 {
 color:var(--pml-v101-ink);
}
html[data-theme="light"] body.admin-page :is(.card,.rw-page,.pml-v98-batch) :is(input,select,textarea):not([type=checkbox]):not([type=radio]) {
 color:#1b304b;background-color:#fff;border-color:#b6c8dd;
}
html[data-theme="dark"] body.admin-page :is(.card,.rw-page,.pml-v98-batch) :is(input,select,textarea):not([type=checkbox]):not([type=radio]) {
 color:#f4f8ff;
}
html[data-theme="light"] body.admin-page :is(input,select,textarea):focus-visible {
 outline:2px solid #4479d7;outline-offset:2px;
}
html[data-theme="light"] body.admin-page :is(.btn,button):disabled {opacity:.55;cursor:not-allowed}
/* Theme.css historically changed primary buttons to dark foreground, breaking
   blue action buttons in light mode. Keep white on filled controls. */
html[data-theme="light"] body.admin-page .btn:not(.secondary):not(.ghost):not(.amber):not(.outline):not(.link) {
 color:#fff;
}
html[data-theme="light"] body.admin-page .btn.secondary,
html[data-theme="light"] body.admin-page .btn.ghost {color:#243c5a}
/* V98: global Stage 1 setup is intentionally one large light card. Its old
   labels were white on white/grey and therefore effectively invisible. */
html[data-theme="light"] body.admin-page .pml-v98-batch {
 background:linear-gradient(145deg,#fff,#f5f8fd) !important;
 border-color:#b7c9e2;
 color:#19314e;
}
html[data-theme="light"] body.admin-page .pml-v98-batch :is(.eyebrow,h2,h3,strong) {color:#1a3150}
html[data-theme="light"] body.admin-page .pml-v98-batch p,
html[data-theme="light"] body.admin-page .pml-v98-note,
html[data-theme="light"] body.admin-page .pml-v98-form .cc-builder-footer>div span {color:#405b7b}
html[data-theme="light"] body.admin-page .pml-v98-metrics>div {
 background:#eaf1fc !important;
 border-color:#c4d4e9;
 box-shadow:none;
}
html[data-theme="light"] body.admin-page .pml-v98-metrics small {color:#405b79 !important}
html[data-theme="light"] body.admin-page .pml-v98-metrics strong {color:#172d4e !important}
html[data-theme="light"] body.admin-page .pml-v98-table-wrap {border-color:#c3d1e5;background:#fff}
html[data-theme="light"] body.admin-page .pml-v98-table th {
 background:#e5eef9 !important;color:#2a486f !important;
 border-bottom:1px solid #bfd0e6;
}
html[data-theme="light"] body.admin-page .pml-v98-table td {
 background:#fff;color:#273b57 !important;border-color:#d9e2ee;
}
html[data-theme="light"] body.admin-page .pml-v98-table tbody tr:nth-child(even) td {background:#f5f8fc}
html[data-theme="light"] body.admin-page .pml-v98-table td:first-child {font-weight:800}
html[data-theme="light"] body.admin-page .pml-v98-state.ready {
 color:#096846 !important;background:#d9f4e8;border-color:#81caae;
}
html[data-theme="light"] body.admin-page .pml-v98-state.done {
 color:#1d4e98 !important;background:#e1edff;border-color:#a7c6f1;
}
html[data-theme="light"] body.admin-page .pml-v98-state.pending {
 color:#81540b !important;background:#fff2db;border-color:#e3c98f;
}
html[data-theme="light"] body.admin-page .pml-v98-complete {
 color:#146244;background:#e4f7ec;border-color:#95d1b3;
}
html[data-theme="dark"] body.admin-page .pml-v98-table td {color:#edf4ff}
html[data-theme="dark"] body.admin-page .pml-v98-table th {color:#c1d9ff}
html[data-theme="dark"] body.admin-page .pml-v98-metrics strong {color:#fff}
/* No-stage / cancelled-stage workflow: retains visual hierarchy without
   pale-on-white titles in LIGHT or dark-on-dark in DARK. */
html[data-theme="light"] body.admin-page .rw-v96-onboarding {
 background:radial-gradient(ellipse at 50% 0,rgba(42,118,210,.11),transparent 55%),linear-gradient(135deg,#fff,#edf4fd 75%) !important;
 border-color:#a7c2e7;box-shadow:0 15px 35px rgba(30,64,111,.08);
}
html[data-theme="light"] body.admin-page .rw-v96-onboarding :is(h1,h2,h3) {color:#18314f !important}
html[data-theme="light"] body.admin-page .rw-v96-onboarding p {color:#425f80 !important}
html[data-theme="light"] body.admin-page .rw-v96-step {color:#23539a}
html[data-theme="light"] body.admin-page .rw-v96-onboarding-note {color:#49627c}
html[data-theme="light"] body.admin-page .rw-v96-onboarding-icon {
 background:#e0edff;color:#2453a3;border-color:#acc6e8;
}
html[data-theme="light"] body.admin-page .rw-v96-onboarding-note span {color:#08704c}
/* Migration, active-race warnings and emergency messages. */
html[data-theme="light"] body.admin-page .pml-v94-migration {
 background:linear-gradient(120deg,#fff4df,#f7faff) !important;
 color:#263952;border-color:#d8a85d;
}
html[data-theme="light"] body.admin-page .pml-v94-migration .eyebrow {color:#8b570f}
html[data-theme="light"] body.admin-page .pml-v94-migration p {color:#40546f}
html[data-theme="light"] body.admin-page .rw-result-locked {
 background:#fff1da;color:#624014;border-color:#d5ad67;
}
html[data-theme="light"] body.admin-page .rw-result-locked strong {color:#51300b}
/* The race workspace has its own paired token variables. Keep custom statuses
   readable and avoid inheriting the dark-theme background from legacy styles. */
html[data-theme="light"] body.admin-page .rw-page {
 --rw-bg:#fff;--rw-surface:#f6f9ff;--rw-soft:#e7eef8;
 --rw-line:#c5d4e8;--rw-text:#192d47;--rw-muted:#48617d;
 --rw-accent:#2057ad;--rw-tint:#e5eefc;
}
html[data-theme="dark"] body.admin-page .rw-page {
 --rw-bg:#0d1421;--rw-surface:#121d2d;--rw-soft:#19263a;
 --rw-line:#30425c;--rw-text:#eef5ff;--rw-muted:#b4c5df;
 --rw-accent:#86b4ff;--rw-tint:#1b3153;
}
html[data-theme="light"] body.admin-page .rw-page :is(.rw-draw,.rw-desk,.rw-commandbar,.rw-track-note) {
 color:var(--rw-text);border-color:var(--rw-line);
}
/* Sponsor and sync sections use smaller copy; ensure secondary text stays legible. */
html[data-theme="light"] body.admin-page :is(.pml-logo-sync-diagnostics,.selected-source,.mapping-grid,.pmlq-sort-help) {color:#3c5572}
html[data-theme="light"] body.admin-page .pml-logo-sync-diagnostics small {color:#405c7c}
/* Public category presentation deliberately retains navy cards in BOTH modes:
   do not apply the white-page text palette to this TV-specific overlay. */
html[data-theme="light"] body.public-page #pbdRoot .pml-v92-category-scene :is(h1,h2,strong) {
 color:#fff;
}
html[data-theme="dark"] body.public-page #pbdRoot .pml-v92-category-scene :is(h1,h2,strong) {
 color:#fff;
}
@media (max-width:700px) {
 html[data-theme="light"] body.admin-page .pml-v98-metrics {grid-template-columns:repeat(2,minmax(0,1fr))}
 html[data-theme="light"] body.admin-page .pml-v98-table td {padding:10px 9px}
}
/* Sponsor management: the V96 repair card had a forced navy gradient even
   when the site was light. Use a surface/text pair, not background inversion. */
html[data-theme="light"] body.admin-page .pml-v96-sponsor-files {
 background:linear-gradient(120deg,#fff,#eef5ff) !important;
 border-color:#afc9e6 !important;color:#203954;
}
html[data-theme="light"] body.admin-page .pml-v96-sponsor-files :is(h2,p,strong) {color:#1a3150}
html[data-theme="light"] body.admin-page .pml-v96-sponsor-files small {color:#485f7a}
html[data-theme="light"] body.admin-page .pml-v96-sponsor-recoverable {color:#875409 !important}
html[data-theme="light"] body.admin-page .pml-v96-sponsor-ok {color:#116747 !important}
html[data-theme="light"] body.admin-page .pml-v96-sponsor-path {color:#4b6483 !important}
html[data-theme="light"] body.admin-page .pml-v93-empty-state {
 background:#edf6ff;border-color:#91b8db;color:#214c6e;
}
html[data-theme="light"] body.admin-page .pml-v93-empty-state :is(strong,span) {color:#214c6e}
/* Non-destructive status/table surface corrections across Racers, Categories,
   Dashboard, Standings, Season/LEG, and Monday Sync. */
html[data-theme="light"] body.admin-page :is(.modal-card,.detect-field,.row-details,.auto-sync-stats>div,.pml-race-class-card) {
 color:#233e5a;
}
html[data-theme="light"] body.admin-page :is(.category-title,.race-card-head,.pml-race-class-title) strong {color:#1a304b}
html[data-theme="light"] body.admin-page .search-count {color:#385675}
html[data-theme="light"] body.admin-page :is(.pml-race-class-copy,.pml-race-class-stats,.row-details) .muted {color:#4a5e76}
html[data-theme="light"] body.admin-page :is(.flash.error,.pml-stage-lock-notice) {color:#713b21}
html[data-theme="dark"] body.admin-page :is(.pml-v96-sponsor-files,.pml-v93-empty-state) {color:#e6f2ff}
