@layer components {
  .dashboard-body {
    background-color: var(--color-canvas);
  }

  .pulse {
    display: flex;
    max-width: 100rem;
    flex-direction: column;
    padding: var(--main-padding);
    gap: var(--inline-space);
    margin-inline: auto;
  }

  .pulse__header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    padding-block-end: var(--block-space-half);
  }

  .pulse__title {
    font-size: var(--text-2xl);
    font-weight: 700;
    letter-spacing: -0.02em;
  }

  .pulse__subtitle {
    color: var(--color-muted);
    font-size: var(--text-sm);
  }

  .pulse__data-badge {
    border-radius: var(--border-radius);
    background-color: var(--color-warning-subtle);
    color: var(--color-warning-strong);
    font-size: var(--text-sm);
    font-weight: 600;
    padding-block: 0.15rem;
    padding-inline: var(--inline-space-half);
  }

  .pulse__row--split {
    display: grid;
    gap: var(--inline-space);
    grid-template-columns: repeat(2, minmax(0, 1fr));

    @media (width < 68rem) {
      grid-template-columns: 1fr;
    }
  }

  .pulse__row--sales {
    grid-template-columns: minmax(0, 2fr) minmax(0, 3fr);

    @media (width < 68rem) {
      grid-template-columns: 1fr;
    }
  }

  .pulse__card {
    display: flex;
    min-width: 0;
    flex-direction: column;
    padding: var(--block-space-double);
    border-radius: 1rem;
    background-color: var(--color-surface);
    box-shadow: var(--shadow-soft);
    gap: var(--block-space);

    @media (width < 40rem) {
      padding: var(--block-space);
    }
  }

  .pulse__card-header {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    column-gap: var(--inline-space-half);
  }

  .pulse__card-title {
    font-size: 1rem;
    font-weight: 650;
  }

  .pulse__card-note {
    color: var(--color-muted);
    font-size: var(--text-sm);
  }

  /* Scorecards (I dag / I går) */

  .scorecards {
    display: grid;
    flex: 1;
    grid-template-columns: repeat(4, minmax(0, 1fr));

    @media (width < 40rem) {
      grid-template-columns: repeat(2, minmax(0, 1fr));
      row-gap: var(--block-space);
    }
  }

  .scorecard {
    display: flex;
    flex-direction: column;
    border-inline-start: 1px solid var(--color-border);
    gap: 0.375rem;
    padding-inline: var(--inline-space);

    &:first-child {
      border-inline-start: none;
      padding-inline-start: 0;
    }

    @media (width < 40rem) {
      &:nth-child(odd) {
        border-inline-start: none;
        padding-inline-start: 0;
      }
    }
  }

  .scorecard__label {
    overflow: hidden;
    color: var(--color-muted);
    font-size: var(--text-sm);
    font-weight: 500;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .scorecard__value {
    font-size: 2rem;
    font-weight: 650;
    line-height: 1.1;
  }

  /* Range bar: typical band, value tick */

  .range-bar {
    display: block;
    width: 100%;
    height: 0.625rem;
  }

  .range-bar__track { fill: var(--color-border); }
  .range-bar__band { fill: oklch(var(--lch-gray-200)); }
  .range-bar__value { fill: var(--color-ink); }
  .range-bar--above .range-bar__value { fill: var(--color-positive); }
  .range-bar--below .range-bar__value { fill: var(--color-negative); }

  /* Trend */

  .trend {
    display: grid;
    gap: var(--block-space-double);
    grid-template-columns: repeat(3, minmax(0, 1fr));

    @media (width < 68rem) {
      grid-template-columns: 1fr;
    }
  }

  .trend__chart {
    min-width: 0;
  }

  .trend__label {
    font-size: var(--text-sm);
    font-weight: 600;
    margin-block-end: var(--block-space-half);
  }

  /* Tables */

  .pulse__table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--text-sm);
  }

  /* A tinted header, zebra rows, and a hover tint to follow a row across */
  .pulse__table th {
    background-color: var(--color-border);
    color: oklch(var(--lch-gray-600));
    font-weight: 600;
    padding-block: var(--block-space-half);
    padding-inline: var(--inline-space-half);
    text-align: left;
    white-space: normal;

    &:first-child {
      border-end-start-radius: var(--border-radius);
      border-start-start-radius: var(--border-radius);
    }

    &:last-child {
      border-end-end-radius: var(--border-radius);
      border-start-end-radius: var(--border-radius);
    }
  }

  .pulse__table td {
    padding-block: var(--block-space-half);
    padding-inline: var(--inline-space-half);
  }

  .pulse__table tbody tr {
    &:nth-child(even) { background-color: var(--color-shade); }
    &:hover { background-color: oklch(var(--lch-green-100)); }
  }

  .pulse__table tfoot td {
    border-block-start: 1px solid oklch(var(--lch-gray-200));
    font-weight: 600;
  }

  /* Qualified so number headers align with their numbers, not the th default */
  .pulse__table .pulse__table-number {
    font-variant-numeric: tabular-nums;
    text-align: right;
    white-space: nowrap;
  }

  .pulse__table-muted {
    color: var(--color-muted);
  }

  .pulse__table-strong {
    font-weight: 600;
  }

  /* Secondary columns give way on phones rather than clip the table */
  .pulse__table-optional {
    @media (width < 40rem) {
      display: none;
    }
  }

  .pulse__link {
    color: var(--color-ink);
    text-decoration-color: var(--color-border);
    text-underline-offset: 0.2em;

    &:hover {
      text-decoration-color: currentColor;
    }
  }

  /* Salg */

  .sales__date {
    white-space: nowrap;
  }

  .sales__product {
    min-width: 12rem;

    @media (width < 40rem) {
      min-width: 0;
    }
  }

  .sales__product-name {
    @media (width < 40rem) {
      display: -webkit-box;
      overflow: hidden;
      -webkit-box-orient: vertical;
      -webkit-line-clamp: 3;
    }
  }

  /* Store and source ride under the product once their columns give way */
  .sales__meta {
    display: none;
    color: var(--color-muted);

    @media (width < 40rem) {
      display: block;
    }
  }

  .sales__status {
    font-weight: 500;
  }

  .sales__status--approved { color: var(--color-positive); }
  .sales__status--pending { color: var(--color-warning-strong); }
  .sales__status--rejected { color: var(--color-negative); }
  .sales__status--unknown { color: var(--color-muted); }

  /* Funnel */

  .funnel__stage {
    font-weight: 500;
  }

  .funnel__typical {
    width: 7rem;
    min-width: 4rem;
  }

  .funnel__sparkline {
    width: 10rem;
  }

  .sparkline {
    display: block;
    width: 8.75rem;
    height: 2rem;
  }

  .sparkline polyline {
    stroke: oklch(var(--lch-gray-400));
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.5;
  }

  .sparkline circle {
    fill: var(--color-primary);
    stroke: var(--color-surface);
    stroke-width: 2;
  }

  .funnel__direction {
    font-weight: 600;
    white-space: nowrap;
  }

  .funnel__direction--up { color: var(--color-positive); }
  .funnel__direction--down { color: var(--color-negative); }
  .funnel__direction--flat { color: var(--color-muted); }

  .funnel__direction--few {
    color: var(--color-muted);
    font-weight: 500;
  }

  /* Kilder */

  .click-rate {
    display: flex;
    align-items: center;
    gap: var(--inline-space-half);
  }

  .click-rate__bar {
    width: 4rem;
    height: 0.375rem;
    fill: var(--color-primary);
  }

  .click-rate__value {
    min-width: 3ch;
    font-variant-numeric: tabular-nums;
    text-align: right;
  }

  /* Butikker */

  .stores__badge {
    border-radius: var(--border-radius);
    font-size: var(--text-sm);
    font-weight: 600;
    padding-block: 0.1rem;
    padding-inline: var(--inline-space-half);
    white-space: nowrap;
  }

  .stores__badge--yes {
    background-color: var(--color-positive-subtle);
    color: var(--color-positive);
  }

  .stores__badge--no {
    background-color: var(--color-negative-subtle);
    color: var(--color-negative);
  }

  .stores__unmapped {
    color: var(--color-warning-strong);
    font-size: var(--text-xs);
  }

  .stores__leak-line {
    color: var(--color-muted);
    font-size: var(--text-sm);
  }
}
