/* Diet Planner — centralized dark theme rules.
   Semantic tokens are defined in design-tokens.css.
   Page-specific layout and behavior remain untouched. */

html[data-theme="dark"] body{
  background-color:var(--dp-bg)!important;
  color:var(--dp-text)!important;
}

html[data-theme="dark"] body,
html[data-theme="dark"] .glass,
html[data-theme="dark"] .card,
html[data-theme="dark"] .main-container,
html[data-theme="dark"] .nav-card,
html[data-theme="dark"] .qc-panel,
html[data-theme="dark"] .editor,
html[data-theme="dark"] .content{
  color:var(--dp-text);
}

/* ---------- Universal neutral surfaces ---------- */
html[data-theme="dark"] .bg-white,
html[data-theme="dark"] .bg-white\/95,
html[data-theme="dark"] .bg-white\/90,
html[data-theme="dark"] .bg-white\/88,
html[data-theme="dark"] .bg-white\/86,
html[data-theme="dark"] .bg-white\/84,
html[data-theme="dark"] .bg-white\/60{
  background-color:var(--dp-surface)!important;
}

html[data-theme="dark"] .bg-slate-50,
html[data-theme="dark"] .bg-gray-50{
  background-color:var(--dp-surface-2)!important;
}
html[data-theme="dark"] .bg-slate-100,
html[data-theme="dark"] .bg-gray-100{
  background-color:var(--dp-surface-3)!important;
}
html[data-theme="dark"] .bg-slate-200,
html[data-theme="dark"] .bg-gray-200{
  background-color:var(--dp-dark-border)!important;
}

/* ---------- Universal text ---------- */
html[data-theme="dark"] .text-slate-900,
html[data-theme="dark"] .text-slate-800,
html[data-theme="dark"] .text-slate-700,
html[data-theme="dark"] .text-gray-900,
html[data-theme="dark"] .text-gray-800,
html[data-theme="dark"] .text-gray-700{
  color:var(--dp-text)!important;
}
html[data-theme="dark"] .text-slate-600,
html[data-theme="dark"] .text-slate-500,
html[data-theme="dark"] .text-gray-600,
html[data-theme="dark"] .text-gray-500{
  color:var(--dp-text-2)!important;
}
html[data-theme="dark"] .text-slate-400,
html[data-theme="dark"] .text-gray-400{
  color:var(--dp-muted)!important;
}
html[data-theme="dark"] .text-slate-300,
html[data-theme="dark"] .text-gray-300{
  color:var(--dp-dark-placeholder)!important;
}

/* ---------- Universal borders ---------- */
html[data-theme="dark"] .border-slate-50,
html[data-theme="dark"] .border-slate-100,
html[data-theme="dark"] .border-slate-200,
html[data-theme="dark"] .border-slate-300,
html[data-theme="dark"] .border-gray-100,
html[data-theme="dark"] .border-gray-200,
html[data-theme="dark"] .border-gray-300{
  border-color:var(--dp-border)!important;
}
html[data-theme="dark"] hr{border-color:var(--dp-border)!important}

/* ---------- Forms ---------- */
html[data-theme="dark"] input,
html[data-theme="dark"] select,
html[data-theme="dark"] textarea{
  background-color:var(--dp-input)!important;
  color:var(--dp-text)!important;
  border-color:var(--dp-input-border)!important;
}
html[data-theme="dark"] input::placeholder,
html[data-theme="dark"] textarea::placeholder{
  color:var(--dp-dark-placeholder)!important;
}
html[data-theme="dark"] input:disabled,
html[data-theme="dark"] select:disabled,
html[data-theme="dark"] textarea:disabled{
  background:var(--dp-dark-surface-raised)!important;
  color:#829a95!important;
  border-color:#2f433f!important;
}
html[data-theme="dark"] option{
  background:var(--dp-dark-surface-raised)!important;
  color:var(--dp-dark-text)!important;
}

/* ---------- Common custom surfaces ---------- */
html[data-theme="dark"] .glass,
html[data-theme="dark"] .card,
html[data-theme="dark"] .main-container,
html[data-theme="dark"] .nav-card{
  background:var(--dp-surface)!important;
  border-color:var(--dp-border)!important;
  box-shadow:0 10px 28px var(--dp-shadow)!important;
}
html[data-theme="dark"] .header,
html[data-theme="dark"] .toolbar,
html[data-theme="dark"] .tabs,
html[data-theme="dark"] .support-header,
html[data-theme="dark"] .support-patient-area,
html[data-theme="dark"] .selected-patient-area,
html[data-theme="dark"] .support-days,
html[data-theme="dark"] .support-tabs{
  background:var(--dp-surface)!important;
  color:var(--dp-text)!important;
  border-color:var(--dp-border)!important;
}
html[data-theme="dark"] .modal,
html[data-theme="dark"] .error-modal,
html[data-theme="dark"] .confirm-modal,
html[data-theme="dark"] .patient-modal,
html[data-theme="dark"] .delete-confirm-box,
html[data-theme="dark"] .print-settings-modal,
html[data-theme="dark"] .print-completion-modal{
  background:var(--dp-surface)!important;
  color:var(--dp-text)!important;
  border-color:var(--dp-border)!important;
}
html[data-theme="dark"] .field label,
html[data-theme="dark"] .form-group label,
html[data-theme="dark"] .patient-form-field label{
  color:var(--dp-text-2)!important;
}

/* ---------- Tables ---------- */
html[data-theme="dark"] table{color:var(--dp-text)!important}
html[data-theme="dark"] thead,
html[data-theme="dark"] th{
  background:var(--dp-dark-surface)!important;
  color:var(--dp-text)!important;
  border-color:var(--dp-border)!important;
}
html[data-theme="dark"] td{
  border-color:var(--dp-border)!important;
  color:var(--dp-text)!important;
}

