:root {
  color-scheme: light;
  --spacecore-brand-primary: #8238f5;
  --spacecore-brand-primary-hover: #6d25d9;
  --spacecore-brand-primary-active: #5719b5;
  --spacecore-brand-primary-soft: #f1e8ff;
}

:root[dark="true"] {
  color-scheme: dark;
  --spacecore-brand-primary: #a66bff;
  --spacecore-brand-primary-hover: #8d4eef;
  --spacecore-brand-primary-active: #7435d2;
  --spacecore-brand-primary-soft: #442663;

  /* SpaceCore website palette: aubergine surfaces, violet and coral accents. */
  --isp-background-main-basis: 263deg, 47%;
  --isp-background-main-lightness: 15.5%;
  --isp-background-additional-basis: 264deg, 42%;
  --isp-background-additional-lightness: 21%;
  --isp-background-contrast-basis: 264deg, 45%;
  --isp-background-contrast-lightness: 18%;
  --isp-background-contrast__hover-basis: 265deg, 43%;
  --isp-background-contrast__hover-lightness: 25%;
  --isp-background-contrast__active-basis: 266deg, 48%;
  --isp-background-contrast__active-lightness: 30%;
  --isp-background-list-basis: 264deg, 39%;
  --isp-background-list-lightness: 23%;
  --isp-background-component-basis: 264deg, 39%;
  --isp-background-component-lightness: 24%;

  --isp-background-primary-basis: 265deg, 90%;
  --isp-background-primary-lightness: 59%;
  --isp-background-primary-inline: hsl(265deg 55% 25%);
  --isp-background-primary-inline__hover: hsl(265deg 58% 29%);
  --isp-background-primary-inline__active: hsl(265deg 61% 33%);

  --isp-background-accent-basis: 348deg, 100%;
  --isp-background-accent-lightness: 70%;
  --isp-text-accent-basis: 348deg, 100%;
  --isp-text-accent-lightness: 72%;

  --isp-text-main-basis: 260deg, 100%;
  --isp-text-main-lightness: 97%;
  --isp-text-additional-basis: 263deg, 24%;
  --isp-text-additional-lightness: 72%;
  --isp-text-contrast-basis: 0deg, 0%;
  --isp-text-contrast-lightness: 100%;
  --isp-text-interactive-basis: 266deg, 100%;
  --isp-text-interactive-lightness: 75%;

  --isp-border-default-basis: 265deg, 28%;
  --isp-border-default-lightness: 35%;
  --isp-border-interactive-basis: 266deg, 100%;
  --isp-border-interactive-lightness: 69%;
  --isp-border-primary-basis: 266deg, 100%;
  --isp-border-primary-lightness: 69%;

  --isp-icon-main-basis: 260deg, 100%;
  --isp-icon-main-lightness: 94%;
  --isp-icon-additional-basis: 263deg, 22%;
  --isp-icon-additional-lightness: 70%;
  --isp-icon-primary-basis: 266deg, 100%;
  --isp-icon-primary-lightness: 72%;

  --isp-neutral-base: hsl(264deg 18% 57%);
  --isp-neutral-lowContrast-10: hsl(264deg 30% 31%);
  --isp-neutral-lowContrast-20: hsl(264deg 32% 27%);
  --isp-neutral-lowContrast-30: hsl(264deg 34% 24%);

  /* Dragon keeps table rows on a separate, blue-based palette. */
  --isp-table-background: hsl(264deg 40% 22%);
  --isp-table-background-odd: hsl(264deg 43% 18%);
  --isp-table-background-hover: hsl(266deg 43% 31%);
  --isp-table-background-selected: hsl(266deg 45% 28%);
  --isp-table-background-odd-selected: hsl(266deg 45% 25%);
  --isp-table-background-even-selected: hsl(266deg 43% 32%);
  --isp-table-background-deleted: hsl(264deg 16% 28%);
}

