/* ==========================================================================
   05. SOURCE: contrast-v531.css
   ========================================================================== */
/* TDH v53.1 contrast and readability audit.
   Final semantic override for light, dark and system themes. */

:root{
  --tdh-on-accent:#fff;
  --tdh-on-dark:#fff;
  --tdh-link:#78178e;
  --tdh-link-hover:#59106b;
}
html[data-theme="dark"]{--tdh-link:#dd79eb;--tdh-link-hover:#efb0f7;--tdh-on-accent:#fff;--tdh-on-dark:#fff}
@media(prefers-color-scheme:dark){html:not([data-theme]){--tdh-link:#dd79eb;--tdh-link-hover:#efb0f7}}

body,.page,.main,.panel,.card,.dialog,.db,.ibox,.adm-content,.dbt-workspace,.sms-mdu-body{color:var(--tdh-text)!important}
p,li,.muted,.dbt-current p,.adm-view-head p,.sms-wl-hero p,.multi-plan-head-v473 p{color:var(--tdh-text-muted)!important}
h1,h2,h3,h4,h5,h6,strong,b,.value{color:var(--tdh-text)!important}
a,.delivery-link,.dbt-action-col button{color:var(--tdh-link)!important}
a:hover,.delivery-link:hover,.dbt-action-col button:hover{color:var(--tdh-link-hover)!important}

/* Never let global heading/text rules weaken text on colored surfaces. */
.top,.top h1,.top h2,.top h3,.top strong,.top b,.top p,.top span,
.homehero,.homehero h1,.homehero h2,.homehero h3,.homehero p,.homehero strong,
.plan-week-head,.plan-week-head b,.plan-week-head span,
.nav button.active,.nav button.active span,.nav button.active b,
.adm-shell>aside button.active,.adm-shell>aside button.active span,.adm-shell>aside button.active b,.adm-shell>aside button.active small,
.dbt-sidebar nav button.active,.dbt-sidebar nav button.active span,.dbt-sidebar nav button.active b,.dbt-sidebar nav button.active small,
.btn.primary,.btn.primary span,.dbt-danger-btn,.dbt-danger-btn span{color:var(--tdh-on-dark)!important}

/* Semantic surfaces */
.kpi.red,.kpi.red b,.kpi.red span{color:#9f1734!important}.kpi.amber,.kpi.amber b,.kpi.amber span{color:#86510a!important}.kpi.violet,.kpi.violet b,.kpi.violet span{color:#641878!important}
.badge.green,.lock-state{color:var(--tdh-success)!important}.badge.amber{color:var(--tdh-warning)!important}.badge.red,.dbt-sql-error{color:var(--tdh-danger)!important}.badge.violet{color:var(--tdh-brand-700)!important}
.dbt-null{background:var(--tdh-surface-muted)!important;color:var(--tdh-text-secondary)!important}

/* Inputs and tables */
input,select,textarea,.input{color:var(--tdh-text)!important;background-color:var(--tdh-surface)!important}
option{color:var(--tdh-text)!important;background:var(--tdh-surface)!important}
input::placeholder,textarea::placeholder{color:var(--tdh-text-faint)!important;opacity:1!important}
thead th{color:var(--tdh-text-secondary)!important;background:var(--tdh-surface-subtle)!important}
tbody td{color:var(--tdh-text)!important;background-color:transparent}

/* Secondary cards and helper blocks */
.template-status,.ibox,.planning-selected-info,.multi-plan-facts-v473>div,.multi-plan-comment-v473,.sms-template-note,
.dbt-summary article,.adm-check-grid label,.adm-column-grid label,.dash46-date-row span{background:var(--tdh-surface-subtle)!important;color:var(--tdh-text)!important}
.template-status p,.ibox p,.planning-selected-info small,.multi-plan-facts-v473 small,.sms-template-note p,.dbt-summary small{color:var(--tdh-text-muted)!important}

/* Dark mode-specific correction for legacy hard-coded light backgrounds. */
html[data-theme="dark"] .backlog-compact-head-v40,html[data-theme="dark"] .plan-day-head,html[data-theme="dark"] .planning-backlog-head,
html[data-theme="dark"] .dash46-filter-drawer,html[data-theme="dark"] .sms-wl-hero,html[data-theme="dark"] .sms-mdu-body,
html[data-theme="dark"] .adm-list,html[data-theme="dark"] .dbt-sidebar,html[data-theme="dark"] .dbt-table-frame>footer,
html[data-theme="dark"] .dbt-column-popover,html[data-theme="dark"] .multi-plan-body-v473{background:var(--tdh-surface-subtle)!important;color:var(--tdh-text)!important}
html[data-theme="dark"] .role-card-v46,html[data-theme="dark"] .role-card-v452,
html[data-theme="dark"] .delivery-dialog-v452,html[data-theme="dark"] .delivery-edit-v452,
html[data-theme="dark"] .dialog,html[data-theme="dark"] .multi-plan-dialog-v473,
html[data-theme="dark"] .tdh-profile-modal section{background:var(--tdh-surface-raised)!important;color:var(--tdh-text)!important}
html[data-theme="dark"] .role-options-v46 button,html[data-theme="dark"] .role-options-v452 button{background:var(--tdh-surface)!important;color:var(--tdh-text)!important;border-color:var(--tdh-line)!important}
html[data-theme="dark"] .close,html[data-theme="dark"] .multi-plan-close-v473{background:var(--tdh-surface-muted)!important;color:var(--tdh-text)!important}

@media(prefers-color-scheme:dark){
  html:not([data-theme]) .backlog-compact-head-v40,html:not([data-theme]) .plan-day-head,html:not([data-theme]) .planning-backlog-head,
  html:not([data-theme]) .dash46-filter-drawer,html:not([data-theme]) .sms-wl-hero,html:not([data-theme]) .sms-mdu-body,
  html:not([data-theme]) .adm-list,html:not([data-theme]) .dbt-sidebar,html:not([data-theme]) .dbt-table-frame>footer,
  html:not([data-theme]) .dbt-column-popover,html:not([data-theme]) .multi-plan-body-v473{background:var(--tdh-surface-subtle)!important;color:var(--tdh-text)!important}
  html:not([data-theme]) .role-card-v46,html:not([data-theme]) .role-card-v452,html:not([data-theme]) .delivery-dialog-v452,
  html:not([data-theme]) .delivery-edit-v452,html:not([data-theme]) .dialog,html:not([data-theme]) .multi-plan-dialog-v473,
  html:not([data-theme]) .tdh-profile-modal section{background:var(--tdh-surface-raised)!important;color:var(--tdh-text)!important}
}