/* ---------- Common light accent surfaces ---------- */
html[data-theme="dark"] .bg-blue-50{background:#172d39!important}
html[data-theme="dark"] .bg-cyan-50{background:#163035!important}
html[data-theme="dark"] .bg-sky-50{background:#172d3b!important}
html[data-theme="dark"] .bg-emerald-50{background:#173027!important}
html[data-theme="dark"] .bg-green-50{background:#173027!important}
html[data-theme="dark"] .bg-amber-50{background:#3a2d17!important}
html[data-theme="dark"] .bg-yellow-50{background:#3a2d17!important}
html[data-theme="dark"] .bg-orange-50{background:#38261a!important}
html[data-theme="dark"] .bg-red-50{background:#351d23!important}
html[data-theme="dark"] .bg-rose-50{background:#351d23!important}
html[data-theme="dark"] .bg-purple-50{background:#29233d!important}
html[data-theme="dark"] .bg-violet-50{background:#29233d!important}
html[data-theme="dark"] .bg-indigo-50{background:#202746!important}

html[data-theme="dark"] .text-blue-700,
html[data-theme="dark"] .text-blue-800,
html[data-theme="dark"] .text-blue-900{color:#7dd3fc!important}
html[data-theme="dark"] .text-sky-700,
html[data-theme="dark"] .text-sky-800,
html[data-theme="dark"] .text-sky-900{color:#7dd3fc!important}
html[data-theme="dark"] .text-emerald-600,
html[data-theme="dark"] .text-emerald-700,
html[data-theme="dark"] .text-emerald-800,
html[data-theme="dark"] .text-emerald-900{color:#6ee7b7!important}
html[data-theme="dark"] .text-green-700,
html[data-theme="dark"] .text-green-800{color:#6ee7b7!important}
html[data-theme="dark"] .text-amber-600,
html[data-theme="dark"] .text-amber-700,
html[data-theme="dark"] .text-amber-800{color:#fbbf24!important}
html[data-theme="dark"] .text-red-600,
html[data-theme="dark"] .text-red-700,
html[data-theme="dark"] .text-red-800{color:#fda4af!important}
html[data-theme="dark"] .text-rose-600,
html[data-theme="dark"] .text-rose-700{color:#fda4af!important}
html[data-theme="dark"] .text-purple-700,
html[data-theme="dark"] .text-purple-800,
html[data-theme="dark"] .text-purple-900,
html[data-theme="dark"] .text-violet-700{color:#c4b5fd!important}
html[data-theme="dark"] .text-indigo-700,
html[data-theme="dark"] .text-indigo-800{color:#a5b4fc!important}

/* ---------- Gradients used by generated diet/legacy UI ---------- */
html[data-theme="dark"] .from-slate-50{
  --tw-gradient-from:var(--dp-dark-surface)!important;
  --tw-gradient-to:rgba(29,41,39,0)!important;
}
html[data-theme="dark"] .to-white{
  --tw-gradient-to:var(--dp-dark-surface-raised)!important;
}
html[data-theme="dark"] .bg-gradient-to-b.from-slate-50{
  background-image:linear-gradient(to bottom,var(--dp-dark-surface),var(--dp-dark-surface-raised))!important;
}
html[data-theme="dark"] .bg-gradient-to-b{
  --tw-gradient-to:var(--dp-dark-surface-raised)!important;
}

/* ---------- Loading / overlays ---------- */
html[data-theme="dark"] .loading,
html[data-theme="dark"] #loading,
html[data-theme="dark"] #loadingScreen{
  background:var(--dp-dark-base)!important;
  color:var(--dp-text)!important;
}
html[data-theme="dark"] .modal-bg,
html[data-theme="dark"] .modal-backdrop,
html[data-theme="dark"] .confirm-backdrop,
html[data-theme="dark"] .error-overlay{
  background:rgba(2,8,7,.78)!important;
}
html[data-theme="dark"] .spinner{
  border-color:#24443f!important;
  border-top-color:#20A88A!important;
}

/* ---------- Buttons / controls ---------- */
html[data-theme="dark"] button.bg-white,
html[data-theme="dark"] a.bg-white,
html[data-theme="dark"] .btn-outline,
html[data-theme="dark"] .back-btn,
html[data-theme="dark"] .icon-btn,
html[data-theme="dark"] .close{
  background:var(--dp-dark-surface)!important;
  color:var(--dp-dark-accent)!important;
  border-color:var(--dp-dark-input-border)!important;
}
html[data-theme="dark"] .btn-danger,
html[data-theme="dark"] .patient-delete-cancel,
html[data-theme="dark"] .delete-confirm-cancel,
html[data-theme="dark"] .print-cancel-btn{
  background:#26332f!important;
  color:var(--dp-dark-text-secondary)!important;
}
html[data-theme="dark"] .tab-btn.active,
html[data-theme="dark"] .support-tab.active{
  background:#173a34!important;
  color:var(--dp-dark-accent)!important;
}
html[data-theme="dark"] .support-tab.tpn.active{
  background:#292d4d!important;
  color:#c4b5fd!important;
}

/* ---------- Login / auth ---------- */
html[data-theme="dark"] body:has(.auth-form),
html[data-theme="dark"] body:has(.site-link){
  background:var(--dp-dark-base)!important;
}
html[data-theme="dark"] body:has(.auth-form) .card{
  background:var(--dp-dark-surface-raised)!important;
  border-color:var(--dp-dark-border)!important;
}
html[data-theme="dark"] .tabs button,
html[data-theme="dark"] .google-btn{
  background:var(--dp-dark-surface)!important;
  color:var(--dp-dark-text-secondary)!important;
  border-color:var(--dp-dark-input-border)!important;
}
html[data-theme="dark"] .tabs button.active{
  background:#243b37!important;
  color:var(--dp-dark-accent)!important;
}
html[data-theme="dark"] .msg.error{background:#351d23!important;color:#fda4af!important}
html[data-theme="dark"] .msg.success{background:#173027!important;color:#6ee7b7!important}

/* ---------- Dashboard / application ---------- */
html[data-theme="dark"] .nav-card .icon-box{
  filter:brightness(.82) saturate(.9);
}
html[data-theme="dark"] .page-header{
  background:var(--dp-surface)!important;
  color:var(--dp-text)!important;
  border-color:var(--dp-border)!important;
}
html[data-theme="dark"] .page-header h1,
html[data-theme="dark"] .page-header-icon{
  color:var(--dp-text)!important;
}
html[data-theme="dark"] .page-header-icon{
  background:#0f7168!important;
  color:#fff!important;
}

/* ---------- Quick calculator ---------- */
html[data-theme="dark"] .qc-tab{
  background:var(--dp-surface)!important;
  color:var(--dp-text)!important;
}
html[data-theme="dark"] .qc-tab small,
html[data-theme="dark"] .qc-panel label{
  color:var(--dp-text-2)!important;
}
html[data-theme="dark"] #sub-content-quick-calc > .border{
  background:var(--dp-surface)!important;
  border-color:var(--dp-dark-input-border)!important;
}
html[data-theme="dark"] #sub-content-quick-calc > .border > [id$="-content"]{
  background:linear-gradient(180deg,var(--dp-dark-surface) 0%,var(--dp-dark-surface-raised) 110px)!important;
  border-color:var(--dp-dark-border)!important;
}
html[data-theme="dark"] .qc-panel{
  background:var(--dp-dark-surface)!important;
  border-color:#35514b!important;
}
html[data-theme="dark"] .iv-line-row{
  background:linear-gradient(180deg,#1d2a28,var(--dp-dark-surface))!important;
  border-color:var(--dp-dark-input-border)!important;
}
html[data-theme="dark"] .qc-result{
  background:linear-gradient(180deg,#1d302d,var(--dp-dark-surface-raised))!important;
  border-color:#3e6f66!important;
}
html[data-theme="dark"] .qc-note{
  background:var(--dp-dark-surface-raised)!important;
  color:var(--dp-dark-text-secondary)!important;
  border-color:var(--dp-dark-input-border)!important;
}
html[data-theme="dark"] .highlight-box{
  background:#15302d!important;
  color:#d9efeb!important;
  border-color:#3f837a!important;
}

/* ---------- Visit / gram plan ---------- */
html[data-theme="dark"] .assessment-section,
html[data-theme="dark"] .calc-card,
html[data-theme="dark"] #calculatorContent,
html[data-theme="dark"] #dietPlanContent,
html[data-theme="dark"] #exchangePlanContent{
  background:var(--dp-surface)!important;
  color:var(--dp-text)!important;
  border-color:var(--dp-border)!important;
}
html[data-theme="dark"] .module-card.assessment-module{
  background:linear-gradient(180deg,#16332f,var(--dp-dark-surface-raised) 62%)!important;
  border-color:#2d6960!important;
}
html[data-theme="dark"] .module-card.calculator-module{
  background:linear-gradient(180deg,#182d3a,var(--dp-dark-surface-raised) 62%)!important;
  border-color:#315e75!important;
}
html[data-theme="dark"] .module-card.diet-module{
  background:linear-gradient(180deg,#193127,var(--dp-dark-surface-raised) 62%)!important;
  border-color:#356b4c!important;
}
html[data-theme="dark"] .embedded-diet-plan{
  background:var(--dp-dark-base)!important;
  color:var(--dp-dark-text)!important;
}
html[data-theme="dark"] .embedded-diet-plan .day-card{
  background:var(--dp-dark-surface-raised)!important;
  border-color:var(--dp-dark-border)!important;
  color:#E4EEE9!important;
}
html[data-theme="dark"] .embedded-diet-plan .meal-header{
  background:var(--dp-dark-surface-raised)!important;
  color:var(--dp-dark-text)!important;
}
html[data-theme="dark"] .embedded-diet-plan .bg-white{
  background:var(--dp-dark-surface-raised)!important;
  color:#E4EEE9!important;
}
html[data-theme="dark"] .embedded-diet-plan .bg-slate-50{
  background:var(--dp-dark-surface)!important;
}
html[data-theme="dark"] .embedded-diet-plan .bg-slate-100{
  background:#26332f!important;
}
html[data-theme="dark"] .embedded-diet-plan .border-slate-50,
html[data-theme="dark"] .embedded-diet-plan .border-slate-100,
html[data-theme="dark"] .embedded-diet-plan .border-slate-200{
  border-color:var(--dp-dark-border)!important;
}
html[data-theme="dark"] .embedded-diet-plan input,
html[data-theme="dark"] .embedded-diet-plan select,
html[data-theme="dark"] .embedded-diet-plan textarea{
  background:var(--dp-dark-surface-raised)!important;
  color:var(--dp-dark-text)!important;
  border-color:var(--dp-dark-input-border)!important;
}
html[data-theme="dark"] .embedded-diet-plan .bg-gradient-to-b.from-slate-50{
  background-image:linear-gradient(to bottom,var(--dp-dark-surface),var(--dp-dark-surface-raised))!important;
}

/* ---------- Diet library ---------- */
html[data-theme="dark"] #editor > div,
html[data-theme="dark"] #foodPicker > div{
  background:var(--dp-dark-surface-raised)!important;
  color:var(--dp-dark-text)!important;
  border-color:var(--dp-dark-border)!important;
}
html[data-theme="dark"] #editor > div > .sticky,
html[data-theme="dark"] #foodPicker > div > div{
  background:var(--dp-dark-surface)!important;
  border-color:var(--dp-dark-border)!important;
}
html[data-theme="dark"] .diet-table,
html[data-theme="dark"] .diet-table td,
html[data-theme="dark"] .food-row{
  background:var(--dp-dark-surface-raised)!important;
  color:#D2DFD8!important;
  border-color:var(--dp-dark-border)!important;
}
html[data-theme="dark"] .diet-table thead{
  background:var(--dp-dark-surface)!important;
}
html[data-theme="dark"] .food-name-cell{
  color:var(--dp-dark-text)!important;
}
html[data-theme="dark"] .food-name-en{
  color:#91A69C!important;
}
html[data-theme="dark"] #foodPicker #foodSearch,
html[data-theme="dark"] #foodPicker #selectedFoodGrams{
  background:var(--dp-dark-surface-raised)!important;
  color:var(--dp-dark-text)!important;
  border-color:var(--dp-dark-input-border)!important;
}
html[data-theme="dark"] #foodPicker #selectedFoodBox{
  background:#17312d!important;
  border-color:#3d756c!important;
}

/* ---------- Food library ---------- */
html[data-theme="dark"] .products-table th:first-child,
html[data-theme="dark"] .products-table td:first-child{
  background:var(--dp-dark-surface-raised)!important;
}
html[data-theme="dark"] .products-table thead th:first-child{
  background:var(--dp-dark-surface)!important;
}
html[data-theme="dark"] .table-wrap::-webkit-scrollbar-track{
  background:var(--dp-dark-surface)!important;
}
html[data-theme="dark"] .table-wrap::-webkit-scrollbar-thumb{
  background:var(--dp-dark-input-border)!important;
}

/* ---------- Patient / profile / support custom cards ---------- */
html[data-theme="dark"] .patient-card{
  background:var(--dp-dark-surface)!important;
  border-color:var(--dp-dark-border)!important;
}
html[data-theme="dark"] .patient-card:hover{
  background:#20312d!important;
}
html[data-theme="dark"] .patient-readonly-card{
  background:var(--dp-dark-surface-raised)!important;
  border-color:var(--dp-dark-border)!important;
}
html[data-theme="dark"] .patient-data-toggle{
  background:#17332f!important;
  color:var(--dp-dark-accent)!important;
}
html[data-theme="dark"] .patient-modal-overlay,
html[data-theme="dark"] .patient-delete-confirm,
html[data-theme="dark"] .delete-confirm-overlay,
html[data-theme="dark"] .print-settings-overlay,
html[data-theme="dark"] .print-completion-overlay{
  background:rgba(2,8,7,.82)!important;
}
html[data-theme="dark"] .patient-form-field input,
html[data-theme="dark"] .patient-form-field select,
html[data-theme="dark"] .patient-form-field textarea{
  background:#101a18!important;
}
html[data-theme="dark"] .day-item{
  background:var(--dp-dark-surface)!important;
  color:#c0d1cc!important;
  border-color:var(--dp-dark-input-border)!important;
}
html[data-theme="dark"] .day-item.active{
  background:#173a34!important;
  color:var(--dp-dark-accent)!important;
  border-color:#2d8176!important;
}

/* ---------- Subscription pages ---------- */
html[data-theme="dark"] .subscription-status-card,
html[data-theme="dark"] .method,
html[data-theme="dark"] .selected-plan-info{
  background:var(--dp-dark-surface)!important;
  color:#D2DFD8!important;
  border-color:var(--dp-dark-border)!important;
}
html[data-theme="dark"] .subscription-status-card strong{
  color:var(--dp-dark-accent)!important;
}
html[data-theme="dark"] .error-details{
  background:#351d23!important;
  border-color:#70404a!important;
  color:#f5c3ca!important;
}

/* ---------- Article editor ---------- */
html[data-theme="dark"] .editor table td,
html[data-theme="dark"] .editor table th,
html[data-theme="dark"] .content table td,
html[data-theme="dark"] .content table th{
  border-color:var(--dp-dark-input-border)!important;
}
html[data-theme="dark"] .editor table th,
html[data-theme="dark"] .content table th,
html[data-theme="dark"] .editor blockquote,
html[data-theme="dark"] .content blockquote{
  background:#17302c!important;
  color:#D2DFD8!important;
  border-color:#3d756c!important;
}

/* ---------- About / privacy / update-password ---------- */
html[data-theme="dark"] .editor{
  background:var(--dp-surface)!important;
  color:var(--dp-text)!important;
}
html[data-theme="dark"] .toolbar button{
  background:var(--dp-dark-surface)!important;
  color:var(--dp-dark-text-secondary)!important;
  border-color:var(--dp-dark-input-border)!important;
}
html[data-theme="dark"] .toolbar button:hover{
  background:#293D37!important;
}
html[data-theme="dark"] .site-link a{color:var(--dp-dark-accent)!important}

/* ---------- SVG weight chart ---------- */
html[data-theme="dark"] .chart-grid{stroke:var(--dp-dark-border)!important}
html[data-theme="dark"] .chart-axis,
html[data-theme="dark"] .chart-date{fill:#91A69C!important}
html[data-theme="dark"] .chart-dot{stroke:var(--dp-dark-surface-raised)!important}
html[data-theme="dark"] .chart-tooltip{
  background:var(--dp-dark-surface-raised)!important;
  color:var(--dp-dark-text)!important;
}

/* ---------- Scrollbars ---------- */
html[data-theme="dark"] .custom-scrollbar::-webkit-scrollbar-track,
html[data-theme="dark"] .table-wrap::-webkit-scrollbar-track{
  background:var(--dp-dark-surface)!important;
}
html[data-theme="dark"] .custom-scrollbar::-webkit-scrollbar-thumb,
html[data-theme="dark"] .table-wrap::-webkit-scrollbar-thumb{
  background:var(--dp-dark-input-border)!important;
}

/* ---------- Theme toggle ---------- */
.dp-theme-toggle{
  position:fixed;
  z-index:99999;
  right:18px;
  bottom:18px;
  width:46px;
  height:46px;
  border:1px solid rgba(23,143,132,.28);
  border-radius:15px;
  display:flex;
  align-items:center;
  justify-content:center;
  background:rgba(255,255,255,.94);
  color:#126f67;
  box-shadow:0 8px 24px rgba(15,71,67,.14);
  cursor:pointer;
  font-size:19px;
  line-height:1;
  backdrop-filter:blur(10px);
  -webkit-backdrop-filter:blur(10px);
  transition:transform .18s ease,box-shadow .18s ease,background .18s ease;
}
html[data-theme="dark"] .dp-theme-toggle{
  background:var(--dp-dark-surface);
  color:var(--dp-dark-accent);
  border-color:var(--dp-dark-input-border);
  box-shadow:0 8px 24px rgba(0,0,0,.35);
}
.dp-theme-toggle:hover{transform:translateY(-2px)}
.dp-theme-toggle:focus-visible{
  outline:3px solid rgba(23,143,132,.22);
  outline-offset:2px;
}
@media(max-width:640px){
  .dp-theme-toggle{right:14px;bottom:14px;width:43px;height:43px;border-radius:14px}
}

/* ---------- Print is always light ---------- */
@media print{
  html[data-theme="dark"],
  html[data-theme="dark"] body,
  html[data-theme="dark"] body *{
    color-scheme:light!important;
  }
}

/* ---------- Tailwind opacity variants ---------- */
html[data-theme="dark"] .bg-slate-50\/60,
html[data-theme="dark"] .bg-slate-50\/70{background:var(--dp-surface-2)!important}
html[data-theme="dark"] .bg-emerald-50\/70{background:#173027!important}
html[data-theme="dark"] .bg-amber-50\/60{background:#3a2d17!important}


/* =========================================================
   Central dark-theme compatibility layer
   Loaded after page styles by theme.js; fixes only shared
   branded surfaces and custom components not using tokens.
   ========================================================= */

/* Preserve the green brand treatment and readable white copy. */
html[data-theme="dark"] header.header,
html[data-theme="dark"] .patient-profile-page-header,
html[data-theme="dark"] .profile-page-header,
html[data-theme="dark"] .finance-page-header,
html[data-theme="dark"] .about-branded-header,
html[data-theme="dark"] .patient-page-header,
html[data-theme="dark"] .feedback-branded-header,
html[data-theme="dark"] .food-page-header,
html[data-theme="dark"] .recipe-page-header,
html[data-theme="dark"] .support-header{
  background:linear-gradient(118deg,#174D43 0%,#087F6B 68%,#066B5B 100%)!important;
  color:var(--dp-dark-text)!important;
  border-color:transparent!important;
}
html[data-theme="dark"] :is(.patient-profile-page-header,.profile-page-header,.finance-page-header,.about-branded-header,.patient-page-header,.feedback-branded-header,.food-page-header,.recipe-page-header,.support-header) :is(h1,h2,h3,p,span,small,strong){
  color:var(--dp-dark-text)!important;
}

/* The compact dashboard welcome panel retains readable white text in dark mode. */
html[data-theme="dark"] .dp-dashboard-welcome-card :is(h1,h2,h3,p,span){
  color:var(--dp-dark-text)!important;
}

/* Dashboard custom cards and announcement dialog. */
html[data-theme="dark"] .dashboard-announcements-section{
  background:var(--dp-surface)!important;
  border-color:var(--dp-border)!important;
}
html[data-theme="dark"] .dashboard-announcement-card,
html[data-theme="dark"] .dp-announcement-dialog{
  background:var(--dp-surface-2)!important;
  color:var(--dp-text)!important;
  border-color:var(--dp-border)!important;
}
html[data-theme="dark"] .dashboard-announcement-card h4,
html[data-theme="dark"] .dashboard-notification-patient,
html[data-theme="dark"] .dp-announcement-dialog h3{
  color:var(--dp-text)!important;
}
html[data-theme="dark"] .dashboard-announcement-card p,
html[data-theme="dark"] .dashboard-announcement-card-footer,
html[data-theme="dark"] .dashboard-notification-action,
html[data-theme="dark"] .dashboard-notification-date,
html[data-theme="dark"] .dp-announcement-dialog p,
html[data-theme="dark"] .dp-announcement-dialog-date{
  color:var(--dp-text-2)!important;
}
html[data-theme="dark"] .dp-announcement-close{
  background:var(--dp-surface)!important;
  color:var(--dp-text-2)!important;
  border-color:var(--dp-border)!important;
}

/* Article detail page includes an inline light stylesheet. */
html[data-theme="dark"] .article-body{
  color:var(--dp-text)!important;
}
html[data-theme="dark"] .article-body :is(h1,h2,h3,h4,h5,h6,strong){
  color:var(--dp-text)!important;
}
html[data-theme="dark"] .article-body blockquote{
  background:#173D34!important;
  color:var(--dp-text)!important;
  border-color:var(--dp-primary)!important;
}
html[data-theme="dark"] .article-body a{color:var(--dp-dark-accent)!important}
html[data-theme="dark"] .article-body th,
html[data-theme="dark"] .article-body td{
  border-color:var(--dp-border)!important;
}

/* ---------- Page-surface normalization: patient directory ---------- */
html[data-theme="dark"] body:has(.patient-stats) main > section,
html[data-theme="dark"] body:has(.patient-stats) main > section.bg-white{
  background:var(--dp-surface)!important;
  color:var(--dp-text)!important;
  border-color:var(--dp-border)!important;
  box-shadow:0 8px 26px var(--dp-shadow)!important;
}
html[data-theme="dark"] .patient-stat{
  background:var(--dp-surface-2)!important;
  color:var(--dp-text-2)!important;
  border-color:var(--dp-border)!important;
}
html[data-theme="dark"] .patient-stat.is-selected{
  background:#173a34!important;
  color:var(--dp-text)!important;
  border-color:#287f70!important;
  box-shadow:inset 0 0 0 1px rgba(32,168,138,.16)!important;
}
html[data-theme="dark"] .patient-stat-label{color:var(--dp-text-2)!important}
html[data-theme="dark"] .patient-stat strong{color:var(--dp-text)!important}
html[data-theme="dark"] .patient-row,
html[data-theme="dark"] .patient-row:nth-child(even){
  background:var(--dp-surface-2)!important;
  border-color:var(--dp-border)!important;
}
html[data-theme="dark"] .patient-row:hover{background:var(--dp-surface-3)!important}
html[data-theme="dark"] .patient-name{color:var(--dp-text)!important}
html[data-theme="dark"] .patient-diagnosis,
html[data-theme="dark"] .patient-follow-up{color:var(--dp-text-2)!important}
html[data-theme="dark"] .patient-empty{color:var(--dp-muted)!important}
html[data-theme="dark"] .patient-delete{
  background:#352329!important;
  border-color:#633a43!important;
  color:#F29A9A!important;
}
html[data-theme="dark"] .patient-status--active{background:#173a2d!important;color:#80D9AE!important}
html[data-theme="dark"] .patient-status--expired{background:#3a2027!important;color:#F2A0A7!important}
html[data-theme="dark"] .patient-status--unknown{background:#3a321d!important;color:#E5C77A!important}

/* ---------- Page-surface normalization: nutrition support ---------- */
html[data-theme="dark"] .support-patient-area,
html[data-theme="dark"] .selected-patient-area,
html[data-theme="dark"] .patient-readonly-card,
html[data-theme="dark"] .support-tabs{
  background:var(--dp-surface)!important;
  color:var(--dp-text)!important;
  border-color:var(--dp-border)!important;
}
html[data-theme="dark"] .patient-data-toggle,
html[data-theme="dark"] .support-tab{
  background:var(--dp-surface-2)!important;
  color:var(--dp-text-2)!important;
  border-color:var(--dp-border)!important;
}
html[data-theme="dark"] .support-tab.active{
  background:#173a34!important;
  color:#8DE0C7!important;
  border-bottom-color:var(--dp-accent)!important;
}
html[data-theme="dark"] .pdata{border-color:var(--dp-border)!important}
html[data-theme="dark"] .pdata span{color:var(--dp-text-2)!important}
html[data-theme="dark"] .pdata strong{color:var(--dp-text)!important}

/* ---------- Page-surface normalization: diet plan editor and preview ---------- */
html[data-theme="dark"] .diet-preview,
html[data-theme="dark"] .dp-macro,
html[data-theme="dark"] .dp-meal,
html[data-theme="dark"] .dp-meal-head,
html[data-theme="dark"] .dp-food-note,
html[data-theme="dark"] .dp-notes{
  background:var(--dp-surface-2)!important;
  color:var(--dp-text)!important;
  border-color:var(--dp-border)!important;
}
html[data-theme="dark"] .dp-section-title,
html[data-theme="dark"] .dp-meal-head h3,
html[data-theme="dark"] .dp-food-main strong{
  color:var(--dp-text)!important;
}
html[data-theme="dark"] .dp-macro span,
html[data-theme="dark"] .dp-macro small,
html[data-theme="dark"] .dp-section-head>span,
html[data-theme="dark"] .dp-count,
html[data-theme="dark"] .dp-food-main small,
html[data-theme="dark"] .dp-label,
html[data-theme="dark"] .dp-empty,
html[data-theme="dark"] .dp-footer{
  color:var(--dp-text-2)!important;
}
html[data-theme="dark"] .dp-macro strong,
html[data-theme="dark"] .dp-food-detail b{color:#78D5BE!important}
html[data-theme="dark"] .dp-meal-head{border-bottom-color:var(--dp-border)!important}
html[data-theme="dark"] .dp-food{border-bottom-color:var(--dp-border)!important}
html[data-theme="dark"] .dp-food-note p,
html[data-theme="dark"] .dp-notes p{color:var(--dp-text-2)!important}
html[data-theme="dark"] .dp-notes .dp-section-title{color:#E5C77A!important}
html[data-theme="dark"] .diet-list-item,
html[data-theme="dark"] .diet-stat-mini{
  background:var(--dp-surface-2)!important;
  color:var(--dp-text)!important;
  border-color:var(--dp-border)!important;
}



/* =========================================================
   Central dark-theme coverage for page-specific components
   These rules are the single theme adapter for legacy page
   surfaces. Page stylesheets keep layout; semantic colors live here.
   ========================================================= */

/* Product catalogue */
html[data-theme="dark"] body:has(.product-modern),
html[data-theme="dark"] body:has(.product-modern) main>.mx-auto>section:nth-of-type(1),
html[data-theme="dark"] .product-modern,
html[data-theme="dark"] .product-usage,
html[data-theme="dark"] .product-formulas,
html[data-theme="dark"] .formula-showcase,
html[data-theme="dark"] .metric,
html[data-theme="dark"] .product-empty,
html[data-theme="dark"] .product-filter-panel{
  background:var(--dp-surface-2)!important;
  color:var(--dp-text)!important;
  border-color:var(--dp-border)!important;
  box-shadow:0 4px 18px var(--dp-shadow)!important;
}
html[data-theme="dark"] .metric-kcal{background:#3a2d17!important}
html[data-theme="dark"] .metric-carb{background:#172d3b!important}
html[data-theme="dark"] .metric-protein{background:#173027!important}
html[data-theme="dark"] .metric-fat{background:#29233d!important}
html[data-theme="dark"] .product-modern :is(h2,h3,h4,strong),
html[data-theme="dark"] .formula-showcase :is(h2,h3,h4,strong){color:var(--dp-text)!important}
html[data-theme="dark"] .product-modern :is(p,small,span),
html[data-theme="dark"] .product-usage p,
html[data-theme="dark"] .metric span{color:var(--dp-text-2)!important}
html[data-theme="dark"] .product-modern input,
html[data-theme="dark"] .product-modern select,
html[data-theme="dark"] .product-modern textarea{background:var(--dp-input)!important;color:var(--dp-text)!important;border-color:var(--dp-input-border)!important}

/* Food library */
html[data-theme="dark"] body:has(.food-brand-copy),
html[data-theme="dark"] body:has(.food-brand-copy) .glass,
html[data-theme="dark"] .table-wrap{
  background:var(--dp-surface-2)!important;
  color:var(--dp-text)!important;
  border-color:var(--dp-border)!important;
}

/* Diet library and recipe editor */
html[data-theme="dark"] body:has(.recipe-brand-copy) .glass,
html[data-theme="dark"] .recipe-card,
html[data-theme="dark"] .recipe-modal,
html[data-theme="dark"] .recipe-list-icon-btn,
html[data-theme="dark"] .diet-list-item,
html[data-theme="dark"] .diet-stat-mini{
  background:var(--dp-surface-2)!important;
  color:var(--dp-text)!important;
  border-color:var(--dp-border)!important;
}
html[data-theme="dark"] .recipe-card :is(h2,h3,h4,strong),
html[data-theme="dark"] .recipe-card :is(h2,h3,h4,strong){color:var(--dp-text)!important}
html[data-theme="dark"] .recipe-card :is(p,small,span){color:var(--dp-text-2)!important}

/* Articles list and reader */
html[data-theme="dark"] body:has(.article-card) .glass,
html[data-theme="dark"] .article-card,
html[data-theme="dark"] .article-reader-head,
html[data-theme="dark"] .article-list-item,
html[data-theme="dark"] .article-reader-content,
html[data-theme="dark"] .article-reader-content .content,
html[data-theme="dark"] .editor,
html[data-theme="dark"] .content,
html[data-theme="dark"] .article-actions button,
html[data-theme="dark"] #closeView{
  background:var(--dp-surface-2)!important;
  color:var(--dp-text)!important;
  border-color:var(--dp-border)!important;
}
html[data-theme="dark"] .article-card :is(h2,h3,h4,strong),
html[data-theme="dark"] .article-reader-content :is(h1,h2,h3,h4),
html[data-theme="dark"] .article-list-item :is(h2,h3,h4,strong){color:var(--dp-text)!important}
html[data-theme="dark"] .article-card :is(p,small,span),
html[data-theme="dark"] .article-list-item :is(p,small,span),
html[data-theme="dark"] .article-card-footer{color:var(--dp-text-2)!important}
html[data-theme="dark"] .editor blockquote,
html[data-theme="dark"] .content blockquote,
html[data-theme="dark"] .article-reader-content blockquote{background:#173a34!important;color:var(--dp-text-2)!important;border-color:var(--dp-accent)!important}

/* Feedback page — centralized surfaces, typography and controls.
   Layout remains in feedback.css; all theme colors come from shared tokens. */
html[data-theme="dark"] body:has(.feedback-branded-header),
html[data-theme="dark"] body:has(.feedback-branded-header) #feedbackPage{
  background:var(--dp-bg)!important;
  color:var(--dp-text)!important;
}
html[data-theme="dark"] body:has(.feedback-branded-header) .feedback-main-card,
html[data-theme="dark"] body:has(.feedback-branded-header) .feedback-reviews-card,
html[data-theme="dark"] body:has(.feedback-branded-header) #feedbackComposerContent,
html[data-theme="dark"] body:has(.feedback-branded-header) #feedbackLoginPrompt,
html[data-theme="dark"] body:has(.feedback-branded-header) .feedback-comment-section,
html[data-theme="dark"] body:has(.feedback-branded-header) .feedback-rating-panel,
html[data-theme="dark"] body:has(.feedback-branded-header) #feedbackForm>div:first-of-type,
html[data-theme="dark"] body:has(.feedback-branded-header) #feedbackEmpty,
html[data-theme="dark"] body:has(.feedback-branded-header) #feedbackList>article,
html[data-theme="dark"] body:has(.feedback-branded-header) #feedbackDeleteModal>div>div{
  background:var(--dp-surface)!important;
  color:var(--dp-text)!important;
  border-color:var(--dp-border)!important;
  box-shadow:0 8px 24px var(--dp-shadow)!important;
}
html[data-theme="dark"] body:has(.feedback-branded-header) .feedback-comment-section,
html[data-theme="dark"] body:has(.feedback-branded-header) #feedbackForm>div:first-of-type{
  background:var(--dp-surface-2)!important;
}
html[data-theme="dark"] body:has(.feedback-branded-header) :is(
  #feedbackPage h1,#feedbackPage h2,#feedbackPage h3,
  #feedbackPage label,#feedbackPage strong,#feedbackPage b,
  #feedbackPage .feedback-reviews-card .text-slate-800
){
  color:var(--dp-text)!important;
}
html[data-theme="dark"] body:has(.feedback-branded-header) :is(
  #feedbackPage p,#feedbackPage small,#feedbackPage .text-slate-700,
  #feedbackPage .text-slate-600,#feedbackPage .text-slate-500,
  #feedbackPage .text-slate-400,#feedbackPage .feedback-page-label
){
  color:var(--dp-text-2)!important;
}
html[data-theme="dark"] body:has(.feedback-branded-header) :is(
  #feedbackComment,#feedbackPage input,#feedbackPage textarea,
  #feedbackPage select
){
  background:var(--dp-input)!important;
  color:var(--dp-text)!important;
  border-color:var(--dp-input-border)!important;
}
html[data-theme="dark"] body:has(.feedback-branded-header) #feedbackComment::placeholder{
  color:var(--dp-muted)!important;
}
html[data-theme="dark"] body:has(.feedback-branded-header) #feedbackComment:focus{
  border-color:var(--dp-accent)!important;
  box-shadow:0 0 0 3px color-mix(in srgb,var(--dp-accent) 18%,transparent)!important;
}
html[data-theme="dark"] body:has(.feedback-branded-header) .feedback-branded-header .feedback-access-card.active{
  background:var(--dp-primary)!important;
  border-color:var(--dp-accent)!important;
  color:#fff!important;
}
html[data-theme="dark"] body:has(.feedback-branded-header) .feedback-branded-header .feedback-access-card.active i{
  color:#fff!important;
}
html[data-theme="dark"] body:has(.feedback-branded-header) .star-button{
  color:var(--dp-muted);
}
html[data-theme="dark"] body:has(.feedback-branded-header) .star-button[aria-checked="true"],
html[data-theme="dark"] body:has(.feedback-branded-header) .star-button.is-active{
  color:var(--dp-warning)!important;
}
html[data-theme="dark"] body:has(.feedback-branded-header) #feedbackStatus{
  color:var(--dp-text)!important;
}
/* Account profile and subscription details */
html[data-theme="dark"] body:has(.profile-page-header) .glass,
html[data-theme="dark"] .profile-plans-section,
html[data-theme="dark"] .profile-plan-tile,
html[data-theme="dark"] .plan-details-dialog,
html[data-theme="dark"] .plan-detail-line,
html[data-theme="dark"] .profile-selected-plan-info,
html[data-theme="dark"] .profile-subscribe-modal,
html[data-theme="dark"] .profile-subscribe-dialog,
html[data-theme="dark"] .profile-inline-email{
  background:var(--dp-surface-2)!important;
  color:var(--dp-text)!important;
  border-color:var(--dp-border)!important;
}
html[data-theme="dark"] .profile-plan-tile :is(h2,h3,h4,strong),
html[data-theme="dark"] .plan-details-dialog :is(h2,h3,h4,strong),
html[data-theme="dark"] .profile-subscribe-modal :is(h2,h3,h4,strong){color:var(--dp-text)!important}
html[data-theme="dark"] .profile-plan-tile :is(p,small,span),
html[data-theme="dark"] .plan-detail-line :is(p,small,span),
html[data-theme="dark"] .profile-subscribe-modal :is(p,small,span),
html[data-theme="dark"] .profile-inline-email :is(span,div,small){color:var(--dp-text-2)!important}

/* Finance, admin and notifications */
html[data-theme="dark"] body:has(.finance-page-header) .glass,
html[data-theme="dark"] .announcement-admin-item,
html[data-theme="dark"] .announcement-form-options,
html[data-theme="dark"] .announcement-form-options{
  background:var(--dp-surface-2)!important;
  color:var(--dp-text)!important;
  border-color:var(--dp-border)!important;
}
html[data-theme="dark"] .announcement-admin-item :is(h2,h3,h4,strong){color:var(--dp-text)!important}
html[data-theme="dark"] .announcement-admin-item :is(p,small,span){color:var(--dp-text-2)!important}

/* Visit assessment and embedded clinical calculators */
html[data-theme="dark"] .assessment-section,
html[data-theme="dark"] .module-card,
html[data-theme="dark"] .assessment-body,
html[data-theme="dark"] .assessment-labs,
html[data-theme="dark"] .assessment-clinical,
html[data-theme="dark"] .assessment-dietary,
html[data-theme="dark"] .calc-card-energy,
html[data-theme="dark"] .calc-card-target,
html[data-theme="dark"] .calc-result-neutral,
html[data-theme="dark"] .calc-result-bmr{
  background:var(--dp-surface-2)!important;
  color:var(--dp-text)!important;
  border-color:var(--dp-border)!important;
}
html[data-theme="dark"] .assessment-section :is(h2,h3,h4,strong,label),
html[data-theme="dark"] .module-card :is(h2,h3,h4,strong){color:var(--dp-text)!important}

/* Weight and measurement history */
html[data-theme="dark"] body:has(#weightTab) .glass,
html[data-theme="dark"] #weightTab,
html[data-theme="dark"] #weightTab tbody tr,
html[data-theme="dark"] #weightTab thead th,
html[data-theme="dark"] .inline-measurement-row,
html[data-theme="dark"] .adherence-badge,
html[data-theme="dark"] #weightTab tbody tr{
  background:var(--dp-surface-2)!important;
  color:var(--dp-text)!important;
  border-color:var(--dp-border)!important;
}
html[data-theme="dark"] #weightTab :is(th,td),

html[data-theme="dark"] #weightTab input,
html[data-theme="dark"] #weightTab select,
html[data-theme="dark"] .inline-measurement-row input,
html[data-theme="dark"] .inline-measurement-row select{
  background:var(--dp-input)!important;color:var(--dp-text)!important;border-color:var(--dp-input-border)!important
}

/* Administration tables and form controls */
html[data-theme="dark"] body:has(.admin-branded-header) .header:not(.admin-branded-header),
html[data-theme="dark"] body:has(.admin-branded-header) .tabs,
html[data-theme="dark"] body:has(.admin-branded-header) .toolbar,
html[data-theme="dark"] body:has(.admin-branded-header) .card,
html[data-theme="dark"] body:has(.admin-branded-header) .check-grid,
html[data-theme="dark"] body:has(.admin-branded-header) .modal,
html[data-theme="dark"] body:has(.admin-branded-header) th,
html[data-theme="dark"] body:has(.admin-branded-header) .stat,
html[data-theme="dark"] body:has(.admin-branded-header) .search{
  background:var(--dp-surface-2)!important;
  color:var(--dp-text)!important;
  border-color:var(--dp-border)!important;
}
html[data-theme="dark"] body:has(.admin-branded-header) :is(td,th,label,.title p,.meta,.state,.confirm-text){color:var(--dp-text-2)!important}
html[data-theme="dark"] body:has(.admin-branded-header) input,
html[data-theme="dark"] body:has(.admin-branded-header) select,
html[data-theme="dark"] body:has(.admin-branded-header) textarea{background:var(--dp-input)!important;color:var(--dp-text)!important;border-color:var(--dp-input-border)!important}

/* Shared light controls embedded in page-specific forms */
html[data-theme="dark"] :is(.patient-fields,.patient-data-fields,.profile-form,.finance-form,.feedback-form,.recipe-form,.food-form,.product-filter-panel,.qc-panel) :is(input,select,textarea){
  background:var(--dp-input)!important;
  color:var(--dp-text)!important;
  border-color:var(--dp-input-border)!important;
}
html[data-theme="dark"] :is(.patient-fields,.patient-data-fields,.profile-form,.finance-form,.feedback-form,.recipe-form,.food-form,.product-filter-panel,.qc-panel) :is(label,p,small,.hint,.field-hint){
  color:var(--dp-text-2)!important;
}

/* Nutrition-support patient day planner */
html[data-theme="dark"] .table-custom,
html[data-theme="dark"] .table-custom tbody td,
html[data-theme="dark"] .day-item,
html[data-theme="dark"] .day-edit-toolbar,
html[data-theme="dark"] .day-edit-btn,
html[data-theme="dark"] .patient-readonly-card{
  background:var(--dp-surface-2)!important;
  color:var(--dp-text-2)!important;
  border-color:var(--dp-border)!important;
}
html[data-theme="dark"] .table-custom th{
  background:var(--dp-surface-3)!important;
  color:var(--dp-text)!important;
  border-color:var(--dp-border)!important;
}
html[data-theme="dark"] .table-custom tbody tr:nth-child(even) td,
html[data-theme="dark"] .table-custom tbody tr:hover td{
  background:var(--dp-surface-3)!important;
}
html[data-theme="dark"] .day-save-btn{
  background:var(--dp-primary)!important;
  color:#fff!important;
}
html[data-theme="dark"] .support-day-locked :is(input,select,textarea){
  background:var(--dp-dark-surface-raised)!important;
  color:var(--dp-muted)!important;
  border-color:var(--dp-border)!important;
}

/* =========================================================
   Central dark-mode completion — product cards and navigation
   These rules intentionally live here, not in page stylesheets.
   ========================================================= */

/* Keep every shared quick-navigation link above decorative layers
   and reliably clickable on touch and pointer devices. */
html body .quick-access-nav{position:relative;z-index:40}
html body .quick-access-track{position:relative;z-index:1;pointer-events:auto}
html body .quick-access-card{
  position:relative;
  z-index:2;
  pointer-events:auto;
  cursor:pointer;
  -webkit-tap-highlight-color:transparent;
}
html body .quick-access-card:focus-visible{
  outline:2px solid var(--dp-accent);
  outline-offset:2px;
}

/* Product library: override legacy page-level hard-coded light surfaces. */
html[data-theme="dark"] body:has(.products-page-header) main>.mx-auto>section,
html[data-theme="dark"] body:has(.products-page-header) #state{
  background:var(--dp-surface)!important;
  color:var(--dp-text)!important;
  border-color:var(--dp-border)!important;
}
html[data-theme="dark"] #categoryFilter,
html[data-theme="dark"] #subcategoryFilter,
html[data-theme="dark"] #searchInput,
html[data-theme="dark"] .field-input,
html[data-theme="dark"] .rich-link-input,
html[data-theme="dark"] .rich-editor-surface,
html[data-theme="dark"] .rich-editor-toolbar :is(button,select,input),
html[data-theme="dark"] body:has(.products-page-header) :is(input,select,textarea){
  background-color:var(--dp-input)!important;
  color:var(--dp-text)!important;
  border-color:var(--dp-input-border)!important;
}
html[data-theme="dark"] body:has(.products-page-header) :is(input,textarea)::placeholder{
  color:var(--dp-muted)!important;
}
html[data-theme="dark"] .product-modern{
  background:var(--dp-surface)!important;
  color:var(--dp-text)!important;
  border-color:var(--dp-border)!important;
  box-shadow:0 5px 18px var(--dp-shadow)!important;
}
html[data-theme="dark"] .product-modern :is(h2,h3,h4,strong,.formula-title-wrap strong){
  color:var(--dp-text)!important;
}
html[data-theme="dark"] .product-modern :is(p,small,span,.product-description,.product-usage p,.product-usage small,.formula-title-wrap span,.metric span,.metric small,.formula-notes){
  color:var(--dp-text-2)!important;
}
html[data-theme="dark"] .product-modern :is(.product-category-pill,.product-usage,.product-formulas,.formula-showcase,.metric,.formula-notes,.empty-formula){
  background:var(--dp-surface-2)!important;
  border-color:var(--dp-border)!important;
}
html[data-theme="dark"] .product-modern .product-symbol,
html[data-theme="dark"] .product-modern .usage-icon,
html[data-theme="dark"] .product-modern .formula-mark,
html[data-theme="dark"] .product-modern .formula-section-title>i{
  background:var(--dp-surface-3)!important;
  color:var(--dp-accent)!important;
}
html[data-theme="dark"] .product-modern .product-category-pill,
html[data-theme="dark"] .product-modern .formula-section-title{
  color:var(--dp-accent)!important;
}
html[data-theme="dark"] .product-modern .nutrition-metrics :is(.metric-kcal,.metric-carb,.metric-protein,.metric-fat){
  background:var(--dp-surface-3)!important;
}
html[data-theme="dark"] .product-modern .nutrition-metrics :is(.metric-kcal,.metric-carb,.metric-protein,.metric-fat) strong{
  color:var(--dp-text)!important;
}
html[data-theme="dark"] .rich-link-dialog,
html[data-theme="dark"] .admin-modal,
html[data-theme="dark"] .admin-modal>form>.mt-7.flex.flex-col-reverse{
  background:var(--dp-surface)!important;
  color:var(--dp-text)!important;
  border-color:var(--dp-border)!important;
}
html[data-theme="dark"] .rich-editor-toolbar{
  background:var(--dp-surface-2)!important;
  border-color:var(--dp-border)!important;
}
html[data-theme="dark"] .rich-link-icon{
  background:var(--dp-surface-3)!important;
  color:var(--dp-accent)!important;
}

/* Dashboard surfaces: these were hard-coded light in app.css and must
   resolve through the same semantic tokens as every other page. */
html[data-theme="dark"] .dashboard-notifications-section,
html[data-theme="dark"] .dashboard-announcements-section,
html[data-theme="dark"] .dashboard-announcement-card,
html[data-theme="dark"] .dp-announcement-dialog,
html[data-theme="dark"] .dashboard-notification-row{
  background:var(--dp-surface)!important;
  color:var(--dp-text)!important;
  border-color:var(--dp-border)!important;
  box-shadow:0 8px 24px var(--dp-shadow)!important;
}
html[data-theme="dark"] .dashboard-notifications-header,
html[data-theme="dark"] .dashboard-notification-row{
  border-color:var(--dp-border)!important;
}
html[data-theme="dark"] .dashboard-notifications-section :is(h1,h2,h3,h4,strong,.dashboard-notification-patient),
html[data-theme="dark"] .dashboard-announcements-section :is(h1,h2,h3,h4,strong),
html[data-theme="dark"] .dashboard-announcement-card :is(h1,h2,h3,h4,strong){
  color:var(--dp-text)!important;
}
html[data-theme="dark"] .dashboard-notifications-section :is(p,small,span,.dashboard-notification-action,.dashboard-notification-date),
html[data-theme="dark"] .dashboard-announcements-section :is(p,small,span),
html[data-theme="dark"] .dashboard-announcement-card :is(p,small,span){
  color:var(--dp-text-2)!important;
}
html[data-theme="dark"] .dashboard-all-notifications{color:var(--dp-accent)!important}
html[data-theme="dark"] .dashboard-notification-row-icon,
html[data-theme="dark"] .dashboard-announcement-card-top,
html[data-theme="dark"] .dashboard-announcement-type{
  background:var(--dp-surface-3)!important;
  color:var(--dp-accent)!important;
  border-color:var(--dp-border)!important;
}
html[data-theme="dark"] .dashboard-announcement-dialog,
html[data-theme="dark"] .dp-announcement-dialog :is(input,select,textarea){
  background:var(--dp-input)!important;
  color:var(--dp-text)!important;
  border-color:var(--dp-input-border)!important;
}

/* Shared application surfaces used by multiple page modules. */
html[data-theme="dark"] body :is(.filter-panel,.search-panel,.stats-card,.stat-card,.form-card,.content-card,.section-card,.table-container,.table-wrapper,.empty-state,.empty-formula,.modal-content,.modal-dialog,.dropdown-menu,.popover-content){
  background-color:var(--dp-surface)!important;
  color:var(--dp-text)!important;
  border-color:var(--dp-border)!important;
}
html[data-theme="dark"] body :is(.filter-panel,.search-panel,.stats-card,.stat-card,.form-card,.content-card,.section-card,.table-container,.table-wrapper,.empty-state,.modal-content,.modal-dialog,.dropdown-menu,.popover-content) :is(h1,h2,h3,h4,strong,label){
  color:var(--dp-text)!important;
}
html[data-theme="dark"] body :is(.filter-panel,.search-panel,.stats-card,.stat-card,.form-card,.content-card,.section-card,.table-container,.table-wrapper,.empty-state,.modal-content,.modal-dialog,.dropdown-menu,.popover-content) :is(p,small,span){
  color:var(--dp-text-2)!important;
}

/* Normalize remaining generic white utility surfaces and their contents. */
html[data-theme="dark"] body :is(.bg-white,.bg-white\/95,.bg-white\/90){
  background-color:var(--dp-surface)!important;
  color:var(--dp-text)!important;
}
html[data-theme="dark"] body :is(.bg-white,.bg-white\/95,.bg-white\/90) :is(h1,h2,h3,h4,p,span,label,strong,small){
  color:inherit;
}


/* Consolidated page dark-mode rule from css/diet.css */
/* Diet Library — page-specific dark-mode exceptions only.
   Global surfaces, text, borders and forms stay in theme.css. */
html[data-theme="dark"] .glass{background:rgba(23,33,31,.96)!important;border-color:var(--dp-border)!important;box-shadow:0 8px 30px rgba(0,0,0,.22)!important}

/* Consolidated page dark-mode rule from css/diet.css */
html[data-theme="dark"] .food-name-cell{color:var(--dp-text)!important}

/* Consolidated page dark-mode rule from css/diet.css */
html[data-theme="dark"] .food-name-en{color:var(--dp-muted)!important}

/* Consolidated page dark-mode rule from css/diet.css */
/* Semantic exceptions for the diet cards. */
html[data-theme="dark"] #dietGrid .bg-amber-50,
html[data-theme="dark"] #dietGrid .bg-amber-50\/60{background:#3a3019!important}

/* Consolidated page dark-mode rule from css/diet.css */
html[data-theme="dark"] #dietGrid .text-amber-600,
html[data-theme="dark"] #dietGrid .text-amber-700{color:#f3cf63!important}

/* Consolidated page dark-mode rule from css/diet.css */
html[data-theme="dark"] #dietGrid .text-amber-900{color:#f6df9a!important}

/* Consolidated page dark-mode rule from css/diet.css */
html[data-theme="dark"] #dietGrid .bg-emerald-50,
html[data-theme="dark"] #dietGrid .bg-emerald-50\/70{background:#17352e!important}

/* Consolidated page dark-mode rule from css/diet.css */
html[data-theme="dark"] #dietGrid .text-emerald-700,
html[data-theme="dark"] #dietGrid .text-emerald-900{color:#8fe3c5!important}

/* Consolidated page dark-mode rule from css/diet.css */
html[data-theme="dark"] #dietGrid .bg-indigo-50{background:#25234a!important}

/* Consolidated page dark-mode rule from css/diet.css */
html[data-theme="dark"] #dietGrid .text-indigo-600{color:#aeb5ff!important}

/* Consolidated page dark-mode rule from css/diet.css */
html[data-theme="dark"] #dietGrid .bg-slate-50\/70{background:#1b2927!important;border-top:1px solid var(--dp-border)!important}

/* Consolidated page dark-mode rule from css/diet.css */
html[data-theme="dark"] #dietGrid .ring-slate-200{--tw-ring-color:#3c514d!important}

/* Consolidated page dark-mode rule from css/diet.css */
/* Editor uses an arbitrary light background not covered by the global palette. */
html[data-theme="dark"] #editor > div{background:var(--dp-bg)!important}

/* Consolidated page dark-mode rule from css/diet.css */
html[data-theme="dark"] #editor .bg-slate-50\/60{background:#182522!important}

/* Consolidated page dark-mode rule from css/diet.css */
/* Food picker selected state. */
html[data-theme="dark"] #foodPicker .bg-brand-50\/60{background:#17342f!important}

/* Consolidated page dark-mode rule from css/diet.css */
html[data-theme="dark"] #foodPicker .border-brand-100,
html[data-theme="dark"] #foodPicker .border-brand-200{border-color:#315c55!important}

/* Consolidated page dark-mode rule from css/diet.css */
/* Viewer/picker/delete surfaces needing page-specific contrast. */
html[data-theme="dark"] #foodPicker > div,
html[data-theme="dark"] #deleteConfirmModal > div{background:var(--dp-surface)!important;color:var(--dp-text)!important}

/* Consolidated page dark-mode rule from css/diet.css */
html[data-theme="dark"] #deleteConfirmModal .bg-slate-100,
html[data-theme="dark"] #cancelEditor{background:var(--dp-surface-3)!important;color:var(--dp-text)!important}

/* Consolidated page dark-mode rule from css/diet.css */
html[data-theme="dark"] .diet-list-item{background:#17211f;border-color:var(--dp-border);box-shadow:0 3px 12px rgba(0,0,0,.15)}

/* Consolidated page dark-mode rule from css/diet.css */
html[data-theme="dark"] #dietGrid .diet-list-item:nth-child(odd){background:#17211f}

/* Consolidated page dark-mode rule from css/diet.css */
html[data-theme="dark"] #dietGrid .diet-list-item:nth-child(even){background:#1d302b}

/* Consolidated page dark-mode rule from css/diet.css */
html[data-theme="dark"] .diet-list-title{color:var(--dp-text)}

/* Consolidated page dark-mode rule from css/diet.css */
html[data-theme="dark"] .diet-list-logo{background:#203a35;color:#75c9b8}

/* Consolidated page dark-mode rule from css/diet.css */
html[data-theme="dark"] .diet-list-publisher{color:var(--dp-muted)}

/* Consolidated page dark-mode rule from css/diet.css */
html[data-theme="dark"] .diet-list-publisher strong{color:#d0ddd8}

/* Consolidated page dark-mode rule from css/diet.css */
html[data-theme="dark"] .diet-list-copy,html[data-theme="dark"] .diet-list-edit{background:#24312e;color:var(--dp-text);border-color:var(--dp-border)}

/* Consolidated page dark-mode rule from css/diet.css */
html[data-theme="dark"] .diet-list-icon-btn{background:#302222;border-color:#563737;color:#f1a0a0}

/* Consolidated page dark-mode rule from css/patient-profile.css */
html[data-theme="dark"] .support-day-delete-box{background:#172a2b}

/* Consolidated page dark-mode rule from css/patient-profile.css */
html[data-theme="dark"] .support-day-delete-box h3{color:#edf7f4}

/* Consolidated page dark-mode rule from css/patient-profile.css */
html[data-theme="dark"] .support-day-delete-box p{color:#bbceca}

/* Consolidated page dark-mode rule from css/patient-profile.css */
html[data-theme="dark"] .support-day-delete-actions [data-delete-cancel]{background:#263c3d;color:#dcebe8}

/* Consolidated page dark-mode rule from css/recipe.css */
html[data-theme="dark"] .recipe-modal {
    background: rgba(0, 0, 0, 0.68);
}

/* Final contrast pass — dark mode */
html[data-theme="dark"] #mix-result{
  background:#1d4038!important;
  color:#a9f0d6!important;
  border:1px solid #3e7568!important;
}

/* =========================================================
   Central compatibility layer for legacy page-specific UI.
   All theme colors stay here; page CSS keeps layout only.
   ========================================================= */
html[data-theme="dark"] body{
  background-color:var(--dp-bg)!important;
  color:var(--dp-text)!important;
}
html[data-theme="dark"] body :is(
  .patient-name-bar,.dashboard-card,.patient-module-panel,.measurements-panel,
  .measurement-summary-card,.patient-data-content,.patient-finance-content,
  .patient-finance-empty,.patient-module-tab:not(.is-active),
  .embedded-calculator,.energy-workspace,.macro-workspace,.target-adjustment,
  .macro-item,.result-metric,.result-equation,.patient-stat,.patient-row,
  .product-modern,.product-card,.formula-item,.rich-link-dialog,
  .rich-editor-surface,.rich-editor-toolbar,.admin-modal,.admin-modal>form,
  .assessment-section,.assessment-body,.assessment-labs,.assessment-clinical,
  .assessment-dietary,.module-card,.qc-panel,.qc-result,.qc-note,
  .highlight-box,.support-content,.support-days,.day-edit-toolbar,
  .detail-patient-area,.table-wrap,.table-container,.summary-card,.metric-card,
  .auth-card,.login-card,.register-card,.password-card,.profile-card,
  .profile-section,.finance-card,.feedback-card,.article-card,.recipe-card
){
  background-color:var(--dp-surface)!important;
  color:var(--dp-text)!important;
  border-color:var(--dp-border)!important;
  box-shadow:0 2px 12px var(--dp-shadow)!important;
}
html[data-theme="dark"] body :is(
  .patient-name-bar,.dashboard-card,.patient-module-panel,.measurements-panel,
  .measurement-summary-card,.patient-data-content,.patient-finance-content,
  .patient-module-tab:not(.is-active),.embedded-calculator,.energy-workspace,
  .macro-workspace,.target-adjustment,.patient-stat,.patient-row,
  .product-modern,.product-card,.formula-item,.rich-link-dialog,
  .rich-editor-surface,.rich-editor-toolbar,.assessment-section,.module-card,
  .qc-panel,.qc-result,.qc-note,.highlight-box,.support-content,.support-days,
  .day-edit-toolbar,.detail-patient-area,.table-wrap,.table-container,
  .summary-card,.metric-card,.auth-card,.login-card,.register-card,
  .password-card,.profile-card,.profile-section,.finance-card,.feedback-card,
  .article-card,.recipe-card
) :is(h1,h2,h3,h4,h5,strong,b,label,th){
  color:var(--dp-text)!important;
}
html[data-theme="dark"] body :is(
  .patient-name-bar,.dashboard-card,.patient-module-panel,.measurements-panel,
  .measurement-summary-card,.patient-data-content,.patient-finance-content,
  .patient-module-tab:not(.is-active),.embedded-calculator,.energy-workspace,
  .macro-workspace,.target-adjustment,.patient-stat,.patient-row,
  .product-modern,.product-card,.formula-item,.rich-link-dialog,
  .rich-editor-surface,.rich-editor-toolbar,.assessment-section,.module-card,
  .qc-panel,.qc-result,.qc-note,.highlight-box,.support-content,.support-days,
  .day-edit-toolbar,.detail-patient-area,.table-wrap,.table-container,
  .summary-card,.metric-card,.auth-card,.login-card,.register-card,
  .password-card,.profile-card,.profile-section,.finance-card,.feedback-card,
  .article-card,.recipe-card
) :is(p,small,span,.muted,.hint,.description,.subtitle){
  color:var(--dp-text-2)!important;
}

/* Food library, product library and data tables */
html[data-theme="dark"] .products-table th:first-child,
html[data-theme="dark"] .products-table td:first-child,
html[data-theme="dark"] .products-table thead th:first-child,
html[data-theme="dark"] .patient-row:nth-child(even),
html[data-theme="dark"] .patient-stat,
html[data-theme="dark"] .patient-stat.is-selected{
  background:var(--dp-surface-2)!important;
  color:var(--dp-text)!important;
  border-color:var(--dp-border)!important;
}
html[data-theme="dark"] .field-input,
html[data-theme="dark"] .rich-link-input,
html[data-theme="dark"] .rich-editor-surface,
html[data-theme="dark"] .rich-editor-toolbar :is(button,select),
html[data-theme="dark"] .admin-modal>form>.mt-7.flex.flex-col-reverse{
  background:var(--dp-input)!important;
  color:var(--dp-text)!important;
  border-color:var(--dp-input-border)!important;
}
html[data-theme="dark"] .formula-item-title,
html[data-theme="dark"] .product-modern :is(h1,h2,h3,h4,strong),
html[data-theme="dark"] .product-card :is(h1,h2,h3,h4,strong){
  color:var(--dp-text)!important;
}
html[data-theme="dark"] .product-modern :is(p,small,.text-slate-700,.text-slate-500),
html[data-theme="dark"] .product-card :is(p,small,.text-slate-700,.text-slate-500){
  color:var(--dp-text-2)!important;
}

/* Visit and nutrition-support workspaces */
html[data-theme="dark"] .assessment-section,
html[data-theme="dark"] .assessment-body,
html[data-theme="dark"] .assessment-labs,
html[data-theme="dark"] .assessment-clinical,
html[data-theme="dark"] .assessment-dietary,
html[data-theme="dark"] .module-card{
  background:var(--dp-surface)!important;
  border-color:var(--dp-border)!important;
  color:var(--dp-text)!important;
}
html[data-theme="dark"] .assessment-section :is(h1,h2,h3,h4,strong,label),
html[data-theme="dark"] .module-card :is(h1,h2,h3,h4,strong,label){
  color:var(--dp-text)!important;
}
html[data-theme="dark"] .assessment-section :is(p,small,span),
html[data-theme="dark"] .module-card :is(p,small,span){
  color:var(--dp-text-2)!important;
}
html[data-theme="dark"] .table-custom th,
html[data-theme="dark"] .ref-table th{
  background:var(--dp-surface-3)!important;
  color:var(--dp-text)!important;
  border-color:var(--dp-border)!important;
}
html[data-theme="dark"] .table-custom td,
html[data-theme="dark"] .ref-table td,
html[data-theme="dark"] .ref-table tr:nth-child(even){
  background:var(--dp-surface)!important;
  color:var(--dp-text)!important;
  border-color:var(--dp-border)!important;
}
html[data-theme="dark"] .qc-tab,
html[data-theme="dark"] .qc-panel,
html[data-theme="dark"] .qc-result,
html[data-theme="dark"] .qc-note,
html[data-theme="dark"] .highlight-box{
  background-color:var(--dp-surface)!important;
  color:var(--dp-text)!important;
  border-color:var(--dp-border)!important;
}

html[data-theme="dark"] .page-header :is(h1,h2,h3,p,span){
  color:var(--dp-text)!important;
}
html[data-theme="dark"] .page-header .page-header-icon{
  background:var(--dp-primary)!important;
  color:#fff!important;
}
html[data-theme="dark"] .back-btn,
html[data-theme="dark"] .qc-tab{
  color:var(--dp-text)!important;
}

/* Keep branded headers, active primary actions, and semantic status colors intact. */
html[data-theme="dark"] :is(
  .patient-profile-page-header,.food-page-header,.profile-page-header,
  .finance-page-header,.about-branded-header,.patient-page-header,
  .feedback-branded-header,.recipe-page-header,.support-header,.nsp-page-header
){
  color:#fff!important;
}
html[data-theme="dark"] :is(
  .patient-profile-page-header,.food-page-header,.profile-page-header,
  .finance-page-header,.about-branded-header,.patient-page-header,
  .feedback-branded-header,.recipe-page-header,.support-header,.nsp-page-header
) :is(h1,h2,h3,p,span,i){
  color:inherit!important;
}
html[data-theme="dark"] :is(button,.btn-primary,.dashboard-primary-btn,.measurements-add-button,.followup-add-button).bg-emerald-600,
html[data-theme="dark"] :is(button,.btn-primary,.dashboard-primary-btn,.measurements-add-button,.followup-add-button).bg-green-600{
  color:#fff!important;
}


/* =========================================================
   Central page adapter — patient profile and embedded visit
   Theme colors are owned here; page stylesheets own layout only.
   ========================================================= */

/* Patient profile: workspace surfaces */
html[data-theme="dark"] :is(
  .patient-name-bar,.dashboard-card,.patient-module-panel,.measurements-panel,
  .measurements-table-wrap,.measurement-summary-card,.patient-finance-content,
  .patient-data-content,.patient-finance-empty,.followup-days-card,
  .visit-embedded-panel,.support-day-delete-box
){
  background:var(--dp-surface)!important;
  color:var(--dp-text)!important;
  border-color:var(--dp-border)!important;
  box-shadow:0 2px 12px var(--dp-shadow)!important;
}
html[data-theme="dark"] :is(
  #patientName,.dashboard-card-head h3,.patient-finance-heading strong,
  .patient-data-title strong,.measurements-table-heading h3,
  .followup-days-heading strong,.patient-module-tab-copy strong,
  .patient-module-tab-copy small
){color:var(--dp-text)!important}
html[data-theme="dark"] :is(
  .dashboard-card-head p,.patient-finance-heading small,
  .patient-data-title small,.measurements-access-status,
  .measurements-table-heading p,.measurement-summary-label,
  .measurement-summary-note,.followup-state,.followup-days-heading small,
  .patient-finance-access-note,.patient-fields label
){color:var(--dp-text-2)!important}

/* Patient module tabs: readable labels in both active and inactive states. */
html[data-theme="dark"] .patient-module-tab{
  background:var(--dp-tab-bg)!important;
  color:var(--dp-tab-text)!important;
  border-color:var(--dp-tab-border)!important;
}
html[data-theme="dark"] .patient-module-tab :is(strong,small){
  color:var(--dp-tab-text)!important;
}
html[data-theme="dark"] .patient-module-tab:hover{
  background:var(--dp-surface-3)!important;
  border-color:var(--dp-primary)!important;
}
html[data-theme="dark"] .patient-module-tab.is-active{
  background:var(--dp-tab-active-bg)!important;
  color:var(--dp-tab-active-text)!important;
  border-color:var(--dp-primary)!important;
  box-shadow:inset 0 0 0 1px var(--dp-primary)!important;
}
html[data-theme="dark"] .patient-module-tab.is-active :is(strong,small){
  color:var(--dp-tab-active-text)!important;
}

/* Patient data, finance, measurements and plan controls. */
html[data-theme="dark"] :is(
  .patient-fields input,.patient-fields select,.patient-fields textarea,
  .patient-data-fields input,.patient-data-fields select,.patient-data-fields textarea,
  .patient-finance-fields input,.patient-finance-fields select,
  .inline-measurement-row input,.inline-measurement-row select
){
  background:var(--dp-input)!important;
  color:var(--dp-text)!important;
  border-color:var(--dp-input-border)!important;
}
html[data-theme="dark"] :is(
  .patient-finance-readonly output,.patient-finance-discounted output,
  .patient-finance-empty,.finance-state,.followup-day-row,
  .followup-day-open,.followup-day-number,.followup-day-title
){
  background:var(--dp-surface-2)!important;
  color:var(--dp-text-2)!important;
  border-color:var(--dp-border)!important;
}
html[data-theme="dark"] .followup-day-open.is-active .followup-day-title{
  color:var(--dp-accent)!important;
}
html[data-theme="dark"] .followup-day-open.is-active .followup-day-number{
  background:var(--dp-primary)!important;
  color:#fff!important;
}
html[data-theme="dark"] .followup-day-row:has(.followup-day-open.is-active){
  background:var(--dp-surface-3)!important;
  border-color:var(--dp-primary)!important;
}
html[data-theme="dark"] :is(
  .measurements-table th,.measurements-table td,
  .measurements-table tbody tr,.measurements-table tbody tr:nth-child(even)
){
  background:var(--dp-surface)!important;
  color:var(--dp-text-2)!important;
  border-color:var(--dp-border)!important;
}
html[data-theme="dark"] .measurements-table th{
  background:var(--dp-surface-3)!important;
  color:var(--dp-text)!important;
}
html[data-theme="dark"] .measurement-summary-value,
html[data-theme="dark"] .measurements-table .measurement-weight{
  color:var(--dp-text)!important;
}
html[data-theme="dark"] :is(
  .patient-finance-readonly output,.patient-finance-discounted output
){background:var(--dp-surface-3)!important;color:var(--dp-text)!important}

/* Patient energy calculator — centralized dark palette using shared semantic tokens. */
html[data-theme="dark"] #patientEnergyPanel{
  background:var(--dp-bg)!important;
  color:var(--dp-text)!important;
  border-color:var(--dp-border)!important;
}
html[data-theme="dark"] #patientEnergyPanel #calcTab :is(
  .energy-workspace,.macro-workspace,.patient-inputs>div,.activity-row,
  .energy-results>div,.target-energy,.target-adjustment,.equation-switch
){
  background:var(--dp-surface)!important;
  color:var(--dp-text)!important;
  border-color:var(--dp-border)!important;
}
html[data-theme="dark"] #patientEnergyPanel #calcTab :is(
  .workspace-heading h3,.energy-results strong,.target-energy strong,
  .macro-name,.macro-grams strong,.macro-section-label,.result-equation strong
){color:var(--dp-text)!important}
html[data-theme="dark"] #patientEnergyPanel #calcTab :is(
  .workspace-step,.workspace-heading p,.energy-results small,.energy-results em,
  .target-energy small,.target-adjustment label,.macro-section-label span,
  .macro-percent,.macro-grams small,.macro-footer>span,
  .patient-inputs label,.activity-row label
){color:var(--dp-text-2)!important}
html[data-theme="dark"] #patientEnergyPanel #calcTab :is(
  .patient-inputs input,.patient-inputs select,.activity-row select,
  .target-adjustment input,.macro-percent input
){
  background:var(--dp-input)!important;
  color:var(--dp-text)!important;
  border-color:var(--dp-input-border)!important;
}
html[data-theme="dark"] #patientEnergyPanel #calcTab :is(
  #eqBtnMifflin.bg-white,#eqBtnSchofield.bg-white
){
  background:var(--dp-surface-3)!important;
  color:var(--dp-accent)!important;
  border-color:var(--dp-border)!important;
}
html[data-theme="dark"] #patientEnergyPanel #calcTab :is(
  .energy-results .primary,.target-energy
){
  background:color-mix(in srgb,var(--dp-success) 13%,var(--dp-surface))!important;
  border-color:var(--dp-success)!important;
}
html[data-theme="dark"] #patientEnergyPanel #calcTab .macro-item.protein{
  background:color-mix(in srgb,var(--dp-success) 15%,var(--dp-surface))!important;
  border-color:color-mix(in srgb,var(--dp-success) 38%,var(--dp-border))!important;
}
html[data-theme="dark"] #patientEnergyPanel #calcTab .macro-item.carbs{
  background:color-mix(in srgb,var(--dp-info) 15%,var(--dp-surface))!important;
  border-color:color-mix(in srgb,var(--dp-info) 38%,var(--dp-border))!important;
}
html[data-theme="dark"] #patientEnergyPanel #calcTab .macro-item.fats{
  background:color-mix(in srgb,var(--dp-warning) 15%,var(--dp-surface))!important;
  border-color:color-mix(in srgb,var(--dp-warning) 38%,var(--dp-border))!important;
}
html[data-theme="dark"] #patientEnergyPanel #calcTab .macro-alert{
  background:color-mix(in srgb,var(--dp-danger) 15%,var(--dp-surface))!important;
  color:var(--dp-danger)!important;
  border-color:color-mix(in srgb,var(--dp-danger) 40%,var(--dp-border))!important;
}

/* Visit editor: both standalone and patient-profile iframe share the same theme. */
html[data-theme="dark"] :is(
  .embedded-diet-plan,#visitContent,#dietPlanContent,#exchangePlanContent,
  .embedded-diet-plan>main
){
  background:var(--dp-bg)!important;
  color:var(--dp-text)!important;
}
html[data-theme="dark"] :is(
  .visit-module-grid .module-card,.visit-module-grid #dietPlanCard,
  .visit-module-grid #exchangePlanCard,.visit-module-grid #assessmentCard,
  .assessment-section,.assessment-body,.assessment-labs,
  .assessment-clinical,.assessment-dietary,.exchange-plan-module,
  .calc-card,.calc-result-neutral,.calc-result-bmr,.calc-result-tdee,
  .calc-result-group
){
  background:var(--dp-surface)!important;
  color:var(--dp-text)!important;
  border-color:var(--dp-border)!important;
  box-shadow:0 2px 12px var(--dp-shadow)!important;
}
html[data-theme="dark"] :is(
  .visit-module-grid .module-card h1,.visit-module-grid .module-card h2,
  .visit-module-grid .module-card h3,.visit-module-grid .module-card h4,
  .visit-module-grid .module-card strong,.assessment-section :is(h2,h3,h4,strong,label),
  .embedded-diet-plan :is(h1,h2,h3,h4,h5,strong,b)
){color:var(--dp-text)!important}
html[data-theme="dark"] :is(
  .visit-module-grid .module-card p,.assessment-section :is(p,small,span),
  .embedded-diet-plan .text-slate-400,.embedded-diet-plan .text-slate-500
){color:var(--dp-text-2)!important}
html[data-theme="dark"] :is(
  .visit-module-grid .module-card>div>div:first-child
){
  background:var(--dp-surface-3)!important;
  color:var(--dp-accent)!important;
}
html[data-theme="dark"] .visit-access-card:not(.active){
  background:rgba(255,255,255,.08)!important;
  color:var(--dp-text)!important;
  border-color:rgba(255,255,255,.16)!important;
}

/* Dynamic days, meals, macro summaries and editable fields inside visit.html. */
html[data-theme="dark"] #visitContent :is(
  .bg-white,.day-card,.day-card-body,.day-summary,.day-meal,.meal-card,
  .meal-row,.meal-table-wrap,.day-empty-state,.day-macros-grid>div,
  .day-panel,.day-summary-card
),
html[data-theme="dark"] #daysContainer :is(
  .day-card,.day-card-body,.day-summary,.day-meal,.meal-card,
  .meal-row,.meal-table-wrap,.day-empty-state,.day-macros-grid>div
){
  background:var(--dp-surface)!important;
  color:var(--dp-text)!important;
  border-color:var(--dp-border)!important;
  box-shadow:none!important;
}
html[data-theme="dark"] #visitContent :is(
  .day-card-head,.day-card-header,.day-meal-header,.meal-header,
  .meal-items-table th,.day-macros-grid>div>div:last-child
),
html[data-theme="dark"] #daysContainer :is(
  .day-card-head,.day-card-header,.day-meal-header,.meal-header,
  .meal-items-table th,.day-macros-grid>div>div:last-child
){
  background:var(--dp-surface-3)!important;
  color:var(--dp-text)!important;
  border-color:var(--dp-border)!important;
}
html[data-theme="dark"] #visitContent :is(
  .day-summary-heading strong,.day-macros-grid strong,.day-micros-row strong,
  .day-micros-row b,.meal-food-name,.day-card-title
){color:var(--dp-text)!important}
html[data-theme="dark"] #visitContent :is(
  .day-summary-heading span,.day-macros-grid span,.day-micros-row small,
  .day-card-meta,.meal-items-count,.meal-items-table td,
  .day-empty-state,.day-notes-wrap>span
){color:var(--dp-text-2)!important}
html[data-theme="dark"] #visitContent :is(
  #daysContainer input,#daysContainer select,#daysContainer textarea,
  #daysContainer .day-title-input,#daysContainer .day-note-input,
  #daysContainer .meal-title-input,#daysContainer .meal-items-table input,
  .exchange-plan-module input,.exchange-plan-module select,
  .exchange-plan-module textarea
){
  background:var(--dp-input)!important;
  color:var(--dp-text)!important;
  border-color:var(--dp-input-border)!important;
}
html[data-theme="dark"] #visitContent :is(
  .day-card-meta,.meal-items-count,.day-micros-row small
){color:var(--dp-text-2)!important}
html[data-theme="dark"] #visitContent :is(
  .meal-items-table,.meal-items-table th,.meal-items-table td,
  .day-macros-grid>div,.day-card,.day-meal,.meal-card
){border-color:var(--dp-border)!important}
html[data-theme="dark"] .embedded-diet-plan .bg-amber-50{
  background:#3a2d17!important;border-color:#66502a!important;
}
html[data-theme="dark"] .embedded-diet-plan .text-amber-600,
html[data-theme="dark"] .embedded-diet-plan .text-amber-800{color:#E0A43B!important}

/* Canonical embedded-plan controls and labels.
   These selectors intentionally outrank legacy visit.css colors without changing layout. */
html[data-theme="dark"] #visitContent .visit-module-grid .module-card,
html[data-theme="dark"] #visitContent #dietPlanCard,
html[data-theme="dark"] #visitContent #exchangePlanCard{
  background:var(--dp-surface)!important;
  color:var(--dp-text)!important;
  border-color:var(--dp-border)!important;
}
html[data-theme="dark"] #visitContent .visit-module-grid .module-card :is(h1,h2,h3,h4,strong){
  color:var(--dp-text)!important;
}
html[data-theme="dark"] #visitContent .visit-module-grid .module-card :is(p,small,span){
  color:var(--dp-text-2)!important;
}
html[data-theme="dark"] #visitContent #daysContainer :is(
  .day-card-header,.meal-card-header,.meal-items-table th,
  .day-macros-grid>div>div:last-child
){
  background:var(--dp-surface-3)!important;
  color:var(--dp-text)!important;
  border-color:var(--dp-border)!important;
}
html[data-theme="dark"] #visitContent #daysContainer :is(
  .day-card-actions button:not(.day-save-btn):not(.day-fixed-meal-btn),
  .meal-card-actions button:not(.meal-add-food-btn)
){
  background:var(--dp-surface-2)!important;
  color:var(--dp-text)!important;
  border-color:var(--dp-input-border)!important;
}
html[data-theme="dark"] #visitContent #daysContainer :is(
  .day-title-input,.day-note-input,.meal-title-input,
  .meal-items-table input:not([type=checkbox])
){
  background:var(--dp-input)!important;
  color:var(--dp-text)!important;
  border-color:var(--dp-input-border)!important;
}
html[data-theme="dark"] #visitContent #daysContainer :is(
  .day-summary-heading strong,.day-macros-grid>div span,
  .day-macros-grid>div>div:nth-child(2) span:first-child,
  .meal-food-name,.meal-title-input,.day-card-title
){
  color:var(--dp-text)!important;
}
html[data-theme="dark"] #visitContent #daysContainer :is(
  .day-card-meta,.day-summary-heading span,.day-micros-row,
  .day-micros-row span,.day-micros-row small,.day-notes-wrap>span,
  .meal-items-table td,.meal-items-count,.meal-quantity span,
  .meal-empty-state,.day-empty-state
){
  color:var(--dp-text-2)!important;
}
html[data-theme="dark"] #visitContent #daysContainer :is(
  .day-card,.day-card-body,.day-summary,.day-macros-grid>div,
  .day-meals-list,.meal-card,.meal-card-header,.meal-table-wrap,
  .meal-items-table,.meal-items-table td
){
  border-color:var(--dp-border)!important;
}
html[data-theme="dark"] #visitContent #exchangePlanContent,
html[data-theme="dark"] #visitContent .exchange-plan-module,
html[data-theme="dark"] #visitContent .exchange-plan-module>section{
  background:var(--dp-surface)!important;
  color:var(--dp-text)!important;
  border-color:var(--dp-border)!important;
}
html[data-theme="dark"] #visitContent .exchange-plan-module :is(h1,h2,h3,h4,strong,label,th){
  color:var(--dp-text)!important;
}
html[data-theme="dark"] #visitContent .exchange-plan-module :is(p,small,span,td){
  color:var(--dp-text-2)!important;
}
html[data-theme="dark"] #visitContent .exchange-plan-module :is(input,select,textarea){
  background:var(--dp-input)!important;
  color:var(--dp-text)!important;
  border-color:var(--dp-input-border)!important;
}

/* The embedded page is a same-origin document: it reads the shared theme key. */
html[data-theme="dark"].visit-embedded,
html[data-theme="dark"].visit-embedded body,
html[data-theme="dark"].visit-embedded body>main{
  background:var(--dp-bg)!important;
  color:var(--dp-text)!important;
}

/* Print output intentionally remains white and is not part of the screen theme. */
@media print{
  html[data-theme="dark"] .diet-preview,
  html[data-theme="dark"] .embedded-diet-plan{
    background:#fff!important;
    color:#111827!important;
  }
}


/* Central dark palette — recipe index, editor and reader.
   Layout stays in recipe.css; this file is the sole dark color authority. */
html[data-theme="dark"] #grid.recipe-list>.recipe-list-row{
  background:var(--dp-surface)!important;
  color:var(--dp-text)!important;
  border-color:var(--dp-border)!important;
  box-shadow:0 1px 4px var(--dp-shadow)!important;
}
html[data-theme="dark"] #grid.recipe-list>.recipe-list-row:nth-child(even){
  background:var(--dp-surface-2)!important;
}
html[data-theme="dark"] #grid.recipe-list>.recipe-list-row:hover{
  background:var(--dp-surface-3)!important;
  border-color:var(--dp-primary)!important;
}
html[data-theme="dark"] #grid .recipe-list-logo{
  background:var(--dp-surface-3)!important;
  color:var(--dp-accent)!important;
}
html[data-theme="dark"] #grid .recipe-list-name h2{color:var(--dp-text)!important}
html[data-theme="dark"] #grid .recipe-list-name span,
html[data-theme="dark"] #grid .recipe-list-basis,
html[data-theme="dark"] #grid .recipe-list-author{color:var(--dp-text-2)!important}
html[data-theme="dark"] #grid .recipe-list-calories{color:var(--dp-success)!important}
html[data-theme="dark"] #grid .recipe-list-calories i{color:var(--dp-warning)!important}
html[data-theme="dark"] #grid .recipe-list-view{
  background:var(--dp-primary)!important;
  border-color:var(--dp-primary)!important;
  color:#fff!important;
}
html[data-theme="dark"] #grid .recipe-list-icon-btn{
  background:var(--dp-surface-2)!important;
  border-color:var(--dp-border)!important;
  color:var(--dp-text-2)!important;
}
html[data-theme="dark"] #grid .recipe-list-delete{color:var(--dp-danger)!important}
html[data-theme="dark"] #search,
html[data-theme="dark"] .recipe-modal .field-input,
html[data-theme="dark"] .recipe-modal .rich-editor{
  background:var(--dp-input)!important;
  color:var(--dp-text)!important;
  border-color:var(--dp-input-border)!important;
}
html[data-theme="dark"] .recipe-modal>div>div,
html[data-theme="dark"] .recipe-modal .bg-slate-50,
html[data-theme="dark"] .recipe-modal .nutrition-basis,
html[data-theme="dark"] .recipe-modal .editor-shell,
html[data-theme="dark"] .recipe-modal .editor-toolbar{
  background:var(--dp-surface)!important;
  color:var(--dp-text)!important;
  border-color:var(--dp-border)!important;
}
html[data-theme="dark"] .recipe-modal .editor-toolbar{background:var(--dp-surface-2)!important}
html[data-theme="dark"] .recipe-modal :is(h2,h3,.font-extrabold){color:var(--dp-text)!important}
html[data-theme="dark"] .recipe-modal :is(.text-slate-500,.text-slate-400,.recipe-text){color:var(--dp-text-2)!important}
html[data-theme="dark"] .recipe-modal :is(.bg-slate-100,.bg-red-50){
  background:var(--dp-surface-3)!important;
  color:var(--dp-text)!important;
}
html[data-theme="dark"] .recipe-modal :is(.border-b,.nutrition-item,.nutrition-basis){border-color:var(--dp-border)!important}
html[data-theme="dark"] .recipe-modal .nutrition-item{
  background:var(--dp-surface-2)!important;
  color:var(--dp-text)!important;
}
html[data-theme="dark"] #search::placeholder,
html[data-theme="dark"] .recipe-modal .field-input::placeholder{color:var(--dp-muted)!important;opacity:1}