:root:not([dark="true"]) {
  /* Light SpaceCore palette: white/lavender surfaces with brand accents. */
  --isp-background-main-basis: 266deg, 38%;
  --isp-background-main-lightness: 98%;
  --isp-background-additional-basis: 0deg, 0%;
  --isp-background-additional-lightness: 100%;
  --isp-background-contrast-basis: 264deg, 48%;
  --isp-background-contrast-lightness: 20%;
  --isp-background-contrast__hover-basis: 265deg, 44%;
  --isp-background-contrast__hover-lightness: 27%;
  --isp-background-contrast__active-basis: 266deg, 48%;
  --isp-background-contrast__active-lightness: 32%;
  --isp-background-list-basis: 266deg, 42%;
  --isp-background-list-lightness: 97%;
  --isp-background-component-basis: 266deg, 42%;
  --isp-background-component-lightness: 96%;

  --isp-background-primary-basis: 265deg, 90%;
  --isp-background-primary-lightness: 59%;
  --isp-background-primary-inline: hsl(266deg 100% 97%);
  --isp-background-primary-inline__hover: hsl(266deg 82% 94%);
  --isp-background-primary-inline__active: hsl(266deg 68% 89%);

  --isp-background-accent-basis: 348deg, 100%;
  --isp-background-accent-lightness: 70%;
  --isp-text-accent-basis: 348deg, 82%;
  --isp-text-accent-lightness: 55%;

  --isp-text-main-basis: 264deg, 37%;
  --isp-text-main-lightness: 18%;
  --isp-text-additional-basis: 264deg, 13%;
  --isp-text-additional-lightness: 46%;
  --isp-text-contrast-basis: 0deg, 0%;
  --isp-text-contrast-lightness: 100%;
  --isp-text-interactive-basis: 265deg, 82%;
  --isp-text-interactive-lightness: 55%;

  --isp-border-default-basis: 265deg, 27%;
  --isp-border-default-lightness: 84%;
  --isp-border-interactive-basis: 265deg, 82%;
  --isp-border-interactive-lightness: 59%;
  --isp-border-primary-basis: 265deg, 82%;
  --isp-border-primary-lightness: 59%;

  --isp-icon-main-basis: 264deg, 37%;
  --isp-icon-main-lightness: 22%;
  --isp-icon-additional-basis: 264deg, 13%;
  --isp-icon-additional-lightness: 48%;
  --isp-icon-primary-basis: 265deg, 82%;
  --isp-icon-primary-lightness: 57%;

  --isp-neutral-base: hsl(264deg 10% 50%);
  --isp-neutral-lowContrast-10: hsl(266deg 31% 88%);
  --isp-neutral-lowContrast-20: hsl(266deg 33% 93%);
  --isp-neutral-lowContrast-30: hsl(267deg 33% 96%);

  --isp-table-background: hsl(0deg 0% 100%);
  --isp-table-background-odd: hsl(266deg 40% 97%);
  --isp-table-background-hover: hsl(266deg 58% 94%);
  --isp-table-background-selected: hsl(266deg 62% 91%);
  --isp-table-background-odd-selected: hsl(266deg 58% 89%);
  --isp-table-background-even-selected: hsl(266deg 58% 93%);
  --isp-table-background-deleted: hsl(264deg 12% 94%);
}

/*
 * Provider branding sets navigation colors directly on nested components.
 * These selectors keep active navigation indicators in the SpaceCore palette.
 */
:root:not([dark="true"]) .isp-context__top-header {
  --isp-background-contrast: #34204f !important;
  --isp-text-contrast: #fff !important;
  --isp-text-additional: #c9bddd !important;
  --isp-text-accent: #ff718d !important;
  --isp-neutral-base: #594470 !important;
  --isp-neutral-lowContrast-10: #6d5785 !important;
  --isp-neutral-lowContrast-30: #80699b !important;
}

