/* Dark palette for all headers using the shared identity loader.
   Important declarations in this layer take precedence over legacy unlayered
   important light colors, without changing layout, visibility or interactions. */
@layer hh-dark-palette {
  @media screen {
    :is(.dark-style,[data-bs-theme="dark"]),
    :is(.dark-style,[data-bs-theme="dark"]) :is(body,.hh-refined-page,.home-day-dashboard,.dr-shell,.mc-workspace,.mc-staff-workspace,.sadq-workspace,.clinicians-page) {
      color-scheme: dark;
      --hg-page: #101923 !important; --hg-surface: #172536 !important;
      --hg-ink: #e6eef8 !important; --hg-muted: #afc0d3 !important; --hg-border: #34495f !important;
      --hg-primary: #8dbdff !important; --hg-primary-deep: #bed9ff !important; --hg-primary-soft: #203853 !important;
      --hg-row-alt: #1b2d41 !important; --hg-row-hover: #25425f !important;
      --bs-body-bg: #101923 !important; --bs-body-color: #e6eef8 !important;
      --bs-heading-color: #e6eef8 !important; --bs-border-color: #34495f !important;
      --bs-table-color: #e6eef8 !important; --bs-table-bg: #172536 !important;
      --bs-table-striped-bg: #1b2d41 !important; --bs-table-hover-bg: #25425f !important;
      --hh-stat-blue: #8dbdff !important; --hh-stat-blue-bg: #203853 !important;
      --hh-stat-amber: #f1c36d !important; --hh-stat-amber-bg: #433720 !important;
      --hh-stat-green: #77d6b5 !important; --hh-stat-green-bg: #193e37 !important;
      --hh-stat-red: #ff9aa7 !important; --hh-stat-red-bg: #482c38 !important;
      --day-soft: #203853 !important; --day-primary: #8dbdff !important;
      --dr-deep: #bed9ff !important; --dr-muted: #afc0d3 !important;
      --doctors-primary: #8dbdff !important; --doctors-ink: #e6eef8 !important; --doctors-muted: #afc0d3 !important;
    }
    :is(.dark-style,[data-bs-theme="dark"]) :is(body,.layout-wrapper,.layout-page,.content-wrapper) { background-color: #101923 !important; color: #e6eef8 !important; }
    :is(.dark-style,[data-bs-theme="dark"]) :is(.layout-navbar,#layout-navbar,.layout-menu,.layout-menu-horizontal,.content-footer,.footer) { background: #172536 !important; border-color: #34495f !important; color: #e6eef8 !important; }
    :is(.dark-style,[data-bs-theme="dark"]) :is(.menu-link,.menu-link > div,.nav-link,.dropdown-item,.dropdown-item-text,.menu-header-text) { color: #dce9f8 !important; }
    :is(.dark-style,[data-bs-theme="dark"]) #layout-navbar .nav-link { background-color: transparent !important; }
    :is(.dark-style,[data-bs-theme="dark"]) #layout-navbar :is(.hh-portal-context,.dropdown-language > .nav-link) { background-color: #203248 !important; border-color: #405873 !important; }
    :is(.dark-style,[data-bs-theme="dark"]) #layout-navbar .nav-link:hover { background-color: #254665 !important; color: #fff !important; }
    :is(.dark-style,[data-bs-theme="dark"]) :is(.menu-sub,.dropdown-menu) { background: #1b2b3e !important; border-color: #34495f !important; }
    :is(.dark-style,[data-bs-theme="dark"]) :is(.menu-item.active > .menu-link,.menu-link:hover,.dropdown-item:hover,.dropdown-item:focus) { background: #254665 !important; color: #fff !important; }
    :is(.dark-style,[data-bs-theme="dark"]) .menu-link .menu-icon,
    :is(.dark-style,[data-bs-theme="dark"]) :is(.hh-portal-avatar,.hh-portal-avatar-icon,.hh-admin-avatar,.hh-portal-location) { background-color: #263f5c !important; color: #b8d7ff !important; border-color: #405b79 !important; }
    /* The original logo keeps its white backing for legibility. */
    :is(.dark-style,[data-bs-theme="dark"]) :is(.hh-portal-brand-link,.hh-admin-brand,.app-brand-link:has(img)) { background-color: #fff !important; border-color: #d9e4f1 !important; }

    :is(.dark-style,[data-bs-theme="dark"]) :is(.card,.box,.panel,.modal-content,.offcanvas,.accordion-item,.list-group-item,.home-day-panel,.home-day-metric,.home-day-attention-item,.home-day-item,.home-contact-card,.dr-card,.training-stat,.stat-card,.clinicians-stat,.clinicians-report-summary,.hac-summary,.complaints-statistics-wrap,.complaints-statistic-card,.tf-search,.tf-list,.holiday-search-card,.holiday-results-card,.medical-search-card,.medical-results-card,.government-search-card,.government-results-card,.approval-card,.hh-settings-card) {
      background-color: #172536 !important; background-image: none !important; color: #e6eef8 !important; border-color: #34495f !important;
    }
    :is(.dark-style,[data-bs-theme="dark"]) :is(.card-header,.card-footer,.box-header,.panel-heading,.modal-header,.modal-footer,.home-day-panel-head,.dr-list-head,.complaints-search-header,.government-search-title,.government-results-title,.holiday-card-title,.tf-search .row:first-of-type,.home-day-shortcuts > a) {
      background: #203248 !important; border-color: #34495f !important; color: #dce9f8 !important;
    }
    :is(.dark-style,[data-bs-theme="dark"]) .content-wrapper :is(h1,h2,h3,h4,h5,h6,.card-title,.modal-title,label,.control-label,legend,.form-label,.table-caption) { color: #dce9f8 !important; }
    :is(.dark-style,[data-bs-theme="dark"]) .content-wrapper :is(h1.page-header,h3.page-header,h4.page-header,.container-xxl > h4.fw-bold,.container-xxl > h3.card-title,.container-xxl > h1,.container-xxl > .row > h1) { background: #203853 !important; color: #bed9ff !important; border-color: #578ecf !important; }
    :is(.dark-style,[data-bs-theme="dark"]) :is(.text-muted,.text-secondary,.form-text,.dataTables_info,.home-day-panel-head p,.home-day-metric small,.home-day-attention-item small,.training-stat span) { color: #afc0d3 !important; }
    :is(.dark-style,[data-bs-theme="dark"]) .content-wrapper a:not(.btn):not(.hh-new-action):not(.badge) { color: #a7ccff !important; }
    :is(.dark-style,[data-bs-theme="dark"]) :is(.text-primary,.file-number,.procedure-code,.home-day-count,.clinicians-stat-value,.training-stat strong,.medical-stat-number,.government-stat-value,.approval-stat-value) { color: #a7ccff !important; }
    :is(.dark-style,[data-bs-theme="dark"]) :is(.text-dark,.text-body,.text-heading) { color: #e6eef8 !important; }
    :is(.dark-style,[data-bs-theme="dark"]) :is(.text-success,.tf-status-success) { color: #77d6b5 !important; }
    :is(.dark-style,[data-bs-theme="dark"]) .text-warning { color: #f1c36d !important; }
    :is(.dark-style,[data-bs-theme="dark"]) .text-danger { color: #ff9aa7 !important; }
    :is(.dark-style,[data-bs-theme="dark"]) :is(.text-white,.procedure-hero h3,.home-day-header h1,.home-day-header p,.training-heading h3,.training-heading p,.dr-hero h2,.dr-hero p,.ed-hero h1,.ed-hero p) { color: #fff !important; }

    :is(.dark-style,[data-bs-theme="dark"]) :is(.form-control,.form-select,select.form-control,textarea.form-control,.select2-selection,.select2-dropdown,.select2-search__field,.dataTables_filter input,.dataTables_length select,.page-link,.input-group-text) {
      background-color: #1b2d41 !important; color: #e6eef8 !important; border-color: #405873 !important;
    }
    :is(.dark-style,[data-bs-theme="dark"]) :is(.form-control,.form-select)::placeholder { color: #a3b5ca !important; opacity: 1; }
    :is(.dark-style,[data-bs-theme="dark"]) :is(.form-control,.form-select):focus { border-color: #8dbdff !important; box-shadow: 0 0 0 3px rgba(141,189,255,.18) !important; }
    :is(.dark-style,[data-bs-theme="dark"]) :is(input,select,textarea):disabled,
    :is(.dark-style,[data-bs-theme="dark"]) .form-control[readonly] { background-color: #263447 !important; color: #adbed0 !important; }
    :is(.dark-style,[data-bs-theme="dark"]) :is(.select2-selection__rendered,.select2-results__option,option) { color: #e6eef8 !important; }
    :is(.dark-style,[data-bs-theme="dark"]) option { background-color: #1b2d41 !important; }
    :is(.dark-style,[data-bs-theme="dark"]) :is(.select2-results__option--highlighted,.select2-results__option[aria-selected="true"],.page-item.active .page-link) { background-color: #1855a4 !important; color: #fff !important; }
    :is(.dark-style,[data-bs-theme="dark"]) .form-check-input:not(:checked) { background-color: #1b2d41 !important; border-color: #718ba6 !important; }

    :is(.dark-style,[data-bs-theme="dark"]) .content-wrapper :is(.table,table.table-bordered) { background-color: #172536 !important; color: #e6eef8 !important; border-color: #34495f !important; }
    :is(.dark-style,[data-bs-theme="dark"]) .content-wrapper :is(.table,table.table-bordered) > :is(thead,tbody,tfoot) > tr > :is(th,td) {
      background-color: #172536 !important; color: #e6eef8 !important; border-color: #34495f !important; box-shadow: none !important;
    }
    :is(.dark-style,[data-bs-theme="dark"]) .content-wrapper :is(.table,table.table-bordered) > thead > tr > :is(th,td) { background: #203853 !important; color: #bed9ff !important; }
    :is(.dark-style,[data-bs-theme="dark"]) .content-wrapper .table-striped > tbody > tr:nth-child(even) > * { background-color: #1b2d41 !important; }
    :is(.dark-style,[data-bs-theme="dark"]) .content-wrapper .table-hover > tbody > tr:hover > * { background-color: #25425f !important; }
    :is(.dark-style,[data-bs-theme="dark"]) .content-wrapper :is(.tf-summary table,.holiday-summary,.inquiries-statistics-table,.complaints-statistics-table) :is(th,td) { background: #1b2d41 !important; color: #a7ccff !important; border-color: #34495f !important; }
    :is(.dark-style,[data-bs-theme="dark"]) .content-wrapper .tf-summary table :is(th,td):nth-child(2) { background: #342f26 !important; color: #f1c36d !important; }
    :is(.dark-style,[data-bs-theme="dark"]) .content-wrapper .tf-summary table :is(th,td):nth-child(3) { background: #193830 !important; color: #77d6b5 !important; }
    :is(.dark-style,[data-bs-theme="dark"]) .tf-summary table td strong { color: inherit !important; }
    :is(.dark-style,[data-bs-theme="dark"]) :is(.government-stat-icon,.medical-stat-icon,.approval-stat-icon,.clinicians-stat-icon,.home-day-count,.stat-icon-wrapper) { background-color: #203853 !important; color: #a7ccff !important; }
    :is(.dark-style,[data-bs-theme="dark"]) :is(.home-day-metric,.home-day-metric > strong) { --metric-color: #a7ccff !important; color: #a7ccff !important; }
    :is(.dark-style,[data-bs-theme="dark"]) :is(.home-day-tone-success,.home-day-tone-success > strong) { --metric-color: #77d6b5 !important; color: #77d6b5 !important; }
    :is(.dark-style,[data-bs-theme="dark"]) :is(.home-day-tone-danger,.home-day-tone-danger > strong) { --metric-color: #ff9aa7 !important; color: #ff9aa7 !important; }
    :is(.dark-style,[data-bs-theme="dark"]) :is(.government-stat-value,.medical-stat-number,.approval-stat-value) { color: var(--hh-stat-color,#a7ccff) !important; }
    :is(.dark-style,[data-bs-theme="dark"]) :is(.government-stat-icon,.medical-stat-icon,.approval-stat-icon) { background-color: var(--hh-stat-bg,#203853) !important; color: var(--hh-stat-color,#a7ccff) !important; }
    :is(.dark-style,[data-bs-theme="dark"]) :is(.clinicians-hero,.clinicians-search,.clinicians-report-summary,.login-shell,.login-card,.login-form-panel) { background-color: #172536 !important; background-image: none !important; border-color: #34495f !important; color: #e6eef8 !important; }
    :is(.dark-style,[data-bs-theme="dark"]) .hh-login :is(h1,h2,h3,label,.login-heading,.login-subtitle) { color: #dce9f8 !important; }
    :is(.dark-style,[data-bs-theme="dark"]) .hh-login .login-brand { background-color: #fff !important; }
    :is(.dark-style,[data-bs-theme="dark"]) .hh-login .login-attempts { background-color: #482c38 !important; color: #ff9aa7 !important; }

    :is(.dark-style,[data-bs-theme="dark"]) :is(.btn-primary,.hh-new-action,.btn-dark,input.btn[name="SubmitSearch"]) { background-color: #1855a4 !important; border-color: #447abf !important; color: #fff !important; }
    :is(.dark-style,[data-bs-theme="dark"]) :is(.btn-primary,.hh-new-action,.btn-dark):not(:disabled):hover { background-color: #2167bc !important; color: #fff !important; }
    :is(.dark-style,[data-bs-theme="dark"]) :is(.btn-secondary,.btn-default,.btn-light,.btn-outline-secondary,.btn-label-secondary,.btn-outline-primary,.btn-label-primary,a.btn[href*="do=restore"],a.btn[href*="do=unset"]) { background-color: #263f5c !important; border-color: #4b6787 !important; color: #c6dfff !important; }
    :is(.dark-style,[data-bs-theme="dark"]) .btn-success { background-color: #176b55 !important; border-color: #3d957b !important; color: #fff !important; }
    :is(.dark-style,[data-bs-theme="dark"]) .modal input.btn:is([name="submitCat"],[name="submitComplaint"],[name="submitDecision"],[name="submitSMSForm"]) { background-color: #176b55 !important; border-color: #3d957b !important; color: #fff !important; }
    :is(.dark-style,[data-bs-theme="dark"]) .btn-danger { background-color: #9a3445 !important; border-color: #c56573 !important; color: #fff !important; }
    :is(.dark-style,[data-bs-theme="dark"]) :is(.btn-warning,.bg-label-warning,.approval-status.pending,.alert-warning) { background-color: #433720 !important; border-color: #796138 !important; color: #f1c36d !important; }
    :is(.dark-style,[data-bs-theme="dark"]) :is(.bg-label-success,.approval-status.approved,.alert-success) { background-color: #193e37 !important; border-color: #376d5d !important; color: #77d6b5 !important; }
    :is(.dark-style,[data-bs-theme="dark"]) :is(.bg-label-danger,.approval-status.rejected,.alert-danger) { background-color: #482c38 !important; border-color: #7d4b5c !important; color: #ff9aa7 !important; }
    :is(.dark-style,[data-bs-theme="dark"]) :is(.bg-label-primary,.bg-label-info,.alert-info,.alert-primary) { background-color: #203853 !important; border-color: #405f82 !important; color: #bed9ff !important; }
    :is(.dark-style,[data-bs-theme="dark"]) .modal .modal-header :is(.modal-title,h4,h5) { color: #bed9ff !important; }
    :is(.dark-style,[data-bs-theme="dark"]) .modal :is(.modal-body,.modal-body label) { color: #e6eef8 !important; }
    /* Stored editor HTML may carry explicit black text and white fills. */
    :is(.dark-style,[data-bs-theme="dark"]) .hh-outpatient-doctors .modal-body :is(p,div,span,font,b,strong,em,i,li,ul,ol,blockquote,pre,code,h1,h2,h3,h4,h5,h6,table,td,th) { color: #e6eef8 !important; background-color: transparent !important; border-color: #405873 !important; }
    :is(.dark-style,[data-bs-theme="dark"]) .hh-outpatient-doctors .modal-body a { color: #a7ccff !important; }
    :is(.dark-style,[data-bs-theme="dark"]) .hh-outpatient-doctors :is(.outpatient-doctors-context,.card-expand) { background-color: #203248 !important; color: #bed9ff !important; }
    :is(.dark-style,[data-bs-theme="dark"]) .hh-outpatient-doctors .outpatient-doctors-context > .row { background-color: transparent !important; }
    :is(.dark-style,[data-bs-theme="dark"]) .hh-outpatient-doctors .outpatient-doctors-search a.btn { background-color: #263f5c !important; color: #c6dfff !important; border-color: #4b6787 !important; }
    :is(.dark-style,[data-bs-theme="dark"]) .hh-outpatient-doctors .outpatient-doctors-context .col-md-12,
    :is(.dark-style,[data-bs-theme="dark"]) .hh-outpatient-doctors .card-action > .card-content > .card-body > .table > tbody > tr > td:first-child > b { color: #afc0d3 !important; }
    :is(.dark-style,[data-bs-theme="dark"]) .modal .modal-header .btn-close { background-color: #dce9f8 !important; filter: none !important; }
    :is(.dark-style,[data-bs-theme="dark"]) .modal .modal-header .close { background-color: #263f5c !important; color: #e6eef8 !important; border-color: #4b6787 !important; }
    /* Light utility panels and legacy inline pale fills must follow the palette. */
    :is(.dark-style,[data-bs-theme="dark"]) .content-wrapper :is(.bg-white,.bg-light,.bg-body,.bg-lighter,.complaints-search-panel,.search-row) { background-color: #172536 !important; color: #e6eef8 !important; border-color: #34495f !important; }
    :is(.dark-style,[data-bs-theme="dark"]) .content-wrapper :is([style*="background-color: #ddd"],[style*="background-color:#ddd"],[style*="background-color: #fff"],[style*="background-color:#fff"],[style*="background-color: #f4f4f4"],[bgcolor="#FFFFFF"],[bgcolor="#ffffff"],[bgcolor="#f4f4f4"]) { background-color: #172536 !important; color: #e6eef8 !important; }
    :is(.dark-style,[data-bs-theme="dark"]) :is(a,button,input,select,textarea):focus-visible { outline-color: #8dbdff !important; }
  }
}