html[data-theme="dark"] .recipe-modal>.bg-white,
html[data-theme="dark"] .recipe-modal>div>.bg-white{
  background:var(--dp-surface)!important;
  color:var(--dp-text)!important;
  border-color:var(--dp-border)!important;
}
html[data-theme="dark"] .recipe-modal>.bg-white :is(h2,h3,strong),
html[data-theme="dark"] .recipe-modal>div>.bg-white :is(h2,h3,strong){color:var(--dp-text)!important}
html[data-theme="dark"] .recipe-modal>.bg-white :is(p,small),
html[data-theme="dark"] .recipe-modal>div>.bg-white :is(p,small){color:var(--dp-text-2)!important}

/* Notifications page — central theme adapter.
   The page stylesheet controls geometry only; colors come exclusively from shared tokens. */
html[data-theme="dark"] body.notifications-page{
  background-color:var(--dp-bg)!important;
  background-image:none!important;
  color:var(--dp-text)!important;
}
html[data-theme="dark"] body.notifications-page :is(header.glass,.notifications-tabs,#empty,.notification-card){
  background:var(--dp-surface)!important;
  color:var(--dp-text)!important;
  border-color:var(--dp-border)!important;
  box-shadow:0 8px 24px var(--dp-shadow)!important;
}
html[data-theme="dark"] body.notifications-page .notifications-tab-list{
  background:var(--dp-surface-2)!important;
  border-color:var(--dp-border)!important;
}
html[data-theme="dark"] body.notifications-page .tab-btn{
  background:transparent!important;
  color:var(--dp-tab-text)!important;
  border-color:transparent!important;
}
html[data-theme="dark"] body.notifications-page .tab-btn.active{
  background:var(--dp-tab-active-bg)!important;
  color:var(--dp-tab-active-text)!important;
  border-color:var(--dp-primary)!important;
  box-shadow:0 2px 8px var(--dp-shadow)!important;
}
html[data-theme="dark"] body.notifications-page :is(#tabTitle,#emptyTitle,.notification-patient-name,.notification-title){
  color:var(--dp-text)!important;
}
html[data-theme="dark"] body.notifications-page :is(#tabSubtitle,#emptyText,.notification-copy,.notification-date,footer){
  color:var(--dp-text-2)!important;
}
html[data-theme="dark"] body.notifications-page .notification-card .bg-sky-50,
html[data-theme="dark"] body.notifications-page .notification-card .bg-indigo-50,
html[data-theme="dark"] body.notifications-page .notification-card .bg-amber-50,
html[data-theme="dark"] body.notifications-page .notification-card .bg-red-50{
  border:1px solid var(--dp-border)!important;
}
html[data-theme="dark"] body.notifications-page #loading{
  background:var(--dp-bg)!important;
  color:var(--dp-text)!important;
}