:root[dark="true"] .isp-context__top-header {
  --isp-background-contrast: #281842 !important;
  --isp-text-contrast: #fff !important;
  --isp-text-additional: #c9bddd !important;
  --isp-text-accent: #ff718d !important;
  --isp-neutral-base: #503968 !important;
  --isp-neutral-lowContrast-10: #654d7c !important;
  --isp-neutral-lowContrast-30: #785f92 !important;
}

isp-tab-bar-item .isp-tab-bar-item__content-wrapper_selected {
  color: var(--spacecore-brand-primary) !important;
}

isp-side-bar .isp-side-bar__sublist_active::before {
  background-color: var(--spacecore-brand-primary) !important;
}

isp-header-top-line .spacecore-theme-toggle {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: flex-start;
  width: 42px;
  height: 24px;
  margin: 0 20px 0 0;
  padding: 2px;
  overflow: hidden;
  border: 1px solid rgb(255 255 255 / 38%);
  border-radius: 999px;
  background: rgb(255 255 255 / 12%);
  color: var(--isp-text-contrast, #fff);
  box-shadow: none;
  cursor: pointer;
  transition: background-color 160ms ease, border-color 160ms ease;
}

isp-header-top-line .spacecore-theme-toggle:hover {
  border-color: rgb(255 255 255 / 72%);
  background: rgb(255 255 255 / 18%);
}

isp-header-top-line .spacecore-theme-toggle:focus-visible {
  outline: 2px solid var(--isp-border-interactive, #1687ff);
  outline-offset: 2px;
}

.spacecore-theme-toggle__thumb {
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--isp-background-primary, #0878e3);
  color: #fff;
  transform: translateX(0);
  transition: transform 180ms ease;
}

.spacecore-theme-toggle__icon {
  width: 12px;
  height: 12px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.spacecore-theme-toggle__sun {
  display: none;
}

:root:not([dark="true"])
  isp-header-top-line
  .spacecore-theme-toggle__thumb {
  transform: translateX(18px);
  background: #fff;
  color: #d97706;
}

:root:not([dark="true"]) .spacecore-theme-toggle__moon {
  display: none;
}

:root:not([dark="true"]) .spacecore-theme-toggle__sun {
  display: block;
}

@media (max-width: 959.98px) {
  isp-header-top-line .spacecore-theme-toggle {
    margin-right: 16px;
  }
}

@media (max-width: 639.98px) {
  isp-header-top-line .spacecore-theme-toggle {
    margin-right: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .spacecore-theme-toggle,
  .spacecore-theme-toggle__thumb {
    transition: none;
  }
}

/*
 * Compact tariff catalogue.
 * The class is added by spacecore-theme.js only for *.order.pricelist pages,
 * so regular BILLmanager card lists retain their default Dragon layout.
 */
:root.spacecore-order-pricelist {
  --spacecore-card-surface: #fff;
  --spacecore-card-border: #ded3eb;
  --spacecore-card-shadow: 0 3px 11px rgb(55 26 88 / 9%);
  --spacecore-card-muted: #756982;
  --spacecore-badge-bg: #e54164;
  --spacecore-badge-text: #fff;
}

:root.spacecore-order-pricelist[dark="true"] {
  --spacecore-card-surface: #35224f;
  --spacecore-card-border: #553b72;
  --spacecore-card-shadow: 0 3px 14px rgb(13 5 27 / 34%);
  --spacecore-card-muted: #bbaed0;
  --spacecore-badge-bg: #ff6685;
}

:root.spacecore-order-pricelist isp-list-cards {
  --isp-list-card-min-width: 218px;
  display: block;
}

:root.spacecore-order-pricelist
  isp-list-cards
  > .list__cards-wrapper {
  grid-template-columns: repeat(auto-fill, minmax(218px, 1fr)) !important;
  gap: 12px !important;
  max-width: none !important;
}

:root.spacecore-order-pricelist isp-list-card {
  --spacecore-card-accent: #1687e8;
  min-width: 0;
}

:root.spacecore-order-pricelist
  isp-list-card:nth-of-type(5n + 1) {
  --spacecore-card-accent: #78ad4f;
}

:root.spacecore-order-pricelist
  isp-list-card:nth-of-type(5n + 2) {
  --spacecore-card-accent: #00a8d8;
}

:root.spacecore-order-pricelist
  isp-list-card:nth-of-type(5n + 3) {
  --spacecore-card-accent: #a358d1;
}

:root.spacecore-order-pricelist
  isp-list-card:nth-of-type(5n + 4) {
  --spacecore-card-accent: #419ca0;
}

:root.spacecore-order-pricelist
  isp-list-card:nth-of-type(5n + 5) {
  --spacecore-card-accent: #dd4938;
}

:root.spacecore-order-pricelist isp-list-card > .list-card {
  box-sizing: border-box;
  min-height: 100%;
  padding: 14px 12px 12px !important;
  overflow: visible;
  border: 1px solid var(--spacecore-card-border) !important;
  border-top: 3px solid var(--spacecore-card-accent) !important;
  border-radius: 6px !important;
  background: var(--spacecore-card-surface) !important;
  box-shadow: var(--spacecore-card-shadow);
  transition:
    border-color 150ms ease,
    box-shadow 150ms ease,
    transform 150ms ease;
}

:root.spacecore-order-pricelist
  isp-list-card
  > .list-card:not(.list-card_disabled):hover {
  border-color: color-mix(
    in srgb,
    var(--spacecore-card-accent) 55%,
    var(--spacecore-card-border)
  ) !important;
  border-top-color: var(--spacecore-card-accent) !important;
  background: var(--spacecore-card-surface) !important;
  box-shadow: 0 5px 16px rgb(20 42 66 / 13%);
  transform: translateY(-1px);
}

:root.spacecore-order-pricelist[dark="true"]
  isp-list-card
  > .list-card:not(.list-card_disabled):hover {
  box-shadow: 0 5px 18px rgb(0 0 0 / 32%);
}

:root.spacecore-order-pricelist
  isp-list-card
  .list-card__terms-wrapper {
  row-gap: 10px !important;
  column-gap: 10px !important;
}

:root.spacecore-order-pricelist
  isp-list-card
  .list-card__header {
  margin-bottom: 2px;
}

:root.spacecore-order-pricelist
  isp-list-card
  .list-card__header
  isp-list-card-term:first-child {
  color: var(--spacecore-card-accent);
  font-weight: 650;
}

:root.spacecore-order-pricelist
  isp-list-card
  .list-card__header
  isp-list-card-term:first-child
  :is(
    .isp-list-cell-text,
    .isp-struct-cell__data,
    isp-link,
    [class*="content"]
  ) {
  color: var(--spacecore-card-accent) !important;
  font-weight: 650 !important;
}

:root.spacecore-order-pricelist
  isp-list-card
  .list-card__footer {
  margin-top: 12px !important;
  gap: 8px !important;
  min-width: 0;
}

:root.spacecore-order-pricelist
  isp-list-card
  .list-card__footer
  .list-card__terms-wrapper {
  width: 100%;
  grid-template-columns: minmax(0, 1fr) !important;
  row-gap: 8px !important;
}

:root.spacecore-order-pricelist
  isp-list-card
  .list-card__footer
  isp-list-card-term {
  grid-column: 1 / -1 !important;
}

:root.spacecore-order-pricelist
  isp-list-card
  isp-list-card-term {
  gap: 2px !important;
  font-size: 12px;
  line-height: 1.25;
}

:root.spacecore-order-pricelist
  isp-list-card
  .list-card-term__label {
  color: var(--spacecore-card-muted) !important;
  font-size: 11px !important;
}

:root.spacecore-order-pricelist
  isp-list-card
  .list-card__footer
  isp-button {
  display: block;
  width: 100%;
  min-width: 0;
}

:root.spacecore-order-pricelist
  isp-list-card
  .list-card__footer
  .ispui-button,
:root.spacecore-order-pricelist
  isp-list-card
  .list-card__footer
  button[class*="button"] {
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  min-height: 30px;
  padding-right: 8px;
  padding-left: 8px;
}

:root.spacecore-order-pricelist
  isp-list-card
  .list-card__footer
  .ispui-button_theme_primary {
  color: #fff !important;
  border-color: var(--spacecore-brand-primary) !important;
  background-color: var(--spacecore-brand-primary) !important;
}

:root.spacecore-order-pricelist
  isp-list-card
  .list-card__footer
  .ispui-button_theme_primary:hover {
  border-color: var(--spacecore-brand-primary-hover) !important;
  background-color: var(--spacecore-brand-primary-hover) !important;
}

:root.spacecore-order-pricelist
  isp-list-card
  .list-card__footer
  .ispui-button_theme_primary:active {
  border-color: var(--spacecore-brand-primary-active) !important;
  background-color: var(--spacecore-brand-primary-active) !important;
}

:root.spacecore-order-pricelist
  isp-list-card
  .list-card__footer
  .ispui-button_theme_secondary {
  color: var(--spacecore-brand-primary) !important;
  border-color: var(--spacecore-brand-primary) !important;
  background-color: transparent !important;
}

:root.spacecore-order-pricelist
  isp-list-card
  .list-card__footer
  .ispui-button_theme_secondary:hover {
  color: var(--spacecore-brand-primary-hover) !important;
  border-color: var(--spacecore-brand-primary-hover) !important;
  background-color: var(--spacecore-brand-primary-soft) !important;
}

:root.spacecore-order-pricelist
  isp-list-card
  .list-card__footer
  .ispui-button_theme_secondary:active {
  color: var(--spacecore-brand-primary-active) !important;
  border-color: var(--spacecore-brand-primary-active) !important;
  background-color: var(--spacecore-brand-primary-soft) !important;
}

:root.spacecore-order-pricelist
  isp-list-card
  .list-card__footer
  isp-list-cell-content-buttons {
  display: block;
  width: 100%;
}

:root.spacecore-order-pricelist
  isp-list-card
  .list-card__footer
  isp-list-cell-content-buttons
  > .cell-buttons {
  display: flex !important;
  flex-direction: column-reverse;
  align-items: stretch;
  width: 100%;
  row-gap: 8px;
  column-gap: 0 !important;
}

:root.spacecore-order-pricelist
  isp-list-card
  .list-card__footer
  isp-list-cell-content-buttons
  > .cell-buttons
  > isp-button {
  display: block;
  width: 100%;
}

:root.spacecore-order-pricelist
  isp-list-card
  isp-cell-tags
  isp-tag {
  border-radius: 5px;
  font-size: 10px;
  font-weight: 600;
}

.spacecore-tariff-badge {
  position: absolute;
  z-index: 3;
  top: -3px;
  right: 10px;
  max-width: calc(100% - 28px);
  padding: 3px 8px 4px;
  overflow: hidden;
  border-radius: 0 0 4px 4px;
  background: var(--spacecore-badge-bg);
  color: var(--spacecore-badge-text);
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  text-overflow: ellipsis;
  text-transform: none;
  white-space: nowrap;
  box-shadow: 0 2px 6px rgb(0 0 0 / 16%);
}

:root.spacecore-order-pricelist
  isp-list-card:has(.spacecore-tariff-badge)
  .list-card__header {
  padding-right: 62px;
}

@media (max-width: 1399.98px) {
  :root.spacecore-order-pricelist isp-list-cards {
    --isp-list-card-min-width: 232px;
  }

  :root.spacecore-order-pricelist
    isp-list-cards
    > .list__cards-wrapper {
    grid-template-columns: repeat(auto-fill, minmax(232px, 1fr)) !important;
  }
}

@media (max-width: 639.98px) {
  :root.spacecore-order-pricelist
    isp-list-cards
    > .list__cards-wrapper {
    grid-template-columns: 1fr !important;
  }
}
