/* Customer light/dark surface remaps. Tokens live in design_tokens.css.
   Unlayered on purpose so remaps beat @layer utilities/components without !important.
   Prefer semantic tokens in component CSS over new remaps here. */

html.theme-dark body,
html.theme-dark body.bg-blue-100 {
  background-color: var(--color-page);
  color: var(--color-body);
}

html.theme-dark .flash-banner--notice {
  background-color: var(--button-grey-bg, #3f4d69);
  color: var(--button-grey-fg, #ffffff);
}

html.theme-dark .door-access-package-status-banner {
  background-color: var(--chart-warning-fill, rgb(250 226 133 / 20%));
  border-color: color-mix(in srgb, var(--chart-warning, #fae285) 45%, transparent);
  color: var(--color-on-surface);
}

html.theme-dark .door-access-package-status-banner .text-black {
  color: var(--color-on-surface);
}

html.theme-dark .door-status-badge--available {
  background-color: var(--color-notice-surface, rgb(70 196 98 / 15%));
  color: var(--color-label-green, #46c462);
}

html.theme-dark .door-demographics-field {
  background-color: var(--color-surface-subtle);
  color: var(--color-on-surface);
  -webkit-text-fill-color: var(--color-on-surface);
}

html.theme-dark .door-demographics-field::placeholder {
  color: var(--color-on-surface);
  -webkit-text-fill-color: var(--color-on-surface);
}

html.theme-dark .door-confirm__open {
  background: var(--login-button-bg);
  color: var(--color-on-surface, #ffffff);
}

html.theme-dark .door-confirm__open:hover:not(:disabled) {
  background: var(--login-button-bg-hover);
}

html.theme-dark .door-confirm__open.bg-green-500,
html.theme-dark .door-confirm__open.bg-green-500:hover:not(:disabled) {
  background: var(--color-status-positive, #46c462);
  color: var(--color-page, #040a1d);
}

html.theme-dark .door-confirm__open:disabled,
html.theme-dark .door-confirm__open.bg-green-500:disabled {
  background: var(--button-grey-bg, #3f4d69);
  color: var(--color-muted, #c0c5d3);
  opacity: 1;
}

html.theme-dark .bg-white {
  background-color: var(--color-surface);
}

html.theme-dark .card:not(.card--purple):not(.card--yellow) {
  background-color: var(--color-surface) !important;
  color: var(--color-on-surface);
  box-shadow:
    0 0.25rem 0.75rem var(--color-overlay-soft),
    0 1px 1px 1px var(--color-border-subtle);
}

html.theme-dark .split-card,
html.theme-dark .split-card.bg-white {
  background-color: var(--color-surface) !important;
  color: var(--color-on-surface);
  box-shadow: var(--login-card-shadow, none);
}

html.theme-dark .split-card__right {
  background-color: var(--color-surface) !important;
  color: var(--color-on-surface);
}

html.theme-dark .input input,
html.theme-dark .input textarea,
html.theme-dark .input select {
  background-color: var(--color-surface-subtle) !important;
  background-image: none !important;
  color: var(--color-on-surface) !important;
  border-color: var(--color-border-subtle) !important;
}

html.theme-dark .input label {
  color: var(--color-on-surface);
}

html.theme-dark .input input::placeholder,
html.theme-dark .input textarea::placeholder,
html.theme-dark .input select::placeholder {
  color: var(--color-muted);
}

html.theme-dark .bg-blue-100 {
  background-color: var(--color-page);
}

/* Suggestion store links stay a pale orange pill in light mode. In dark mode match the blue action button. */
html.theme-dark a.bg-blue-100.text-orange-450 {
  background: var(--login-button-bg);
  color: var(--color-on-surface, #ffffff);
  text-decoration: none;
}

html.theme-dark a.bg-blue-100.text-orange-450:hover,
html.theme-dark a.bg-blue-100.text-orange-450:focus-visible {
  background: var(--login-button-bg-hover);
  color: var(--color-on-surface, #ffffff);
  text-decoration: none;
}

html.theme-dark a.bg-blue-100.text-orange-450 img {
  filter: brightness(0) invert(1);
}

html.theme-dark .bg-blue-50 {
  background-color: var(--color-surface-subtle) !important;
}

html.theme-dark .bg-blue-lighter {
  background-color: var(--bg-blue-lighter) !important;
}

html.theme-dark .bg-gray-50 {
  background-color: var(--color-surface-subtle);
  color: var(--color-on-surface);
}

html.theme-dark .bg-green-50 {
  background-color: var(--color-notice-surface);
}

html.theme-dark .bg-red-50 {
  background-color: var(--color-danger-surface);
}

html.theme-dark .hover\:bg-gray-50:hover,
html.theme-dark .hover\:bg-purple-50:hover {
  background-color: var(--color-overlay-soft);
}

html.theme-dark .hover\:bg-blue-200:hover {
  background-color: var(--own-results-add-card-bg-hover, #242b3d);
}

html.theme-dark .hover\:bg-red-50:hover {
  background-color: var(--color-danger-surface);
}

html.theme-dark .text-gray-900,
html.theme-dark .text-purple-950,
html.theme-dark .text-black {
  color: var(--color-on-surface);
}

html.theme-dark .text-gray-800,
html.theme-dark .text-gray-700 {
  color: var(--color-body);
}

html.theme-dark .text-gray-600,
html.theme-dark .text-gray-500 {
  color: var(--color-muted);
}

html.theme-dark .border-gray-200,
html.theme-dark .border-gray-300,
html.theme-dark .border-gray-400,
html.theme-dark .border-blue-200 {
  border-color: var(--color-border-subtle);
}

html.theme-dark .hover\:border-gray-400:hover {
  border-color: var(--color-muted);
}

html.theme-dark .border-red-300 {
  border-color: var(--color-alert-border);
}

html.theme-dark .text-red-800 {
  color: var(--color-alert-emphasis);
}

html.theme-dark .color-purple {
  color: var(--color-heading);
}

/* Purple link and leftover purple copy on the dark page. Headings stay white. */
html.theme-dark a.color-purple,
html.theme-dark .react-shell .card a.color-purple,
html.theme-dark a.text-purple-950:not([class*="bg-"]),
html.theme-dark a.text-purple-800,
html.theme-dark a.text-purple-700,
html.theme-dark a.text-purple-600,
html.theme-dark button.text-purple-950:not([class*="bg-"]),
html.theme-dark button.text-purple-800,
html.theme-dark .text-purple-950 a:not([class*="bg-"]),
html.theme-dark .color-purple a:not([class*="bg-"]),
html.theme-dark .text-purple-800,
html.theme-dark .text-purple-700,
html.theme-dark .text-purple-600,
html.theme-dark .text-purple-900,
html.theme-dark .text-purple-300,
html.theme-dark .hover\:text-purple-800:hover,
html.theme-dark .hover\:text-purple-700:hover,
html.theme-dark .hover\:text-purple-600:hover,
html.theme-dark .focus-visible\:outline-purple-800:focus-visible,
html.theme-dark .door-text-link {
  color: var(--color-secondary-600, #a8c5e6);
  outline-color: var(--color-secondary-600, #a8c5e6);
}

.door-text-link {
  color: var(--color-purple, #39235d);
}

html.theme-dark .color-dark {
  color: var(--color-body);
}

html.theme-dark .color-black {
  color: var(--color-on-surface);
}

html.theme-dark .text-black {
  color: var(--color-on-surface) !important;
}

html.theme-dark .nav-header--desktop {
  position: relative;
  background-color: var(--color-page);
  color: var(--color-on-surface);
  /* Full-width hairline above logo/logotype backgrounds (inset shadow was covered by them). */
  box-shadow: none;
  border-bottom: none;
  width: 100%;
  max-width: none;
}

/* Drop the old header line. The desktop line is drawn on the navigation root, above the search overlay. */
html.theme-dark .nav-header--desktop::after {
  content: none;
}

/* Desktop navigation. A line on the header was cut in half by the search overlay. */
@media (min-width: 1024px) {
  html.theme-dark [data-controller="user--navigation"]::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: calc(var(--nav-header-height, 81px) - 1px);
    height: 1px;
    background-color: var(--color-border-subtle);
    pointer-events: none;
    z-index: 10005;
  }

  /* Light bar has no border of its own. #E2ECF7 is the section-band blue. */
  html:not(.theme-dark) [data-controller="user--navigation"]::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: calc(var(--nav-header-height, 81px) - 1px);
    height: 1px;
    background-color: #e2ecf7;
    pointer-events: none;
    z-index: 10005;
  }

  /* The right cluster covers that line, so the same edge is drawn on the cluster. */
  .nav-header--desktop .nav-header__user-controls::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 1px;
    background-color: #e2ecf7;
    pointer-events: none;
    z-index: 1;
  }

  html.theme-dark .nav-header--desktop .nav-header__user-controls::after {
    background-color: var(--color-border-subtle);
  }
}

html.theme-dark .nav-header--desktop .logo-container {
  background-color: var(--color-page);
}

html.theme-dark .nav-header--mobile {
  background-color: var(--color-page);
  color: var(--color-on-surface);
}

html.theme-dark .nav-header--mobile .nav-header__container {
  background-color: transparent;
}

html.theme-dark .mobile-hamburger-circle {
  background-color: var(--button-grey-bg, #3f4d69);
}

/*
  Bell + magnifier dark paint lives here: nested html.theme-dark under the nav
  controller never matches. Keep the same blue as the light magnifier (#6e9fd5),
  not the pale --color-link wash.
*/
html.theme-dark .customer-search-trigger,
html.theme-dark .customer-search-trigger--desktop,
html.theme-dark .service-announcements-slot .service-announcements-button:not(.hidden),
html.theme-dark .service-announcements-slot .service-announcements-button:hover,
html.theme-dark .service-announcements-slot .service-announcements-button:focus-visible,
html.theme-dark .nav-header__user-controls .service-announcements-button {
  color: var(--blue-base-legacy, #6e9fd5);
  background-color: transparent;
}

html.theme-dark .customer-search-trigger:hover,
html.theme-dark .customer-search-trigger:focus-visible,
html.theme-dark .customer-search-trigger--desktop:hover,
html.theme-dark .customer-search-trigger--desktop:focus-visible,
html.theme-dark .service-announcements-slot .service-announcements-button:hover,
html.theme-dark .service-announcements-slot .service-announcements-button:focus-visible,
html.theme-dark .nav-header__user-controls .service-announcements-button:hover,
html.theme-dark .nav-header__user-controls .service-announcements-button:focus-visible {
  color: var(--bodymaja, #5696dc);
  background-color: transparent;
}

html.theme-dark .mobile-hamburger-circle .nav-toggle::before,
html.theme-dark .mobile-hamburger-circle .nav-toggle::after,
html.theme-dark .mobile-hamburger-circle .nav-toggle__inner {
  background-color: var(--color-on-surface, #ffffff);
}

html.theme-dark #user-top-chrome {
  background-color: var(--color-page);
  box-shadow: inset 0 -1px 0 var(--color-border-subtle);
  border-bottom: none;
  width: 100%;
  left: 0;
  right: 0;
}

html.theme-dark .nav-header--desktop .nav-header__links {
  /* Bottom hairline lives on the full-width header; drop the links-only top rule. */
  border-top-color: transparent;
}

html.theme-dark .nav-header__logo-symbol,
html.theme-dark .nav-header__logo-symbol.bg-purple-950 {
  background: var(--color-page);
}

html.theme-dark .nav-header__logotype {
  background: var(--color-page);
  /* No purple plate in dark; left padding would be empty space before the wordmark. */
  padding-left: 0;
}

.repurchase-graph {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
}

.repurchase-graph--dark {
  display: none;
}

html.theme-dark .repurchase-graph--light {
  display: none;
}

html.theme-dark .repurchase-graph--dark {
  display: block;
}

.site-wrapper__footer .footer-logo--dark {
  display: none;
}

html.theme-dark .nav-header__logotype-img {
  filter: brightness(0) invert(1);
}

html.theme-dark .site-wrapper__footer .footer-logo--light {
  display: none;
}

html.theme-dark .site-wrapper__footer .footer-logo--dark {
  display: block;
}

html.theme-dark #left-links a:not(.nav-link--external).nav-item-selected-gradient {
  background: linear-gradient(
    121.92deg,
    var(--nav-item-selected-start) -1.88%,
    var(--nav-item-selected-end) 89.66%
  );
  border-bottom: 4px solid var(--bodymaja, #5696dc);
}

html.theme-dark .mobile-menu-panel > div.flex a.nav-item-selected-gradient {
  background: linear-gradient(
    121.92deg,
    var(--nav-item-selected-start) -1.88%,
    var(--nav-item-selected-end) 89.66%
  );
}

html.theme-dark .nav-header--desktop .nav-link__icon,
html.theme-dark .nav-header--desktop .nav-link__arrow,
html.theme-dark .nav-header--desktop .nav-link__arrow-icon,
html.theme-dark .nav-header--mobile .nav-link__icon,
html.theme-dark #user-top-chrome .nav-link__icon,
html.theme-dark #left-links .nav-menu-item__icon,
html.theme-dark .nav-menu-item__icon,
html.theme-dark .mobile-menu__item-icon,
html.theme-dark .mobile-menu__language-icon {
  color: var(--bodymaja, #5696dc);
}

html.theme-dark .menu-measurement-info,
html.theme-dark .menu-measurement-info strong {
  color: var(--color-muted, #c0c5d3);
}

html.theme-dark .menu-measurement-link,
html.theme-dark .menu-measurement-link-separator {
  color: var(--bodymaja, #5696dc);
}

html.theme-dark .menu-measurement-btn {
  background: var(--login-button-bg);
  color: var(--color-on-surface, #ffffff);
}

html.theme-dark .menu-measurement-btn:hover {
  background: var(--login-button-bg-hover);
  opacity: 1;
}

html.theme-dark .measurement-notice__open-door {
  background: var(--login-button-bg) !important;
  color: var(--color-on-surface, #ffffff);
}

html.theme-dark .measurement-notice__open-door:hover {
  background: var(--login-button-bg-hover) !important;
}

/* Dark-only: language trigger matches dropdown panel + item hover surfaces. */
html.theme-dark .navigation-list__link--dropdown > .nav-link__content.button.button--grey {
  height: 1.5rem;
  min-width: auto;
  padding: 0 8px;
  gap: 8px;
  border-radius: var(--radius-md, 8px);
  font-weight: 600;
  font-size: 0.75rem;
  line-height: 1.5rem;
  letter-spacing: 0.005rem;
  background-color: var(--color-surface, #141924);
  color: var(--color-on-surface, #ffffff);
}

html.theme-dark .navigation-list__link--dropdown > .nav-link__content.button.button--grey:hover {
  background-color: var(--own-results-add-card-bg-hover, #242b3d);
  color: var(--color-on-surface, #ffffff);
}

html.theme-dark .navigation-list__link--dropdown > .nav-link__content.button.button--grey .nav-link__label {
  color: inherit;
}

html.theme-dark .navigation-list__link--dropdown > .nav-link__content.button.button--grey .nav-link__icon,
html.theme-dark .navigation-list__link--dropdown > .nav-link__content.button.button--grey .nav-link__arrow,
html.theme-dark .navigation-list__link--dropdown > .nav-link__content.button.button--grey .nav-link__arrow-icon {
  color: var(--bodymaja, #5696dc);
}

html.theme-dark .navigation-list__link--dropdown > .nav-link__content.button.button--grey .nav-link__arrow {
  margin-inline-start: 0;
}

html.theme-dark .logo-container,
html.theme-dark [data-controller="user--navigation"] #left-links,
html.theme-dark .nav-header--desktop .nav-header__user-controls {
  background-color: var(--color-page);
}

html.theme-dark .nav-header__logotype-img--light {
  display: none;
}

html.theme-dark .nav-header__logotype-img--dark {
  display: block;
}

html.theme-dark .user-profile-popover,
html.theme-dark .mobile-menu-panel,
html.theme-dark .navigation-list__submenu--active {
  background-color: var(--color-surface);
  color: var(--color-on-surface);
  box-shadow: var(--popover-shadow);
}

html.theme-dark .mobile-menu-panel > div.flex a,
html.theme-dark .mobile-menu-panel > div.flex a .nav-link__label,
html.theme-dark .mobile-menu-panel > div.flex a:hover > span.nav-link__label,
html.theme-dark .mobile-menu__item,
html.theme-dark button.mobile-menu__item,
html.theme-dark .mobile-menu__item-label,
html.theme-dark .mobile-menu__language-label,
html.theme-dark .mobile-menu-panel .mobile-menu__locale-link,
html.theme-dark .mobile-menu-panel .mobile-menu__locale-link--active,
html.theme-dark .mobile-menu-panel a.mobile-menu__locale-link:hover,
html.theme-dark .mobile-menu-panel button.mobile-menu__locale-link:hover,
html.theme-dark .mobile-menu-panel .mobile-menu__locale-separator {
  color: var(--color-on-surface);
}

html.theme-dark .mobile-menu-panel .mobile-menu__locale-link--active {
  background-color: var(--color-surface-subtle);
}

html.theme-dark button.mobile-menu__item.mobile-menu__item--sign-out,
html.theme-dark .mobile-menu__item--sign-out .mobile-menu__item-label,
html.theme-dark .mobile-menu__item--sign-out svg {
  color: #c5d9ee;
}

html.theme-dark .mobile-menu-panel .nav-link__count-badge {
  box-sizing: border-box;
  align-self: center;
  background-color: var(--color-blue, #4bc1e5);
  color: var(--color-surface, #141924);
  height: 20px;
  min-height: 20px;
  max-height: 20px;
  min-width: 20px;
  padding: 0 8px;
  font-size: 12px;
  line-height: 20px;
  font-stretch: normal;
}

html.theme-dark .mobile-menu__separator {
  border-top: 1px solid var(--color-border-subtle);
  background-color: transparent;
}

html.theme-dark .mobile-menu__section-label {
  color: var(--color-muted);
}

html.theme-dark .user-profile-popover .mobile-menu__item:hover,
html.theme-dark .user-profile-popover .mobile-menu__item:focus-visible,
html.theme-dark .user-profile-popover button.mobile-menu__item:hover,
html.theme-dark .user-profile-popover button.mobile-menu__item:focus-visible,
html.theme-dark .navigation-list__submenu .nav-link--menuitem:hover,
html.theme-dark .navigation-list__submenu .nav-link--menuitem:focus-visible {
  background-color: var(--own-results-add-card-bg-hover, #242b3d);
}

html.theme-dark .navigation-list__submenu .nav-link--menuitem,
html.theme-dark .navigation-list__submenu .nav-link--menuitem .nav-link__label {
  color: var(--color-on-surface);
}

html.theme-dark .navigation-list__submenu .nav-link--menuitem:hover .nav-link__label,
html.theme-dark .navigation-list__submenu .nav-link--menuitem:focus-visible .nav-link__label {
  color: var(--color-muted);
}

html.theme-dark .navigation-list__submenu .nav-link__icon-img:not(.nav-list__filler-icon) {
  filter: brightness(0) invert(1);
}

html.theme-dark .own-results-add-card {
  background-color: var(--own-results-add-card-bg);
  color: var(--own-results-add-card-color);
}

html.theme-dark .own-results-add-card:hover {
  background-color: var(--own-results-add-card-hover-bg);
}

html.theme-dark .own-results-add-card:focus-visible {
  outline-color: var(--color-link);
}

html.theme-dark .date-range-preset {
  background-color: var(--date-range-preset-bg);
  color: var(--date-range-preset-fg);
}

html.theme-dark .date-range-preset:hover {
  background-color: var(--date-range-preset-bg-hover, #3f4d69);
  color: var(--date-range-preset-fg-hover, #ffffff);
}

html.theme-dark .date-range-preset--active {
  background-color: var(--date-range-preset-active-bg);
  color: var(--date-range-preset-active-fg);
  box-shadow: 0 0 0 1px var(--date-range-preset-active-ring);
}

html.theme-dark .order-history-period-filter__presets .date-range-preset--active {
  color: var(--color-link);
  border-color: var(--color-link);
  box-shadow: 0 2px 6px rgb(0 0 0 / 35%);
}

html.theme-dark .border-purple-950 {
  border-color: var(--color-heading);
}

html.theme-dark .hover\:text-purple-950:hover {
  color: var(--color-heading);
}

html.theme-dark .own-results-combobox-search {
  background-color: var(--color-surface-subtle);
  color: var(--color-on-surface);
  border-color: var(--color-border-subtle);
}

html.theme-dark .own-results-modal-heading-icon {
  color: var(--color-neutral-gray, #646464);
}

html.theme-dark .own-results-heading-icon {
  color: var(--color-neutral-gray, #646464);
  opacity: 0.75;
}

html.theme-dark .own-results-filter-section-title {
  color: var(--color-link);
}

html.theme-dark .laboratory-test-circle-chart__percent {
  color: var(--color-on-surface);
}

html.theme-dark .dashboard-tab-button.text-blue-600,
html.theme-dark .dashboard-tab-button.hover\:text-blue-600:hover {
  color: var(--color-link);
}

html.theme-dark .dashboard-tab-button.border-blue-600 {
  border-color: var(--color-link);
}

html.theme-dark .dashboard-tab-button.text-blue-500 {
  color: color-mix(in srgb, var(--color-link) 70%, var(--color-muted));
}

/* Measurement sessions: card surfaces, shadows, order-select chrome */
html.theme-dark .shadow,
html.theme-dark .shadow-sm,
html.theme-dark .shadow-md,
html.theme-dark .shadow-lg {
  box-shadow: var(--popover-shadow);
}

html.theme-dark .order-select-container:not(.order-select-container--compact),
html.theme-dark .inbody-score-card,
html.theme-dark .result-card,
html.theme-dark .overview-card {
  box-shadow: var(--popover-shadow);
}

html.theme-dark .order-select-container:not(.order-select-container--compact):not(.measurement-session-island) {
  background-color: transparent;
  box-shadow: none;
  color: var(--color-on-surface);
}

html.theme-dark .order-select-container .dropdown-toggle {
  background-color: var(--color-surface);
  color: var(--color-on-surface);
  border-color: var(--color-border-subtle);
}

html.theme-dark .order-select-row__number {
  color: var(--color-muted, #c0c5d3);
}

html.theme-dark .order-select-container .dropdown-toggle.focus\:border-blue-600:focus,
html.theme-dark .order-select-container .dropdown-toggle:focus,
html.theme-dark .order-select-container .dropdown-toggle:focus-visible {
  border-color: var(--color-focus-ring, var(--color-link));
}

html.theme-dark .order-select-container .dropdown-item {
  color: var(--color-on-surface);
}

html.theme-dark .order-select-container .order-select__action-link,
html.theme-dark .order-select-container .order-select__show-order,
html.theme-dark .order-select-container .order-select__buy-again {
  color: var(--color-link);
}

html.theme-dark .order-select-container .order-select__show-order:hover,
html.theme-dark .order-select-container .order-select__show-order:focus-visible,
html.theme-dark .order-select-container .order-select__buy-again:hover,
html.theme-dark .order-select-container .order-select__buy-again:focus-visible {
  color: var(--bodymaja, #5696dc);
}

html.theme-dark .order-select-container .body-composition-order-select__section-link,
html.theme-dark .order-select-container .body-composition-order-select__text-button,
html.theme-dark .body-composition-order-select__print-wrap .body-composition-order-select__text-button {
  color: var(--color-link);
}

html.theme-dark .order-select-container .body-composition-order-select__section-link:hover,
html.theme-dark .order-select-container .body-composition-order-select__text-button:hover,
html.theme-dark .body-composition-order-select__print-wrap .body-composition-order-select__text-button:hover {
  color: var(--bodymaja, #5696dc);
}

html.theme-dark .order-select-container .body-composition-order-select__section-link:focus,
html.theme-dark .order-select-container .body-composition-order-select__text-button:focus,
html.theme-dark .body-composition-order-select__print-wrap .body-composition-order-select__text-button:focus-visible {
  outline-color: var(--color-link);
}

html.theme-dark .body-composition-order-select__print-wrap .body-composition-order-select__text-button img {
  filter: brightness(0) invert(1);
}

html.theme-dark .inbody-score-card,
html.theme-dark .overview-card__content,
html.theme-dark .overview-card__inner {
  background-color: var(--color-surface);
  color: var(--color-on-surface);
}

/* Result cards: body copy inherits leipäteksti; titles keep white via heading utilities. */
html.theme-dark .result-card__content,
html.theme-dark .result-card__title-block,
html.theme-dark .result-card__chart-block,
html.theme-dark .result-card__details-panel {
  background-color: var(--color-surface);
  color: var(--color-body);
}

html.theme-dark .result-card__details-panel {
  box-shadow: none;
}

html.theme-dark .result-card__title-block h2,
html.theme-dark .result-card__details-panel h2 {
  color: var(--color-heading);
}

html.theme-dark .bg-\[\#E0F0EB\] {
  background-color: var(--color-surface-subtle);
}

/* Change-from-previous chips and range previous-value pills */
.result-text__change-from-previous,
.range-chart__change-from-previous,
.bp-change-from-previous {
  background-color: var(--result-change-chip-bg, #f3f4f7);
  border: 0.8px solid var(--result-change-chip-border, #e0e2e9);
  color: var(--result-change-chip-fg, #39235d);
  font-weight: 600;
}

/* Match the lab-results chip. Tailwind mt-2 is 0.4rem here (--spacing is
   0.2rem), about 8px, while the lab chip uses 16px. px-* has the same scale. */
.result-text__change-from-previous {
  margin-top: 16px;
  padding-left: 8px;
  padding-right: 8px;
}

.result-text__change-label--desktop {
  display: none;
}

/* Wide result card. The long change label fits. Narrow cards keep the short one. */
@media (min-width: 768px) {
  .result-text__change-label--mobile {
    display: none;
  }

  .result-text__change-label--desktop {
    display: inline;
  }
}

.range-slider__previous-label,
.range-slider .marker-label--previous {
  background-color: var(--result-previous-chip-bg, var(--result-change-chip-bg, #f3f4f7));
  border: 0.8px solid var(--result-change-chip-border, #e0e2e9);
  color: var(--result-change-chip-fg, #39235d);
}

html.theme-dark .result-text__change-from-previous.text-purple-950,
html.theme-dark .range-chart__change-from-previous.text-purple-950,
html.theme-dark .result-text__change-from-previous,
html.theme-dark .range-chart__change-from-previous,
html.theme-dark .bp-change-from-previous,
html.theme-dark .bp-change-from-previous .text-purple-950,
html.theme-dark .bp-change-from-previous .bp-summary-change-label,
html.theme-dark .bp-change-from-previous .bp-summary-change-value,
html.theme-dark .range-slider__previous-label,
html.theme-dark .range-slider .marker-label--previous {
  color: var(--result-change-chip-fg, #c0c5d3);
}

html.theme-dark .bp-change-from-previous {
  border-color: transparent;
}

.result-card__show-more {
  color: var(--result-show-more-fg, #016d81);
}

html.theme-dark .result-card__show-more {
  background-color: var(--bg-blue-lightest, var(--blue-lightest, #f3f7fb));
  border-top-color: var(--color-border-subtle);
  color: var(--result-show-more-fg, #a8c5e6);
}

html.theme-dark .result-card__show-more p,
html.theme-dark .result-card__show-more span,
html.theme-dark .result-card__show-more .result-card__show-more-icon {
  color: var(--result-show-more-fg, #a8c5e6);
  stroke: var(--result-show-more-fg, #a8c5e6);
}

/* Stacked card. The sections sit on top of each other, so the divider is a top border. */
@media (max-width: 47.99rem) {
  /* Open details continue below this bar, so it is no longer the card's bottom corner. */
  details.group[open] .result-card__show-more {
    border-bottom-right-radius: 0;
  }

  .result-card .result-card__chart-block,
  .result-card .result-card__details-chart {
    border-top-width: 2px;
    border-top-style: solid;
    border-left-width: 0;
    border-top-right-radius: 0;
  }
}

/* Side-by-side card. The open details panel is the card's bottom-right corner. */
@media (min-width: 48rem) {
  .result-card__details-panel,
  .result-card__details-chart {
    border-bottom-right-radius: var(--radius-lg, 12px);
  }

  .result-card__details-chart {
    border-top-right-radius: 0;
  }
}

/* Title and ring share one row until the header is wide enough for two columns. */
.report-summary-header {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
  min-width: 0;
  max-width: 100%;
}

.report-summary-header__copy {
  flex: 1 1 0;
  min-width: 0;
}

/* Wide header. The ring gets its own column so a long title cannot push it. */
@media (min-width: 992px) {
  .report-summary-header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    column-gap: 0.75rem;
    align-items: start;
  }
}

/* Blood sample and date. Icon and label share one grid row.
   0.3rem is the production gap. px-3 is 0.6rem with this app's spacing step. */
.report-summary-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.375rem;
  margin-left: -0.25rem;
}

.report-summary-meta__item {
  display: grid;
  grid-template-columns: 22px minmax(0, auto);
  align-items: center;
  column-gap: 0.3rem;
  padding-left: 3px;
}

.report-summary-meta__icon {
  width: 22px;
  height: 22px;
}

.report-summary-meta__label {
  margin: 0;
}

/* Wide header. The sample and the date fit on one row. */
@media (min-width: 992px) {
  .report-summary-meta {
    flex-direction: row;
    align-items: center;
    gap: 1rem;
    margin-left: 0;
  }

  .report-summary-meta__item {
    padding-left: 0;
  }
}

/* Caption under the ring. Beside it, the row is wider than a narrow header. */
.report-summary-pie-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.375rem;
  width: fit-content;
  max-width: 100%;
}

.report-summary-pie-block__caption {
  margin: 0;
  padding: 0;
  width: max-content;
  max-width: 100%;
  text-align: center;
  line-height: 1.25;
  white-space: nowrap;
}

/* Wide header. The caption sits beside the ring. */
@media (min-width: 992px) {
  .report-summary-pie-block {
    flex-direction: row;
    align-items: center;
    gap: 0;
  }

  .report-summary-pie-block__caption {
    padding-left: 0.5rem;
    text-align: left;
  }
}

/* 75px ring so it fits the narrow header. The percent is HTML. The ring is SVG. */
.report-summary-pie {
  position: relative;
  box-sizing: border-box;
  width: 75px;
  height: 75px;
  min-width: 75px;
  min-height: 75px;
  padding: 0;
  flex-shrink: 0;
}

.report-summary-pie-slot {
  z-index: 20;
  display: flex;
  flex: 0 0 auto;
  align-items: flex-start;
  justify-content: flex-end;
  align-self: flex-start;
  width: fit-content;
  max-width: 100%;
  min-width: 0;
  padding: 0;
  overflow: hidden;
}

.report-summary-pie__chart {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  line-height: 0;
}

.report-summary-pie__chart svg {
  display: block;
}

.report-summary-pie__label {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.report-summary-pie__value {
  color: var(--color-label-green, #0a8525);
  font-weight: 600;
  font-size: 1.25rem;
  line-height: 1;
  white-space: nowrap;
  transform: translateX(0.12em);
}

.report-summary-pie__percent {
  margin-left: 0.2em;
  color: var(--color-on-surface, #1c1f28);
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1;
}

.report-summary-pie__value--full {
  font-size: 1rem;
}

/* Wide header. The ring grows once it has its own column. */
@media (min-width: 992px) {
  .report-summary-pie {
    width: 110px;
    height: 110px;
  }

  .report-summary-pie__value--full {
    font-size: 1.25rem;
  }
}

html.theme-dark .report-summary-pie__value,
html.theme-dark .report-summary-pie__percent {
  color: var(--color-on-surface, #ffffff);
}

#order_report_summary {
  margin-top: 1rem;
}

.summary-chevron {
  color: var(--color-blue, #4bc1e5);
  /* Narrow summary row. A fixed size, because w-6 grows with the root font. */
  width: 24px;
  height: 24px;
}

/* Wide summary row. The chevron can use the spacing scale. */
@media (min-width: 768px) {
  .summary-chevron {
    width: calc(var(--spacing) * 6);
    height: calc(var(--spacing) * 6);
  }
}

html.theme-dark .summary-chevron {
  color: var(--color-link, #c5d9ee);
}

.summary-result-pills {
  gap: 0.25rem;
}

.summary-result-pill {
  box-shadow: 0 1px 1px rgb(28 31 40 / 8%);
}

html.theme-dark .summary-result-pill {
  background-color: var(--button-grey-bg, #3f4d69);
  color: var(--color-on-surface, #ffffff);
  box-shadow: 0 1px 2px rgb(0 0 0 / 35%);
}

.report-summary-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem;
  background: var(--bg-blue-lightest);
  border-bottom-left-radius: 0.5rem;
  border-bottom-right-radius: 0.5rem;
}

.report-summary-actions__links {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  margin-left: auto;
}

.report-summary-actions__link {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  margin-right: 1rem;
  padding: 0.5rem;
  color: var(--blue-darker-legacy, #2d5a8a);
  font-weight: 500;
  line-height: 1.25rem;
  text-decoration: none;
}

.report-summary-actions__link:last-child {
  margin-right: 0;
}

.report-summary-actions__icon {
  display: flex;
  width: 1.125rem;
  height: 1.125rem;
  flex-shrink: 0;
  color: var(--blue-base-legacy, #6e9fd5);
}

.report-summary-actions__icon svg {
  display: block;
  width: 100%;
  height: 100%;
}

.report-summary-actions__label {
  margin: 0;
  text-decoration: none;
}

.report-summary-actions__link:hover,
.report-summary-actions__link:focus-visible {
  color: var(--blue-base-legacy, #6e9fd5);
}

.report-summary-actions__link:hover .report-summary-actions__label,
.report-summary-actions__link:focus-visible .report-summary-actions__label {
  text-decoration: underline;
  text-decoration-color: currentColor;
}

html.theme-dark .report-summary-actions a.report-summary-actions__link,
html.theme-dark .report-summary-actions__icon,
html.theme-dark .order-results-customize__trigger,
html.theme-dark .order-results-customize__trigger:hover,
html.theme-dark .order-results-customize__trigger:focus-visible,
html.theme-dark .order-results-customize__icon,
html.theme-dark .order-results-customize__label {
  color: var(--color-link, #c5d9ee);
}

/* Narrow report. Customize, help, and print become full-width rows. */
@media (max-width: 991px) {
  .report-summary-actions {
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 0;
  }

  .report-summary-actions__links {
    margin-left: 0;
    flex-direction: column;
    align-items: stretch;
  }

  .report-summary-actions__link {
    margin: 0;
    border-top: 0;
    border-right: 0;
    border-left: 0;
    border-bottom: 1px solid var(--color-border-subtle);
    border-radius: 0;
  }

  .report-summary-actions__links .report-summary-actions__link:last-child {
    border-bottom: 0;
    border-bottom-left-radius: 0.5rem;
    border-bottom-right-radius: 0.5rem;
  }
}

html:not(.theme-dark) #order_report_summary {
  box-shadow: var(--popover-shadow);
}

html.theme-dark #order_report_summary {
  box-shadow: none;
  border-left-width: 0;
  border-right-width: 0;
}

/* Narrow summary rows. The color bar stays on the left, where a bottom bar is easy to miss. */
.summary-accent--outside,
.summary-accent--within {
  border-left-width: 6px;
  border-left-style: solid;
}

.summary-accent--outside {
  border-left-color: var(--result-range-bar-red, #f87171);
}

.summary-accent--within {
  border-left-color: var(--result-range-bar-green, #0dab30);
}

/* Wide summary rows. The color bar moves to the bottom of the band. */
@media (min-width: 992px) {
  .summary-accent--outside,
  .summary-accent--within {
    border-left-width: 1px;
    border-left-color: var(--color-gray-200, #e0e2e9);
    border-right-color: var(--color-gray-200, #e0e2e9);
    border-bottom-width: 6px;
    border-bottom-style: solid;
  }

  .summary-accent--outside {
    border-bottom-color: var(--result-range-bar-red, #f87171);
  }

  .summary-accent--within {
    border-bottom-color: var(--result-range-bar-green, #0dab30);
  }

  html.theme-dark .summary-accent--outside,
  html.theme-dark .summary-accent--within {
    border-left-color: var(--color-border-subtle);
    border-right-color: var(--color-border-subtle);
  }
}

html.theme-dark .summary-accent--outside,
html.theme-dark .summary-accent--within,
html.theme-dark .summary-accent--none {
  border-top-color: var(--color-border-subtle);
}

/* The card drops its side border in dark mode. This row draws the same left edge as the rows above. */
html.theme-dark .summary-accent--none {
  border-left-width: 6px;
  border-left-style: solid;
  border-left-color: var(--color-muted, #c0c5d3);
}

@media (min-width: 992px) {
  html.theme-dark .summary-accent--none {
    border-left-width: 1px;
    border-right-width: 1px;
    border-right-style: solid;
    border-left-color: var(--color-border-subtle);
    border-right-color: var(--color-border-subtle);
  }
}

/* Range chart reference limits and bars: solid status green/red in dark mode */
html.theme-dark .range-slider__min,
html.theme-dark .range-slider__max,
html.theme-dark .range-slider .text-red-450,
html.theme-dark .range-slider .text-red-400,
html.theme-dark .range-slider .color-red-dark {
  color: var(--result-ref-label-red, #ea5858);
}

html.theme-dark .range-slider .text-green-700,
html.theme-dark .range-slider .text-green-600,
html.theme-dark .range-slider .text-green-500,
html.theme-dark .range-slider .color-green,
html.theme-dark .range-slider .color-green-dark {
  color: var(--result-ref-label-green, #46c462);
}

/* Status sentences render beside the chart, outside .range-slider. */
html.theme-dark .inline-icon-text.color-red-dark,
html.theme-dark .inline-icon-text.color-red-dark .inline-icon-text__icon,
html.theme-dark .result-text .text-red-600 {
  color: var(--chart-negative, #ea5858);
}

html.theme-dark .inline-icon-text.color-green-dark,
html.theme-dark .inline-icon-text.color-green-dark .inline-icon-text__icon,
html.theme-dark .result-text .text-green-500,
html.theme-dark .overview-card .text-green-500 {
  color: var(--chart-positive, #46c462);
}

/* Match the blood-test status line: 1rem icon, body copy, 0.25rem gap. */
.result-text > .flex {
  font-size: 0.67rem;
  line-height: 1rem;
}

.result-text__status-icon {
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
  margin-right: 0.25rem;
}

/* Second green segment keeps legacy dark green (Puristusvoima / green-450). */
html.theme-dark .range-slider .text-green-450 {
  color: var(--result-range-bar-green-dark, #157f2c);
}

html.theme-dark .range-slider .bg-red,
html.theme-dark .range-slider .bg-red-400,
html.theme-dark .range-slider .bg-red-600,
html.theme-dark .range-slider__bar.bg-red {
  background-color: var(--result-range-bar-red, #ea5858);
}

html.theme-dark .range-slider .bg-green,
html.theme-dark .range-slider .bg-green-600,
html.theme-dark .range-slider .bg-green-500,
html.theme-dark .range-slider__bar.bg-green,
html.theme-dark .range-slider__midpoint-marker,
html.theme-dark .range-slider__green-midpoint-marker {
  background-color: var(--result-range-bar-green, #46c462);
}

html.theme-dark .range-slider .bg-green-450 {
  background-color: var(--result-range-bar-green-dark, #157f2c);
}

html.theme-dark .range-slider .bg-yellow-500,
html.theme-dark .range-slider .bg-yellow-600,
html.theme-dark .range-slider__recommendation {
  background-color: var(--result-range-bar-yellow, #e2b53f);
}

html.theme-dark .range-slider .text-yellow-700,
html.theme-dark .range-slider .text-yellow-600,
html.theme-dark .range-slider__recommendation,
html.theme-dark .range-slider__recommendation:after {
  color: var(--result-range-bar-yellow, #e2b53f);
}

/* Login notice icon strip. background-color cannot paint the dark gradient. */
html.theme-dark .login-notice .bg-blue {
  background: var(--dark-gradient, linear-gradient(180deg, rgba(63, 77, 105, 0.70) 0%, rgba(63, 77, 105, 0.61) 100%));
}

/* Body-measurement notice icon. bg-blue-400 is the light blue and does not flip. */
html.theme-dark .measurement-notice__icon {
  background: var(--dark-gradient, linear-gradient(180deg, rgba(63, 77, 105, 0.70) 0%, rgba(63, 77, 105, 0.61) 100%));
}

/* Lab-result notice icon. One step lighter than the shared dark gradient (#3f4d69 -> #52607a). */
html.theme-dark .notice__icon {
  background: linear-gradient(180deg, rgba(82, 96, 122, 0.70) 0%, rgba(82, 96, 122, 0.61) 100%);
}

/* React lab-order leftover surfaces (hybrid until Phlex owns /orders/:id).
   Prefer tokens in React Sass; these catch CSS-module and leftover hardcodes. */
html.theme-dark .react-shell {
  color: var(--color-body);
}

html.theme-dark .react-shell .card:not(.card--purple):not(.card--yellow),
html.theme-dark .react-shell .suggestion-item,
html.theme-dark .react-shell .notice {
  background-color: var(--color-surface) !important;
  color: var(--color-body);
  box-shadow: var(--popover-shadow);
}

html.theme-dark .react-shell .card .color-purple,
html.theme-dark .react-shell .result-box__main > h2 {
  color: var(--color-heading);
}

/* Disclaimer paragraph under the results heading. Darker than the white title. */
html.theme-dark .disclaimer-subtitle,
html.theme-dark .notice-text__body {
  color: var(--color-body);
}

html.theme-dark .react-shell .result-box__main .markdown-content {
  color: var(--color-body);
}

html.theme-dark .react-shell .split-card {
  background-color: var(--color-surface) !important;
  color: var(--color-on-surface);
  box-shadow: var(--login-card-shadow, none);
}

html.theme-dark .react-shell .suggestion-item__footer,
html.theme-dark .react-shell .select-order__footer,
html.theme-dark .react-shell .disabled-card,
html.theme-dark .react-shell .result-box__footer,
html.theme-dark .react-shell .result-box__footer-desktop,
html.theme-dark .react-shell .result-box__left--grey,
html.theme-dark .react-shell .result-box__right--grey,
html.theme-dark .react-shell .result-box__right--pending {
  background-color: var(--color-surface-subtle) !important;
  color: var(--color-on-surface);
}

html.theme-dark .react-shell .result-box__label,
html.theme-dark .react-shell .result-box__comparison,
html.theme-dark .react-shell .result-box__more-notice {
  color: var(--color-heading) !important;
}

html.theme-dark .react-shell .result-box__readmore {
  color: var(--result-show-more-fg, #a8c5e6) !important;
}

html.theme-dark .react-shell .result-box__comparison svg {
  stroke: var(--color-heading) !important;
}

html.theme-dark .react-shell .result-box__readmore svg {
  stroke: var(--result-show-more-fg, #a8c5e6) !important;
}

html.theme-dark .react-shell .result-box__value,
html.theme-dark .react-shell .result-box__statement,
html.theme-dark .react-shell .result-box__pending {
  color: var(--color-muted) !important;
}

html.theme-dark .react-shell .promotions-banner-container,
html.theme-dark .promotions-banner-container {
  background-color: var(--color-surface) !important;
  color: var(--color-on-surface);
}

html.theme-dark .promotions-banner-container .button.button--white,
html.theme-dark .promotions-banner-container .button.button--white_outlined {
  background: var(--login-button-bg);
  color: var(--color-on-surface, #ffffff);
  box-shadow: none;
}

html.theme-dark .promotions-banner-container .button.button--white:hover,
html.theme-dark .promotions-banner-container .button.button--white_outlined:hover {
  background: var(--login-button-bg-hover);
  color: var(--color-on-surface, #ffffff);
  opacity: 1;
}

html.theme-dark .blood-test-react-boot-overlay {
  background-color: var(--color-page);
  color: var(--color-on-surface);
}

html.theme-dark .page-header__heading {
  color: var(--color-heading) !important;
}

html.theme-dark .page-header__subheading {
  color: var(--color-muted) !important;
}

html.theme-dark .own-results-add-card__face {
  background-color: transparent !important;
  background-image: linear-gradient(
    var(--own-results-add-card-bg),
    var(--own-results-add-card-bg)
  ) !important;
}

html.theme-dark .own-results-add-card:hover .own-results-add-card__face {
  background-image: linear-gradient(
    var(--own-results-add-card-hover-bg),
    var(--own-results-add-card-hover-bg)
  ) !important;
}