/* Nutrition Support Patient — centralized adapter.
   All colors resolve through shared semantic tokens; page CSS owns layout only. */
html.nsp-embedded #dp-theme-toggle{display:none!important}
html[data-theme="dark"] body:has(#section-en){
  background:var(--dp-bg)!important;
  color:var(--dp-text)!important;
}
html[data-theme="dark"] body:has(#section-en) .container-main,
html[data-theme="dark"] body:has(#section-en) :is(
  .detail-patient-area,.support-days,.support-tabs,.day-edit-toolbar,
  .support-content,.tab-content,.monitoring-section,.highlight-box,
  .table-custom,.en-volume-fields,.en-volume-field,
  .print-settings-modal,.print-completion-modal,.delete-confirm-box
){
  background:var(--dp-surface)!important;
  color:var(--dp-text)!important;
  border-color:var(--dp-border)!important;
  box-shadow:0 2px 12px var(--dp-shadow)!important;
}
html[data-theme="dark"] body:has(#section-en) :is(
  #section-en .bg-white,#section-tpn .bg-white,
  #en-volume-content,#en-calories-content,#glu-remaining-info,
  .tab-content .bg-white,.print-settings-head,
  .print-settings-body,.print-settings-actions
){
  background:var(--dp-surface-2)!important;
  color:var(--dp-text)!important;
  border-color:var(--dp-border)!important;
}
html[data-theme="dark"] body:has(#section-en) :is(
  #section-en :is(.bg-gray-50,.bg-blue-50,.bg-blue-100,.bg-blue-200,.bg-indigo-50,.bg-indigo-100,.bg-indigo-900,.bg-purple-50,.bg-purple-100,.bg-emerald-50,.bg-emerald-100),
  #section-tpn :is(.bg-gray-50,.bg-blue-50,.bg-blue-100,.bg-blue-200,.bg-indigo-50,.bg-indigo-100,.bg-indigo-900,.bg-amber-50,.bg-amber-100,.bg-emerald-50,.bg-emerald-100),
  .support-tab,.day-item,.day-edit-btn,.component-select,
  #patient-collapse-btn,.table-custom tbody td,
  .print-cancel-btn,.delete-confirm-cancel
){
  background:var(--dp-surface-2)!important;
  color:var(--dp-text-2)!important;
  border-color:var(--dp-border)!important;
}
html[data-theme="dark"] body:has(#section-en) :is(
  .support-brand h1,.support-patient-top h2,.selected-patient-head h2,
  .day-edit-title,.detail-top h2,.days-toolbar h3,
  .support-content h1,.support-content h2,.support-content h3,
  .support-content h4,.support-content label,
  .table-custom td,.table-custom th,.delete-confirm-title,
  .print-settings-head h3,.print-field label,.print-completion-modal h3
){
  color:var(--dp-text)!important;
}
html[data-theme="dark"] body:has(#section-en) :is(
  .support-content p,.support-content small,.support-content .text-gray-500,
  .support-content .text-slate-500,.day-empty,.print-settings-head p,
  .print-completion-modal p,.delete-confirm-text
){
  color:var(--dp-text-2)!important;
}
html[data-theme="dark"] body:has(#section-en) :is(input,select,textarea){
  background:var(--dp-input)!important;
  color:var(--dp-text)!important;
  border-color:var(--dp-input-border)!important;
}
html[data-theme="dark"] body:has(#section-en) :is(input,textarea)::placeholder{
  color:var(--dp-muted)!important;
  opacity:1;
}
html[data-theme="dark"] body:has(#section-en) :is(input,select,textarea):disabled{
  background:var(--dp-surface-2)!important;
  color:var(--dp-muted)!important;
  border-color:var(--dp-border)!important;
}
html[data-theme="dark"] body:has(#section-en) :is(
  .support-tab.active,.day-item.active,.day-item:hover,
  .day-edit-btn:hover,#patient-collapse-btn:hover,
  .day-save-btn,.days-add button,.print-confirm-btn,.print-completion-btn
){
  background:var(--dp-primary)!important;
  color:#fff!important;
  border-color:var(--dp-primary)!important;
}
html[data-theme="dark"] body:has(#section-en) .table-custom th{
  background:var(--dp-surface-3)!important;
  color:var(--dp-text)!important;
}
html[data-theme="dark"] body:has(#section-en) :is(
  #section-en .text-purple-700,#section-en .text-purple-800,
  #section-en .text-purple-900,#section-en .text-indigo-700,
  #section-en .text-indigo-800,#section-en .text-indigo-900,
  #section-en .text-blue-700,#section-en .text-blue-800,
  #section-en .text-blue-900,#section-en .text-emerald-700,
  #section-tpn .text-blue-700,#section-tpn .text-blue-800,
  #section-tpn .text-blue-900,#section-tpn .text-emerald-700,
  #section-tpn .text-emerald-800,#section-tpn .text-emerald-900
){
  color:var(--dp-text)!important;
}
html[data-theme="dark"] body:has(#section-en) :is(
  .bg-low-risk,.bg-mod-risk,.bg-high-risk,#mix-result
){
  border-color:var(--dp-border)!important;
}
html[data-theme="dark"] body:has(#section-en) .bg-low-risk{
  background:#143126!important;color:#c7ead9!important;
}
html[data-theme="dark"] body:has(#section-en) .bg-mod-risk{
  background:#332b16!important;color:#f3dfad!important;
}
html[data-theme="dark"] body:has(#section-en) .bg-high-risk{
  background:#351b1d!important;color:#f3c6c8!important;
}
html[data-theme="dark"] body:has(#section-en) #mix-result{
  background:var(--dp-surface-3)!important;color:var(--dp-text)!important;
}
html[data-theme="dark"] body:has(#section-en) .delete-confirm-icon{
  background:var(--dp-notification-danger-bg)!important;
  color:var(--dp-notification-danger-text)!important;
}
@media print{
  html[data-theme="dark"] body:has(#section-en),
  html[data-theme="dark"] body:has(#section-en) :is(
    .container-main,.support-days,.support-tabs,.day-edit-toolbar,
    .support-content,.tab-content,.monitoring-section
  ){
    background:#fff!important;color:#111!important;box-shadow:none!important;
  }
}

/* Embedded patient-visit diet modals — use the same central semantic palette.
   These dialogs live outside #visitContent, so the visit-content adapter cannot reach them. */
html[data-theme="dark"] .embedded-diet-modals :is(
  #foodModal>div,#addMealModal>div,#confirmModal>div,
  #fixedMealsModal>div,#printSettingsModal>div
){
  background:var(--dp-surface)!important;
  color:var(--dp-text)!important;
  border:1px solid var(--dp-border)!important;
  box-shadow:0 18px 48px var(--dp-shadow)!important;
}
html[data-theme="dark"] .embedded-diet-modals :is(
  #foodModal h3,#addMealModal h3,#confirmModal h3,
  #fixedMealsModal h3,#printSettingsModal h3,
  #foodModal label
){
  color:var(--dp-text)!important;
}
html[data-theme="dark"] .embedded-diet-modals :is(
  #foodSearchInput,#foodGramsInput,#newMealNameInput,
  #fixedMealsSearch,#settingDocName,#settingDocSpec,
  #settingClinicName,#settingAddress
){
  background:var(--dp-input)!important;
  color:var(--dp-text)!important;
  border-color:var(--dp-input-border)!important;
  caret-color:var(--dp-accent);
}
html[data-theme="dark"] .embedded-diet-modals :is(
  #foodSearchInput,#foodGramsInput,#newMealNameInput,
  #fixedMealsSearch,#settingDocName,#settingDocSpec,
  #settingClinicName,#settingAddress
)::placeholder{color:var(--dp-muted)!important;opacity:1}
html[data-theme="dark"] .embedded-diet-modals :is(
  #foodModal .border-slate-100,#foodModal .border-slate-200,
  #addMealModal .border-slate-100,#confirmModal .border-slate-100,
  #fixedMealsModal .border-slate-100,#printSettingsModal .border-slate-100
){border-color:var(--dp-border)!important}
html[data-theme="dark"] #foodDropdownList{
  background:var(--dp-surface-2)!important;
  border-color:var(--dp-border)!important;
}
html[data-theme="dark"] #foodDropdownList .food-result{
  background:var(--dp-surface-2)!important;
  color:var(--dp-text)!important;
  border-color:var(--dp-border)!important;
}
html[data-theme="dark"] #foodDropdownList .food-result:hover,
html[data-theme="dark"] #foodDropdownList .food-result.bg-emerald-100\/70{
  background:var(--dp-surface-3)!important;
  color:var(--dp-text)!important;
}
html[data-theme="dark"] #foodModalHouseholdBox{
  background:var(--dp-surface-2)!important;
  border-color:var(--dp-border)!important;
}
html[data-theme="dark"] #foodModalHouseholdBox :is(div){
  color:var(--dp-text-2)!important;
}
html[data-theme="dark"] .embedded-diet-modals :is(
  #foodModal .bg-slate-100,#confirmModal .bg-slate-100,
  #fixedMealsModal .bg-slate-50,#fixedMealsModal .bg-white
){
  background:var(--dp-surface-2)!important;
  color:var(--dp-text-2)!important;
  border-color:var(--dp-border)!important;
}
html[data-theme="dark"] .embedded-diet-modals :is(
  #foodModal button,#addMealModal button,#confirmModal button,
  #fixedMealsModal button,#printSettingsModal button
):focus-visible{
  outline:2px solid var(--dp-accent)!important;
  outline-offset:2px;
}

