@layer components {
  /* A workflow state: a colored dot and its label. */
  .state {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    white-space: nowrap;

    &::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--state-color, var(--color-state-off)); flex: none; }
  }

  .state--created { --state-color: var(--color-state-created); }
  .state--submitted { --state-color: var(--color-state-submitted); }
  .state--buyer { --state-color: var(--color-state-buyer); }
  .state--treasury { --state-color: var(--color-state-treasury); }
  .state--supplier { --state-color: var(--color-state-supplier); }
  .state--done { --state-color: var(--color-state-done); }
  .state--refused { --state-color: var(--color-state-refused); color: var(--color-ink-muted); }

  /* Workflow progress: one segment per step, the first N in the state color. */
  .progress {
    display: inline-flex;
    flex-direction: column;
    gap: 0.3125rem;
    font-size: var(--text-sm);
    font-weight: 600;
    white-space: nowrap;

    & span { display: inline-flex; gap: 4px; }
    & i { width: 22px; height: 7px; border-radius: 999px; background: var(--color-state-off); }
  }

  .progress--1 i:nth-child(-n + 1), .progress--2 i:nth-child(-n + 2), .progress--3 i:nth-child(-n + 3), .progress--4 i:nth-child(-n + 4), .progress--5 i:nth-child(-n + 5), .progress--6 i:nth-child(-n + 6) { background: var(--state-color, var(--color-state-off)); }

  /* A person's initials in a colored circle. */
  .who {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;

    & i {
      width: 28px;
      height: 28px;
      border-radius: 50%;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      font-style: normal;
      font-size: var(--text-xs);
      font-weight: 700;
      color: #fff;
      background: var(--who-color, var(--color-ink-muted));
      flex: none;
    }
  }

  /* The last message of a discussion, with a dot when unread. */
  .last {
    display: block;
    font-size: var(--text-sm);
    color: var(--color-ink-muted);
    max-width: 32ch;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;

    & b { color: var(--color-ink); font-weight: 600; }
  }

  .last--unread {
    color: var(--color-ink);
    &::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--color-accent); margin-right: 6px; vertical-align: middle; }
  }

  /* Notification list items on the dashboard. */
  .notif {
    display: grid;
    grid-template-columns: 1.75rem minmax(0, 1fr) auto;
    gap: 0.75rem;
    align-items: start;
    padding: 0.75rem 1.25rem;
    border-bottom: 1px solid var(--color-line);
    color: var(--color-ink);
    text-decoration: none;

    &:last-child { border-bottom: 0; }
    &:hover { text-decoration: none; background: var(--color-zebra); }
    & svg { width: 18px; height: 18px; color: var(--notif-color, var(--color-ink-muted)); margin-top: 2px; }
  }

  .notif__title { display: block; font-weight: 700; }
  .notif__text { display: block; color: var(--color-ink-muted); font-size: var(--text-sm); }
  .notif__date { color: var(--color-ink-muted); font-size: var(--text-sm); white-space: nowrap; }
  .notif--to_do { --notif-color: var(--color-notif-to-do); }
  .notif--waiting { --notif-color: var(--color-notif-waiting); }
  .notif--running { --notif-color: var(--color-notif-running); }
  .notif--done { --notif-color: var(--color-notif-done); }
  .notif--refused { --notif-color: var(--color-notif-refused); }
  .notif--comment { --notif-color: var(--color-notif-comment); }

  .notif-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding-right: 1.25rem;
    border-bottom: 1px solid var(--color-line);

    & .notif { flex: 1; border-bottom: 0; }
    &:last-child { border-bottom: 0; }
  }
}
