@layer components {

  /* The main region of a bill's page: the processing placeholder while the
     uploaded document runs through the pipeline, then the invoice page's
     two-column layout — the editor (supplier, line items, totals) on the
     left, the document itself on the right. Transparent — each section
     inside brings its own card styling. */
  .bill-body {
    display: flex;
    flex-direction: column;
  }

  /* On a phone the body dissolves like the layout it wraps (see invoice.css),
     and the processing placeholder takes the main column's place in the
     page's order. */
  @media (width < 768px) {
    .bill-body {
      display: contents;
    }

    .bill-processing {
      margin-block-start: 2rem;
      order: 5;
    }
  }

  /* The supplier card opens the main column here, where the invoice's header
     card would; the layout's own top padding is all the space it needs. */
  .bill-body .inv-parties {
    margin-block-start: 0;
  }

  .bill-processing {
    align-items: center;
    background: var(--color-surface);
    border-radius: var(--radius-md);
    color: var(--color-ink-muted);
    display: flex;
    flex-direction: column;
    font-size: 1.125rem;
    gap: 1.5rem;
    margin-block-start: 2rem;
    padding: 4rem 1.5rem;
    text-align: center;
  }

  .bill-processing__text {
    margin: 0;
  }

  .bill-processing__text--deferred {
    font-size: 0.9375rem;
    max-inline-size: 40ch;
  }

  /* The card's label names what the document is and when it was issued, with
     the inbound-document glyph in front of it. */
  .inv-sidebar__due-label.bill-summary {
    align-items: center;
    display: flex;
    gap: 0.5rem;
  }

  /* The same label as a button, where the kind can be changed by hand: it
     keeps the label's look, with a chevron after it saying it opens. */
  .bill-type {
    position: relative;
  }

  .bill-type__button {
    background: none;
    border: none;
    border-radius: var(--radius-xs);
    cursor: pointer;
    font-family: inherit;
    padding: 0;
    text-align: start;

    &:hover {
      color: var(--color-ink-inverted);
    }

    &:disabled {
      cursor: default;
    }
  }

  .bill-type__menu {
    inset-block-start: calc(100% + 0.25rem);
    inset-inline-start: 0;
    min-inline-size: 14rem;
  }

  /* How the bill was paid, under its title: a pill in the brand's tint, so
     it reads as a fact about the bill rather than as a caption. Unknown is
     the same pill drawn in outline — there, but nothing to call attention
     to; the canvas under the header is already the neutral tint. */
  .page-header__subtitle.bill-payment {
    background: var(--color-brand-tint);
    border-radius: var(--radius-pill);
    color: var(--color-brand-strong);
    font-size: 0.875rem;
    font-weight: 600;
    inline-size: fit-content;
    padding: 0.25rem 0.75rem;
  }

  .page-header__subtitle.bill-payment--unknown {
    background: none;
    border: 1px dashed var(--color-border-strong);
    color: var(--color-ink-muted);
  }

  /* The pill beside the print button in the bill's header, stretched to
     the button's height — over the centring `.inv-head-actions` gives the
     row, which loads after this file. */
  .inv-head-actions.bill-head-actions {
    align-items: stretch;

    .page-header__subtitle.bill-payment {
      align-items: center;
      display: flex;
      margin: 0;
    }

    .bill-payment-method {
      display: flex;
    }
  }

  /* The same pill as a button while the bill can be edited: a chevron after
     it says it opens the menu of ways to have paid. The second class beats
     the list cell's `.bill-payment` further down. */
  .bill-payment-method {
    position: relative;
  }

  .bill-payment.bill-payment-method__button {
    align-items: center;
    border: none;
    cursor: pointer;
    display: inline-flex;
    font-family: inherit;
    gap: 0.375rem;

    &:hover {
      color: var(--color-brand);
    }

    &:disabled {
      cursor: default;
    }
  }

  .bill-payment-method__menu {
    inset-block-start: calc(100% + 0.25rem);
    inset-inline-start: 0;
    min-inline-size: 14rem;
  }

  /* A bill's side column, taller than the viewport once it holds the
     preview, gives up the stickiness `invoice.css` gives it and scrolls with
     the page: the amount, the payment and the preview in their order, none
     pinned over another. */
  @media (width >= 1024px) {
    .inv-layout__side-col:has(.bill-due) {
      position: static;
    }
  }

  /* The final document's card in the side column: title, the preview and the
     download under it. Two classes so it beats `.inv-sidebar__section`, which
     `sidebar.css` loads after this file. */
  .inv-sidebar__section.bill-download {
    align-items: stretch;
    gap: 1rem;
  }

  .bill-download__btn {
    margin-block-start: 0.25rem;
  }

  /* On the phone the preview shrinks to a strip beside its title and button,
     so the editor is one thumb-scroll away. */
  @media (width < 768px) {
    .inv-sidebar__section.bill-download {
      align-items: center;
      column-gap: 1rem;
      display: grid;
      grid-template-columns: 6rem minmax(0, 1fr);
      row-gap: 0.75rem;
    }

    .bill-download .inv-sidebar__section-title,
    .bill-download__label,
    .bill-download__btn {
      grid-column: 2;
    }

    .bill-download .inv-sidebar__section-title {
      align-self: start;
    }

    .bill-download__btn {
      align-self: end;
      margin-block-start: 0;
    }

    /* The grid item is the button around the preview, not the frame itself —
       so the button carries the placement, else the frame would fall out of
       its column. */
    .bill-download__zoom {
      align-self: stretch;
      grid-column: 1;
      grid-row: 1 / -1;
    }

    /* A fixed-height strip, whatever the document's proportions: a tall
       receipt is cropped from the top rather than stretching the card. */
    .bill-download__frame {
      aspect-ratio: auto;
      block-size: 8rem;
      inline-size: 6rem;
    }

    /* Two classes: the base `.bill-download__preview` rule comes later in
       this file and would otherwise win the tie. */
    .bill-download__frame .bill-download__preview {
      block-size: 100%;
      max-block-size: none;
      object-fit: cover;
      object-position: top;
    }
  }

  /* The preview is wrapped in a button so it can be enlarged from the
     keyboard too. The button draws nothing and sets no size of its own —
     the preview frame inside carries the dimensions. */
  .bill-download__zoom {
    align-self: center;
    background: none;
    border: none;
    cursor: zoom-in;
    display: block;
    padding: 0;
  }

  /* The preview is stored at up to 1500px a side; on the page it reads as a
     thumbnail of the document, scaled down to a readable glance. The frame
     fits a 20rem × 24rem box and gets the picture's own proportions from
     `bill_preview_tag`, so it holds the picture's place — under a sliding
     shimmer — until the image has loaded and the `image-load` controller
     marks it loaded. */
  .bill-download__frame {
    --bill-preview-inline-size: 20rem;
    --bill-preview-shade: var(--color-border-subtle);
    --bill-preview-highlight: var(--color-surface-tint);

    align-self: center;
    animation: bill-preview-shimmer 1.6s ease-in-out infinite;
    aspect-ratio: var(--bill-preview-aspect-ratio, auto);
    background: linear-gradient(100deg, var(--bill-preview-shade) 40%, var(--bill-preview-highlight) 50%, var(--bill-preview-shade) 60%) 100% 0 / 300% 100%;
    border: 1px solid var(--color-border-subtle);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-popover);
    inline-size: var(--bill-preview-inline-size);
    margin: 0;
    max-inline-size: 100%;
    overflow: hidden;

    &.bill-download__frame--loaded {
      animation: none;
      background: var(--color-surface);
    }
  }

  .bill-download__preview {
    block-size: auto;
    display: block;
    inline-size: 100%;
    max-block-size: 24rem;
    object-fit: contain;
    opacity: 0;
    transition: opacity 200ms ease-out;

    .bill-download__frame--loaded & {
      opacity: 1;
    }
  }

  @keyframes bill-preview-shimmer {
    from { background-position: 100% 0; }
    to   { background-position: 0 0; }
  }

  .bill-download__label {
    color: var(--color-ink-secondary);
    font-size: 0.875rem;
    margin: 0;
  }

  /* ─── Received documents list — the processing row ───────

     While the uploaded document is being read, the row has nothing to say:
     a grey sheen sweeps across its background from left to right (the same
     keyframes as the document preview above), and in the cells the reading
     has yet to fill, three dots pulse — one after another, so the row reads
     as work in progress, not as an answer. */

  /* ─── Received documents list ──────────────── */

  /* A bill is listed by who it is from, with what it is and how it was paid
     in a quiet line under the name; then the date, where the payment stands
     and the amount. Every row is its own grid, so the columns are fractions
     and the date a fixed width: a column sized to its content would start
     somewhere else in every row. The type has no column of its own (its
     header is hidden): it sits under the supplier, and the other cells span
     both of the row's lines, centred on them. */
  .doc-headers.doc-headers--bills,
  .doc-row.doc-row--bills {
    --doc-columns: minmax(0, 2.2fr) 9rem minmax(0, 1.4fr) minmax(0, 1fr);
  }

  .doc-headers--bills .doc-col--type {
    display: none;
  }

  /* The gap also opens after the checkbox column while it is closed, so
     the leading padding gives that much back: the name starts where the
     other lists' first column does. */
  .doc-headers.doc-headers--bills,
  .doc-row.doc-row--bills {
    --doc-bills-gap: 1.25rem;

    column-gap: var(--doc-bills-gap);
    padding-inline: calc(1.75rem - var(--doc-bills-gap)) 1.75rem;
  }

  .doc-row.doc-row--bills {
    grid-template-rows: auto auto;
    padding-block: 1.25rem;
    row-gap: 0.3125rem;
  }

  .doc-row--bills > .doc-check {
    grid-column: 1;
    grid-row: 1 / 3;
  }

  .doc-row--bills .doc-cell--client {
    align-self: end;
    grid-column: 2;
    grid-row: 1;
  }

  .doc-row--bills .doc-col--type {
    align-self: start;
    grid-column: 2;
    grid-row: 2;
  }

  .doc-row--bills .doc-col--date {
    grid-column: 3;
    grid-row: 1 / 3;
  }

  .doc-row--bills .doc-col--payment {
    grid-column: 4;
    grid-row: 1 / 3;
  }

  .doc-row--bills .doc-col--amount {
    grid-column: 5;
    grid-row: 1 / 3;
  }

  /* The due date's column, between the date and the payment, where the
     list isn't ordered by it (`_list`): the cell is in every row, so a row
     streamed in after a change of order needs nothing else. */
  .doc-row--bills .doc-col--due {
    display: none;
  }

  .doc-headers.doc-headers--with-due,
  .doc-table--with-due .doc-row.doc-row--bills {
    --doc-columns: minmax(0, 2fr) 8.5rem 9rem minmax(0, 1.3fr) minmax(0, 0.9fr);
  }

  .doc-table--with-due .doc-row--bills {
    .doc-col--due {
      display: block;
      grid-column: 4;
      grid-row: 1 / 3;
      text-align: center;
    }

    .doc-col--payment {
      grid-column: 5;
    }

    .doc-col--amount {
      grid-column: 6;
    }
  }

  .doc-headers--with-due .doc-col--due {
    text-align: center;
  }

  /* The due date in a line, and under it how late it is once the bill should
     have been paid; settled, it steps back. Its own label shows on a phone
     only, where the column has no header. */
  .bill-due {
    color: var(--color-ink-secondary);
    display: inline-flex;
    flex-direction: column;
    font-size: 1rem;
    gap: 0.125rem;
    line-height: 1.3;
    white-space: nowrap;
  }

  .bill-due__label {
    display: none;
  }

  .bill-due--overdue {
    color: var(--color-negative);
    font-weight: 600;
  }

  .bill-due__late {
    font-size: 0.75rem;
    font-weight: 600;
  }

  .bill-due--settled,
  .bill-due--none {
    color: var(--color-ink-muted);
  }

  .doc-row--bills .doc-col--date,
  .doc-row--bills .doc-col--amount {
    white-space: nowrap;
  }

  .doc-row--bills .doc-col--date {
    color: var(--color-ink-secondary);
    font-size: 1rem;
  }

  /* The supplier reads from its start and the amount from its end; the
     date and the payment sit in the middle of their columns, under headers
     centred over them, as the issued invoices' columns do. */
  .doc-row--bills .doc-cell--client,
  .doc-row--bills .doc-col--type,
  .doc-headers--bills .doc-col--supplier {
    text-align: start;
  }

  .doc-row--bills .doc-col--date,
  .doc-row--bills .doc-col--payment,
  .doc-headers--bills .doc-col--payment {
    text-align: center;
  }

  .doc-headers--bills .bill-sort {
    justify-content: center;
  }

  /* The date's header is a pill taller than the labels beside it: the
     labels sit level with its middle. */
  .doc-headers--bills {
    align-items: center;
  }

  /* The supplier's name is the row's link, in the brand as a link is. */
  .doc-row--bills .doc-cell--client {
    font-size: 1.0625rem;
    line-height: 1.3;
  }

  .doc-row--bills .doc-cell--client a {
    color: var(--color-brand);
    text-decoration: none;

    &:hover {
      text-decoration: underline;
    }
  }

  /* What the bill is and how it was paid, under the name: each a small icon
     and its name, a dot between them. The name is the icon's bubble, shown
     in the line rather than on hover, so the row says it without a pointer.
     A way of paying nobody knows yet adds nothing, so it is left out. */
  .doc-row--bills .doc-col--type {
    align-items: center;
    color: var(--color-ink-muted);
    display: flex;
    flex-wrap: wrap;
    font-size: 0.8125rem;
    gap: 0.375rem;
  }

  .doc-row--bills .doc-icon {
    align-items: center;
    color: inherit;
    cursor: default;
    gap: 0.3125rem;

    svg {
      block-size: 15px;
      inline-size: 15px;
    }
  }

  .doc-row--bills .doc-icon + .doc-icon::before {
    content: "·";
    margin-inline-end: 0.0625rem;
  }

  .doc-row--bills .doc-icon + .doc-icon:has(.icon--question-mark) {
    display: none;
  }

  .doc-row--bills .doc-icon__bubble,
  .doc-row--bills .doc-icon:hover .doc-icon__bubble {
    background: none;
    color: inherit;
    display: inline;
    font-size: inherit;
    font-weight: 500;
    padding: 0;
    position: static;
    transform: none;
  }

  /* A type or payment icon, centred in its cell, in the ink the type used to
     be printed in, and its name in a bubble beside it on hover. */
  .doc-icon {
    color: var(--color-ink-secondary);
    cursor: help;
    display: inline-flex;
    position: relative;
    vertical-align: middle;
  }

  /* To the icon's left and level with it: a row is taller than the bubble,
     and the cells to the left of both icon columns are wide enough for it,
     so the table's `overflow: hidden` — which would cut off a bubble opening
     above the first row or below the last — never reaches it. */
  .doc-icon__bubble {
    background: var(--color-surface-inverted);
    border-radius: var(--radius-sm);
    color: var(--color-ink-inverted);
    display: none;
    font-size: 0.75rem;
    font-weight: 600;
    inline-size: max-content;
    inset-block-start: 50%;
    inset-inline-end: calc(100% + 0.5rem);
    line-height: 1.4;
    padding: 0.3rem 0.6rem;
    pointer-events: none;
    position: absolute;
    transform: translateY(-50%);
    z-index: var(--z-popover);
  }

  .doc-icon:hover .doc-icon__bubble {
    display: block;
  }

  .doc-row--processing {
    --doc-processing-shade: var(--color-surface-tint);

    animation: bill-preview-shimmer 2.4s ease-in-out infinite;
    background: linear-gradient(90deg, var(--color-surface) 35%, var(--doc-processing-shade) 50%, var(--color-surface) 65%) 100% 0 / 300% 100%;
  }

  .doc-dots {
    --doc-dot-size: 0.4em;

    align-items: center;
    display: inline-flex;
    gap: calc(var(--doc-dot-size) * 0.75);
    vertical-align: middle;
  }

  .doc-dots__dot {
    animation: doc-dot-pulse 1.2s ease-in-out infinite;
    background: var(--color-ink-faint);
    block-size: var(--doc-dot-size);
    border-radius: 50%;
    display: block;
    inline-size: var(--doc-dot-size);

    &:nth-child(2) {
      animation-delay: 0.2s;
    }

    &:nth-child(3) {
      animation-delay: 0.4s;
    }
  }

  @keyframes doc-dot-pulse {
    0%, 60%, 100% { transform: scale(0.65); opacity: 0.55; }
    30%           { transform: scale(1);    opacity: 1; }
  }

  /* ─── Received documents list — narrower ─────

     On a tablet the row keeps its columns, narrower. On a phone it is a card
     of three lines: who it is from and what it comes to; what it is, and
     the date the list is ordered by; then where the payment stands, which
     takes no line where there is nothing to say. */

  @media (768px <= width < 1024px) {
    .doc-headers.doc-headers--bills,
    .doc-row.doc-row--bills {
      --doc-columns: minmax(0, 1.6fr) 7.5rem minmax(0, 1fr) minmax(0, 0.8fr);
    }

    .doc-headers.doc-headers--bills,
    .doc-row.doc-row--bills {
      --doc-bills-gap: 1rem;

      padding-inline: calc(1.25rem - var(--doc-bills-gap)) 1.25rem;
    }

    .doc-headers.doc-headers--with-due,
    .doc-table--with-due .doc-row.doc-row--bills {
      --doc-columns: minmax(0, 1.4fr) 6.5rem 7rem minmax(0, 1fr) minmax(0, 0.8fr);
    }

    .bill-due {
      font-size: 0.875rem;
    }
  }

  @media (width < 768px) {
    .doc-headers.doc-headers--bills,
    .doc-row.doc-row--bills {
      --doc-bills-gap: 0.875rem;
      --doc-columns: minmax(0, 1fr) auto;

      padding-inline: calc(1.125rem - var(--doc-bills-gap)) 1.125rem;
    }

    /* Only the lines a card has content for: the payment's and the due
       date's open a line of their own where they say something. */
    .doc-row.doc-row--bills {
      grid-template-rows: none;
      padding-block: 1rem;
      row-gap: 0.375rem;
    }

    .doc-row--bills > .doc-check {
      grid-row: 1 / 4;
    }

    /* Over the card only the supplier and the date it is ordered by have a
       column to head. */
    .doc-headers--bills .doc-col--payment,
    .doc-headers--bills .doc-col--amount {
      display: none;
    }

    .doc-headers--bills .doc-col--date {
      display: flex;
      grid-column: 3;
      justify-self: end;
    }

    .doc-row--bills .doc-cell--client {
      align-self: center;
      font-size: 1rem;
      grid-column: 2;
      grid-row: 1;
    }

    .doc-row--bills .doc-col--amount {
      font-size: 1rem;
      grid-column: 3;
      grid-row: 1;
    }

    .doc-row--bills .doc-col--type {
      grid-column: 2;
      grid-row: 2;
    }

    .doc-row--bills .doc-col--date {
      align-self: center;
      color: var(--color-ink-muted);
      display: block;
      font-size: 0.8125rem;
      grid-column: 3;
      grid-row: 2;
      text-align: end;
    }

    .doc-row--bills .doc-col--payment {
      grid-column: 2 / 4;
      grid-row: 3;
      justify-self: start;
      padding-block-start: 0.25rem;
      text-align: start;
    }

    .doc-row--bills .doc-col--payment:not(:has(*)) {
      display: none;
    }

    .doc-headers.doc-headers--with-due,
    .doc-table--with-due .doc-row.doc-row--bills {
      --doc-columns: minmax(0, 1fr) auto;
    }

    /* The due date on a line of its own under the payment's pill, named,
       how late it is after it: in the row's last column it would widen it
       and cut the supplier's name short. A bill with none says nothing
       there. The column's overrides above are the desktop's, so these
       restate the place. */
    .doc-headers--with-due .doc-col--due {
      display: none;
    }

    .doc-table--with-due .doc-row--bills .doc-col--due {
      grid-column: 2 / 4;
      grid-row: 4;
      justify-self: start;
      text-align: start;
    }

    .doc-table--with-due .doc-row--bills .doc-col--payment {
      grid-column: 2 / 4;
    }

    .doc-table--with-due .doc-row--bills .doc-col--amount {
      grid-column: 3;
    }

    .doc-table--with-due .doc-row--bills .doc-col--due:has(.bill-due--none) {
      display: none;
    }

    .bill-due {
      align-items: baseline;
      flex-direction: row;
      flex-wrap: wrap;
      font-size: 0.8125rem;
      gap: 0.3125rem;
    }

    .bill-due__label {
      color: var(--color-ink-muted);
      display: inline;
      font-weight: 500;
    }

    .bill-due__late::before {
      content: "· ";
    }
  }

  /* ─── The payment order ───────────────────── */

  /* The manage bar's "Payment order" button sits in a form of its own,
     which must not break the row of buttons it stands in. */
  .bill-payment-order {
    display: contents;
  }

  /* ─── The list's order ──────────────────── */

  /* A row carries all three of its dates and shows the one the list is
     ordered by (`Bills::DocumentsHelper#bill_list_dates_tag`). */
  .bill-date {
    display: none;
  }

  .doc-table--by-issued .bill-date--issued,
  .doc-table--by-due .bill-date--due,
  .doc-table--by-added .bill-date--added {
    display: inline;
  }

  /* The date column's header, a button naming the date the list is ordered
     by and which way it runs. */
  /* A flex box, so the pill is its whole height: inline, it would sit on
     the text's baseline with a line's descent under it. */
  .bill-sort {
    display: flex;
    position: relative;
  }

  .bill-sort__button {
    align-items: center;
    background: var(--color-brand-tint);
    border: none;
    border-radius: var(--radius-pill);
    color: var(--color-brand);
    cursor: pointer;
    display: inline-flex;
    gap: 0.375rem;
    margin-inline-start: -0.625rem;
    min-block-size: 2rem;
    padding: 0.25rem 0.625rem;

    &:hover {
      background: oklch(from var(--color-brand) l c h / 18%);
    }

    &:focus-visible {
      box-shadow: var(--shadow-focus);
      outline: 2px solid var(--color-brand);
    }

    @media (width < 768px) {
      margin-inline: 0 -0.625rem;
    }
  }

  .bill-sort__panel {
    display: grid;
    gap: 0.5rem;
    inline-size: 17rem;
    inset-block-start: calc(100% + 0.375rem);
    inset-inline-start: -0.625rem;
    text-align: start;
    white-space: normal;
  }

  .bill-sort__group {
    border: none;
    display: grid;
    gap: 0.125rem;
    margin: 0;
    padding: 0;
  }

  .bill-sort__legend {
    padding: 0.375rem 0.625rem 0.25rem;
  }

  .bill-sort__option {
    input {
      accent-color: var(--color-brand);
      margin: 0;
    }

    &:has(input:checked) {
      background: var(--color-brand-tint);
    }
  }

  .bill-sort__option-text {
    display: grid;
  }

  .bill-sort__option-label {
    color: var(--color-ink);
    font-weight: 600;
  }

  .bill-sort__option-hint {
    color: var(--color-ink-muted);
    font-size: 0.8125rem;
  }

  /* Which way round, as two halves of one switch over a well. */
  .bill-sort__directions {
    background: var(--color-surface-tint);
    border-radius: var(--radius-sm);
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding: 0.25rem;

    .bill-sort__legend {
      grid-column: 1 / -1;
    }
  }

  .bill-sort__direction {
    align-items: center;
    border-radius: var(--radius-xs);
    color: var(--color-ink-secondary);
    cursor: pointer;
    display: flex;
    font-size: 0.8125rem;
    justify-content: center;
    min-block-size: 2.25rem;
    padding: 0.25rem 0.5rem;
    text-align: center;

    &:has(input:checked) {
      background: var(--color-surface);
      box-shadow: var(--shadow-card);
      color: var(--color-brand);
      font-weight: 600;
    }

    &:has(:focus-visible) {
      outline: 2px solid var(--color-brand);
    }
  }

  /* On a phone the panel rises from the bottom as a sheet, its rows tall
     enough for a thumb; its shadow dims the list, and a tap on it is a tap
     outside, which closes the sheet. */
  @media (width < 768px) {
    .bill-sort__panel {
      border-radius: var(--radius-xl) var(--radius-xl) 0 0;
      box-shadow: 0 0 0 100vmax oklch(from var(--color-shadow) l c h / 45%);
      gap: 0.75rem;
      inline-size: auto;
      inset: auto 0 0;
      padding: 1rem 1rem calc(1.5rem + var(--native-tab-bar-clearance, 0px));
      position: fixed;
      z-index: var(--z-sheet);
    }

    .bill-sort__option {
      min-block-size: 3.25rem;
    }

    .bill-sort__direction {
      font-size: 0.875rem;
      min-block-size: 2.75rem;
    }
  }

  /* ─── Where the payment stands ──────────── */

  /* The list's payment cell: the state in a line, in the brand where it
     only says how things stand, in the warning's colour where something is
     to be done, the detail in a bubble on hover. */
  .bill-payment {
    color: var(--color-brand);
    font-size: 0.9375rem;
    font-weight: 600;
    line-height: 1.3;
    text-align: start;
  }

  /* In the list the state is a pill, its tint saying at a glance whether
     the bill is settled (green), waits on something (the brand) or needs
     the user (the warning's colour). */
  .doc-row--bills .bill-payment {
    background: var(--color-brand-tint);
    border-radius: var(--radius-pill);
    display: inline-block;
    font-size: 0.8125rem;
    padding: 0.3125rem 0.75rem;
    white-space: nowrap;
  }

  .doc-row--bills :is(.bill-payment--paid, .bill-payment--paid_otherwise) {
    background: var(--color-positive-tint);
    color: var(--color-positive);
  }

  .doc-row--bills :is(.bill-payment--proposed, .bill-payment--partly_paid, .bill-payment--unpaid, .bill-payment--warning) {
    background: var(--color-warning-tint);
  }

  .doc-row--bills .bill-payment--cash {
    background: var(--color-surface-tint);
  }

  .bill-payment--proposed,
  .bill-payment--partly_paid,
  .bill-payment--unpaid,
  .bill-payment--warning {
    color: var(--color-warning);
  }

  .bill-payment--cash {
    color: var(--color-ink-secondary);
    font-weight: 500;
  }

  /* The bill page's account of its payment. */
  .bill-settlements {
    display: grid;
    gap: 0.75rem;
  }

  .bill-settlements__state {
    margin: 0;
  }

  .bill-settlement {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    font-size: 0.875rem;
    gap: 0.25rem 0.75rem;
    justify-content: space-between;
  }

  .bill-settlement__note {
    color: var(--color-ink-muted);
    flex-basis: 100%;
  }

  .bill-settlement__remove {
    background: none;
    border: none;
    color: var(--color-link);
    cursor: pointer;
    font-size: 0.8125rem;
    padding: 0;
  }

  /* ─── Paying the bill ───────────────────── */

  .bill-pay {
    display: grid;
    gap: 0.75rem;
    justify-items: center;
    margin-block-start: 1rem;
  }

  .bill-pay__label {
    justify-self: start;
  }

  .bill-pay__qr {
    background: var(--color-code-surface);
    block-size: 10rem;
    border-radius: var(--radius-sm);
    inline-size: 10rem;
    padding: 0.5rem;
  }

  /* payme.sk opens a banking app, which lives on the phone: on a wider
     screen the code is the way to pay, as in the invoice's email. */
  .bill-pay__payme {
    @media (width >= 768px) {
      display: none;
    }
  }
}
