@layer components {
  /* Base
  /* -------------------------------------------------------------------------- */

  .dashboard {
    display: grid;
    gap: var(--block-space);
    grid-template-columns: repeat(auto-fit, minmax(var(--dashboard-column-size, 12rem), 1fr));
  }

  /* The currency picker sits beside the Net/Gross switch, so it's as small */
  .dashboard__currency {
    align-items: center;
    display: flex;
    gap: var(--inline-space-half);

    .select .input {
      --input-font-size: var(--text-x-small);
      --input-inline-size: auto;
      --input-padding: 0.35em 2em 0.35em 0.75em;
    }
  }

  /* The charts under the cards: two columns where there's room, one otherwise.
  /* Colours come from the app palette, which is tuned per theme. */
  .dashboard-panels {
    --chart-1: var(--color-palette-blue);
    --chart-2: var(--color-palette-cyan);
    --chart-3: var(--color-palette-yellow);
    --chart-4: var(--color-palette-red);
    --chart-5: var(--color-palette-magenta);
    --chart-6: var(--color-palette-green);
    --chart-7: var(--color-palette-bright-blue);
    --chart-8: var(--color-palette-bright-cyan);
    --chart-digital: var(--chart-1);
    --chart-non-digital: var(--chart-3);
    --chart-unknown: var(--color-palette-neutral);
    --chart-other: var(--color-palette-neutral-dim);

    align-items: start;
    display: grid;
    gap: var(--block-space);
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 28rem), 1fr));
    margin-block-start: var(--block-space);
  }

  .dashboard-panel {
    min-inline-size: 0;
  }

  /* One column of panels, one above the other, independent of the column
  /* beside it */
  .dashboard-panels__stack {
    display: flex;
    flex-direction: column;
    gap: var(--block-space);
    min-inline-size: 0;
  }

  /* A currency's share of revenue: a bar, then the percentage */
  .dashboard-share {
    align-items: center;
    display: flex;
    gap: var(--inline-space);
  }

  /* Elements
  /* -------------------------------------------------------------------------- */

  .dashboard-panel__title {
    font-size: var(--text-medium);
    font-weight: 600;
    margin: 0;
  }

  .dashboard-panel__empty {
    color: var(--color-ink-muted);
    margin: 0;
    padding-block: var(--block-space-double);
    text-align: center;
  }

  .dashboard-panel__caption {
    color: var(--color-ink-muted);
    font-size: var(--text-small);
    margin: 0;
  }

  /* Takes what room the column has, so the table fits its card */
  .dashboard-share__track {
    background-color: var(--color-surface-subtle);
    border-radius: 999px;
    block-size: 0.5rem;
    flex: 1;
    min-inline-size: 2.5rem;
    overflow: hidden;
  }

  .dashboard-share__fill {
    background-color: var(--chart-1);
    block-size: 100%;
    display: block;
    inline-size: var(--share);
  }

  .dashboard-share__value {
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
  }

  /* A small table in half a row: fits the card rather than scrolling */
  .dashboard-currencies {
    --table-min-inline-size: 0;
    --table-label-size: auto;
    --table-cell-padding: var(--block-space-half);
  }

  /* Sentence case, the spec's secondary label */
  .dashboard-card__label {
    color: var(--color-ink-muted);
    font-size: var(--text-x-small);
    font-weight: 500;
    line-height: 16px;
    margin: 0;
  }

  .dashboard-card__value {
    color: var(--color-ink);
    font-size: var(--dashboard-card-value-size, var(--text-x-large));
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    line-height: 1.25;
  }

  /* Two small counts in one card: number then noun, e.g. "40 works" */
  .dashboard-card__counts {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    margin: 0;
  }

  .dashboard-card__count {
    align-items: baseline;
    display: flex;
    gap: var(--inline-space-half);
  }

  .dashboard-card__count-value {
    color: var(--color-ink);
    font-size: var(--text-large);
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    margin: 0;
    order: -1;
  }

  .dashboard-card__count-label {
    color: var(--color-ink-muted);
    font-size: var(--text-small);
  }

  .dashboard-card__note,
  .dashboard__note {
    color: var(--color-ink-muted);
    font-size: var(--text-x-small);
    margin: 0;
  }

  .dashboard__note {
    margin-block-start: var(--block-space);
  }

  /* Variants
  /* -------------------------------------------------------------------------- */

  .dashboard-panel--wide {
    grid-column: 1 / -1;
  }
}