/* EN volume form surfaces — resolve legacy light-only field groups via central tokens. */
html[data-theme="dark"] body:has(#section-en) .container-main,
html[data-theme="dark"] body:has(#section-en) #en-volume-content,
html[data-theme="dark"] body:has(#section-en) #en-calories-content{
  background:var(--dp-surface)!important;
  color:var(--dp-text)!important;
  border-color:var(--dp-border)!important;
}
html[data-theme="dark"] body:has(#section-en) #en-volume-content .en-volume-fields,
html[data-theme="dark"] body:has(#section-en) #en-volume-content .en-volume-fields--primary,
html[data-theme="dark"] body:has(#section-en) #en-volume-content .en-volume-fields--rates,
html[data-theme="dark"] body:has(#section-en) #en-volume-content .en-volume-fields--fortification{
  background:var(--dp-surface-2)!important;
  color:var(--dp-text)!important;
  border-color:var(--dp-border)!important;
}
html[data-theme="dark"] body:has(#section-en) #en-volume-content .en-volume-field,
html[data-theme="dark"] body:has(#section-en) #en-volume-content .en-volume-frequency{
  background:transparent!important;
  color:var(--dp-text)!important;
}
html[data-theme="dark"] body:has(#section-en) #en-volume-content .en-volume-field>label,
html[data-theme="dark"] body:has(#section-en) #en-volume-content .en-volume-frequency>span{
  color:var(--dp-text-2)!important;
}
html[data-theme="dark"] body:has(#section-en) #section-en .bg-white,
html[data-theme="dark"] body:has(#section-en) #section-en .bg-emerald-50,
html[data-theme="dark"] body:has(#section-en) #section-en .bg-blue-50,
html[data-theme="dark"] body:has(#section-en) #section-en .bg-amber-50,
html[data-theme="dark"] body:has(#section-en) #section-en .bg-purple-50{
  background:var(--dp-surface-2)!important;
  color:var(--dp-text)!important;
  border-color:var(--dp-border)!important;
}
html[data-theme="dark"] body:has(#section-en) #section-en :is(.bg-emerald-100,.bg-blue-100,.bg-amber-100,.bg-purple-100,.bg-indigo-100){
  background:var(--dp-surface-3)!important;
  color:var(--dp-text)!important;
  border-color:var(--dp-border)!important;
}

/* ---------- Central dark theme: patient directory and profile navigation ---------- */
html[data-theme="dark"] .patient-record-views{
  background:var(--dp-surface-2)!important;
  border-color:var(--dp-border)!important;
}
html[data-theme="dark"] .patient-record-view{
  color:var(--dp-text-2)!important;
}
html[data-theme="dark"] .patient-record-view:hover{
  background:var(--dp-surface-3)!important;
  color:var(--dp-text)!important;
}
html[data-theme="dark"] .patient-record-view.is-selected{
  background:var(--dp-dark-surface-raised)!important;
  border-color:var(--dp-accent)!important;
  color:var(--dp-text)!important;
  box-shadow:0 1px 4px var(--dp-shadow)!important;
}
html[data-theme="dark"] .patient-module-tabs{
  background:var(--dp-surface-2)!important;
  border-color:var(--dp-border)!important;
  scrollbar-color:var(--dp-muted) transparent;
}
html[data-theme="dark"] .patient-module-tab{
  color:var(--dp-text-2)!important;
}
html[data-theme="dark"] .patient-module-tab:hover{
  background:var(--dp-surface-3)!important;
  color:var(--dp-text)!important;
}
html[data-theme="dark"] .patient-module-tab.is-active{
  background:var(--dp-dark-surface-raised)!important;
  color:var(--dp-text)!important;
  border-bottom-color:var(--dp-accent)!important;
}
html[data-theme="dark"] .patient-module-tab:focus-visible{
  outline:2px solid var(--dp-text-2)!important;
  outline-offset:2px;
  border-radius:7px;
}
html[data-theme="dark"] .patient-record-action{
  background:var(--dp-surface-2)!important;
  border-color:var(--dp-border)!important;
  color:var(--dp-accent)!important;
}
html[data-theme="dark"] .patient-record-action:hover{
  background:var(--dp-surface-3)!important;
}
html[data-theme="dark"] .patient-record-action--restore{
  background:#173a2d!important;
  border-color:#315e48!important;
  color:#8ed7a8!important;
}
html[data-theme="dark"] .patient-status--linked{
  background:#1c3047!important;
  color:#a9c9f5!important;
}
html[data-theme="dark"] .patient-status--archived{
  background:var(--dp-surface-3)!important;
  color:var(--dp-text-2)!important;
}
html[data-theme="dark"] .patient-data-title strong{
  color:var(--dp-accent)!important;
}
html[data-theme="dark"] .patient-data-summary .dashboard-icon{
  background:var(--dp-surface-3)!important;
  color:var(--dp-accent)!important;
}

/* Patient profile measurement summary — centralized semantic dark surfaces. */
html[data-theme="dark"] body.patient-profile-page .measurement-summary-card{
  background:var(--dp-surface-2)!important;
  border-color:var(--dp-border)!important;
  box-shadow:none!important;
}
html[data-theme="dark"] body.patient-profile-page .measurement-summary-label{
  color:var(--dp-text-2)!important;
}
html[data-theme="dark"] body.patient-profile-page .measurement-summary-value{
  color:var(--dp-text)!important;
}
html[data-theme="dark"] body.patient-profile-page .measurement-summary-value[data-trend="up"]{
  color:#f0a39b!important;
}
html[data-theme="dark"] body.patient-profile-page .measurement-summary-value[data-trend="down"]{
  color:#72d6b0!important;
}
html[data-theme="dark"] body.patient-profile-page .measurement-summary-value[data-trend="neutral"]{
  color:var(--dp-text)!important;
}
html[data-theme="dark"] body.patient-profile-page .measurement-summary-note{
  color:var(--dp-muted)!important;
}

/* ---------- Admin workspace: centralized dark theme ---------- */
html[data-theme="dark"] body:has(#adminContactForm) .header.admin-branded-header{
  background:var(--dp-brand-gradient)!important;
  color:#fff!important;
}
html[data-theme="dark"] body:has(#adminContactForm) #adminGate{
  background:var(--dp-surface)!important;
  color:var(--dp-text-2)!important;
  border-color:var(--dp-border)!important;
  box-shadow:0 8px 25px var(--dp-shadow)!important;
}
html[data-theme="dark"] body:has(#adminContactForm) :is(
  .stat,.check-grid,.announcement-form-options,
  .announcement-admin-item,.professional-review-card,
  .admin-contact-toggle
){
  background:var(--dp-surface-2)!important;
  color:var(--dp-text)!important;
  border-color:var(--dp-border)!important;
}
html[data-theme="dark"] body:has(#adminContactForm) :is(
  .admin-contact-heading h2,.admin-contact-field,
  .admin-contact-field label,.admin-contact-toggle,
  .announcement-admin-item h3
){
  color:var(--dp-text)!important;
}
html[data-theme="dark"] body:has(#adminContactForm) :is(
  .admin-contact-heading p,.announcement-admin-item p,
  .announcement-admin-meta,.field label,.confirm-text
){
  color:var(--dp-text-2)!important;
}
html[data-theme="dark"] body:has(#adminContactForm) .admin-contact-field :is(input,textarea){
  background:var(--dp-input)!important;
  color:var(--dp-text)!important;
  border-color:var(--dp-input-border)!important;
  caret-color:var(--dp-accent);
}
html[data-theme="dark"] body:has(#adminContactForm) .admin-contact-field :is(input,textarea)::placeholder{
  color:var(--dp-muted)!important;
  opacity:1;
}
html[data-theme="dark"] body:has(#adminContactForm) .admin-contact-field i{
  color:var(--dp-accent)!important;
}
html[data-theme="dark"] body:has(#adminContactForm) :is(
  .admin-contact-toggle,.announcement-form-options,
  .check-grid,.announcement-admin-meta,.announcement-admin-actions
){
  border-color:var(--dp-border)!important;
}
html[data-theme="dark"] body:has(#adminContactForm) .admin-contact-actions [role="status"]{
  color:var(--dp-text-2)!important;
}


/* Admin plan editor — semantic dark surfaces from the central theme. */
html[data-theme="dark"] #modalBg.plan-editor #modal{
 background:var(--dp-surface)!important;color:var(--dp-text)!important;border-color:var(--dp-border)!important;
}
html[data-theme="dark"] #modalBg.plan-editor .modal-head,
html[data-theme="dark"] #modalBg.plan-editor .plan-editor-actions{
 background:var(--dp-surface)!important;border-color:var(--dp-border)!important;
}
html[data-theme="dark"] #modalBg.plan-editor .modal-head h2,
html[data-theme="dark"] #modalBg.plan-editor .plan-editor-section-head h3,
html[data-theme="dark"] #modalBg.plan-editor .plan-editor-trial strong{
 color:var(--dp-text)!important;
}
html[data-theme="dark"] #modalBg.plan-editor .plan-editor-section-head p,
html[data-theme="dark"] #modalBg.plan-editor .plan-editor-trial small{
 color:var(--dp-text-2)!important;
}
html[data-theme="dark"] #modalBg.plan-editor .plan-editor-section-icon{
 background:var(--dp-surface-3)!important;color:var(--dp-accent)!important;
}
html[data-theme="dark"] #modalBg.plan-editor .plan-editor-trial{
 background:var(--dp-surface-2)!important;border-color:var(--dp-border)!important;
}
html[data-theme="dark"] #modalBg.plan-editor .plan-editor-form .field label{
 color:var(--dp-text-2)!important;
}
html[data-theme="dark"] #modalBg.plan-editor .plan-editor-form .field :is(input,select,textarea){
 background:var(--dp-input)!important;color:var(--dp-text)!important;border-color:var(--dp-input-border)!important;
}
html[data-theme="dark"] #modalBg.plan-editor .plan-editor-form .field :is(input,textarea)::placeholder{
 color:var(--dp-muted)!important;opacity:1;
}
html[data-theme="dark"] #modalBg.plan-editor .close{
 background:var(--dp-surface-2)!important;color:var(--dp-text)!important;border-color:var(--dp-border)!important;
}
