/*
 * The company page types' own chrome (companies/_chrome; tasks/redesign, D8,
 * from keystats.png), and the keystats report's two-column arrangement.
 *
 *   .company-chrome             the header
 *   .company-chrome__utility    the breadcrumbs, then the date, Excel and
 *                               Print, over a hairline
 *   .company-chrome__title      the company's name in the serif, and the
 *                               ticker in a chip beside it
 *   .company-chrome__identity   the sector and industry in green small caps
 *   .company-chrome__lede       the standfirst — the sentence, the quarter's
 *                               figures, the tags — beside the price block,
 *                               side by side from 1024px
 *   .stat-bar                   seven figures under a double rule, scrolling
 *                               sideways on a phone
 *
 * Then the tab bar at every width, scrolling sideways on a phone
 * (components/tabs.css) — the one company navigation; and the keystats
 * report, one column in reading order below 1280px and two from it (below).
 */
@layer pages {
  .company-chrome {
    /* One line of the price at its hero size, and its "as of" under it: what
       the price frame reserves for its placeholder and keeps when it lands —
       or when a company has no price and the frame comes back empty. */
    --company-price-height: 4.25rem;

    display: grid;
    gap: var(--space-xs);
    margin-block-end: var(--space-sm);

    /* With `extended_hours` on, room for the pre-market or after-hours line
       under the price at every hour (companies/_extended_hours), so the poll
       never moves the page when a session starts or ends. */
    &.company-chrome--sessions {
      --company-price-height: 5.75rem;
    }

    /* With the reader's notebook slip, from 1024px, the header is two
       columns: the name, the identity line and the standfirst down the
       left, one after the other; the slip and, under it, the price with
       Follow and Alert down the right. The lede gives up its own box
       (`display: contents`) so its two halves can take a column each, and
       the flexible fourth row takes whatever one column needs past the
       other, so neither side leaves a gap in the middle of the other. */
    @media (width >= 1024px) {
      &:has(.notebook-entry) {
        grid-template-columns: minmax(0, 1fr) auto;
        grid-template-rows: auto auto auto 1fr auto;
        column-gap: var(--space-2xl);

        & > * {
          grid-column: 1 / -1;
        }

        & > .company-chrome__utility {
          grid-row: 1;
        }

        & > .company-chrome__title,
        & > .company-chrome__identity {
          grid-column: 1;
          align-self: start;
        }

        & > .company-chrome__title {
          grid-row: 2;
        }

        & > .company-chrome__identity {
          grid-row: 3;
        }

        & > .company-chrome__lede {
          display: contents;
        }

        & .company-chrome__summary {
          grid-column: 1;
          grid-row: 4 / span 2;
          align-self: start;
          margin-block-start: var(--space-sm);
        }

        & .company-chrome__quote {
          grid-column: 2;
          grid-row: 5;
          align-self: end;
          margin-block-start: var(--space-md);
        }

        & > .notebook-entry-slot {
          grid-column: 2;
          grid-row: 2 / span 3;
          align-self: start;
          justify-content: flex-end;
          margin-block-start: var(--space-sm);
        }
      }
    }
  }

  .company-chrome__utility {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--space-2xs) var(--space-lg);
    padding-block-end: var(--space-xs);
    border-block-end: var(--rule-hairline);

    & .breadcrumbs {
      margin: 0;
    }
  }

  .company-chrome__tools {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: var(--space-2xs) var(--space-md);
    color: var(--color-ink-muted);
    font-size: var(--text-ui-sm);
  }

  .company-chrome__date {
    @media (width < 640px) {
      display: none;
    }
  }

  .company-header__export {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2xs);
  }

  /* The overview's Print button: a word, in the link green; not on a phone,
     where there is rarely a printer, and not on the paper. */
  .company-chrome__print {
    display: none;
    color: var(--color-link);
    font-size: inherit;
    cursor: pointer;

    &:hover {
      text-decoration: underline;
    }

    @media (width >= 768px) {
      display: inline;
    }
  }

  /* The name and the ticker's chip on one line, the chip wrapping under a
     long name rather than squeezing it. */
  .company-chrome__title {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2xs) var(--space-sm);
    margin-block-start: var(--space-sm);
  }

  .company-chrome__name {
    margin: 0;
    font-size: var(--text-h1);
    line-height: var(--leading-h1);
    letter-spacing: -0.01em;
  }

  .company-chrome__identity {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: var(--space-2xs) var(--space-xs);
    margin: 0;
    color: var(--color-ink-muted);
    font-size: var(--text-caps);
    letter-spacing: var(--tracking-caps);
    text-transform: uppercase;
  }

  .company-chrome__ticker {
    padding: var(--space-3xs) var(--space-xs);
    border: var(--rule-width) solid var(--color-rule);
    color: var(--color-ink);
    font-size: var(--text-caps);
    font-weight: var(--weight-semibold);
    letter-spacing: var(--tracking-caps);
  }

  .company-chrome__segment {
    position: relative;
    color: var(--color-link);
    text-decoration: none;

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

  /* The two links are a line of text, and a 44px target on touch without
     making the line taller: the hit area reaches above and below it. The
     @media is on the outside: Chrome before 130 drops declarations in an
     @media nested inside a nested pseudo-element. */
  @media (pointer: coarse) {
    .company-chrome__segment::after {
      content: "";
      position: absolute;
      inset-block: calc((100% - var(--target-min)) / 2);
      inset-inline: 0;
    }
  }

  .company-chrome__lede {
    display: grid;
    gap: var(--space-md) var(--space-2xl);
    margin-block-start: var(--space-2xs);

    @media (width >= 1024px) {
      grid-template-columns: minmax(0, 1fr) auto;
      align-items: end;
    }
  }

  .company-chrome__summary {
    display: grid;
    grid-row: 1;
    gap: var(--space-sm);
    max-inline-size: 48rem;
  }

  .company-chrome__standfirst {
    max-inline-size: 48rem;
    margin: 0;
    font-family: var(--font-prose);
    font-size: var(--text-lead);
    line-height: var(--leading-lead);
    text-wrap: pretty;
  }

  /* The latest quarter against a year earlier (companies/_quarter_changes,
     M17-D3): caps labels over signed figures, then what they are measured
     against and the quarter's earnings digest. */
  .quarter-changes {
    display: grid;
    gap: var(--space-2xs);
  }

  .quarter-changes__figures {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2xs) var(--space-lg);
    margin: 0;

    & dd {
      margin: 0;
      font-weight: var(--weight-semibold);
    }
  }

  .quarter-changes__figure {
    display: grid;
    gap: var(--space-3xs);
  }

  .quarter-changes__note {
    margin: 0;
    color: var(--color-ink-muted);
    font-size: var(--text-ui-sm);
  }

  /* The sets of companies this one belongs to — indexes, then streaks — and
     on the overview its red flags (M12-D11): square tags in one wrapping row,
     each a link. A tag is a word, so a 44px target on touch comes from its
     padding. */
  .company-chrome__tags {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-xs);
    margin: 0;
    padding: 0;
    list-style: none;
    font-size: var(--text-ui-sm);
  }

  .company-chrome__tag {
    display: inline-flex;
    align-items: baseline;
    gap: var(--space-2xs);
    padding: var(--space-3xs) var(--space-sm);
    border: var(--rule-width) solid var(--color-rule);
    border-radius: var(--radius-md);
    color: var(--color-ink);
    text-decoration: none;

    &:hover {
      border-color: var(--color-link);
      color: var(--color-link);
    }

    @media (pointer: coarse) {
      min-block-size: var(--target-min);
      align-items: center;
    }
  }

  .company-chrome__tag-count {
    color: var(--color-gain);
    font-weight: var(--weight-semibold);
    font-variant-numeric: tabular-nums lining-nums;
  }

  .company-chrome__quote {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: var(--space-sm) var(--space-xl);

    @media (width >= 1024px) {
      grid-column: 2;
      grid-row: 1;
      justify-content: flex-end;
    }
  }

  .company-chrome__price {
    display: block;
    min-block-size: var(--company-price-height);
  }

  .company-price {
    display: grid;
    align-content: end;
    gap: var(--space-3xs);
    block-size: var(--company-price-height);
  }

  .company-price__figures {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: var(--space-2xs) var(--space-sm);
  }

  .company-price__change {
    display: inline-flex;
    align-items: baseline;
    gap: var(--space-2xs);

    & .figure {
      font-weight: var(--weight-semibold);
    }
  }

  /* "After hours 352.17 ▼ 1.41 −0.40% · 6:12pm ET": quieter than the price
     above it, in the UI face; the time wraps under the figures on a phone. */
  .company-price__session {
    font-family: var(--font-ui);
    font-size: var(--text-ui);
    line-height: var(--leading-ui);
  }

  .company-price__session-figures {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: var(--space-3xs) var(--space-xs);
  }

  .company-price__session-time {
    color: var(--color-ink-subtle);
    font-size: var(--text-ui-sm);

    &::before {
      content: "· ";
    }
  }

  /* Follow at the size of the block it ends, Alert beside it, and for a
     reader with the notebook its button after them. No wider than the quote,
     so on a phone a third button wraps under the others rather than off the
     edge. */
  .company-chrome__follow {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-xs);
    max-inline-size: 100%;

    & .button {
      min-block-size: var(--control-height);
      padding-inline: var(--space-lg);
    }

    /* From a tablet up the buttons sit at the page's right edge, so the
       alert panel and the follow signup open leftward; on a phone they sit at the left and it opens
       rightward, as everywhere else. */
    @media (width >= 768px) {
      & .alert-panel,
      & .follow__signup-form {
        inset-inline: auto 0;
      }
    }
  }

  /* The stat bar: a double rule, then seven cells of a caps label over a
     serif figure, ending on a hairline. It scrolls sideways inside itself on
     a phone. */
  .stat-bar {
    display: grid;
    grid-auto-columns: minmax(7.5rem, 1fr);
    grid-auto-flow: column;
    gap: var(--space-lg);
    margin: var(--space-sm) 0 0;
    padding-block: calc(var(--rule-double-height) + var(--space-sm)) var(--space-sm);
    border-block-end: var(--rule-hairline);
    background: var(--rule-double) top / 100% var(--rule-double-height) no-repeat;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
  }

  .stat-bar__cell {
    display: grid;
    gap: var(--space-3xs);
  }

  .stat-bar__label {
    white-space: nowrap;
  }

  /* The fiscal year an estimate is for, after its label: as the ratios
     card writes it, not in capitals. */
  .stat-bar__period {
    text-transform: none;
    letter-spacing: 0;
  }

  .stat-bar__value {
    margin: 0;
    white-space: nowrap;
  }

  /* The date a figure is as of, under it: the Stock analysis's snapshot
     (companies/articles/_snapshot), whose figures are not all as fresh. */
  .stat-bar__note {
    color: var(--color-ink-muted);
    font-size: var(--text-ui-sm);
    white-space: nowrap;
  }

  .stat-bar__link {
    color: inherit;
    text-decoration: none;

    &:hover {
      text-decoration: underline;
      text-decoration-thickness: 1px;
    }
  }

  .company-tabs {
    margin-block-end: var(--space-md);
  }

  /*
   * The keystats report. From 1280px: the sidebar in a fixed column to the
   * left, the main column (.keystats__main, a grid) beside it, in source
   * order. Below 1280px: one column in reading order — the annual grid, the
   * chart and target (.keystats__overview), the revenue flow (M23), the
   * sidebar, the peers, the
   * business profile, the commentary, the rating changes, the holders, pay
   * and ownership from the proxy, the news, the metric links. `.keystats__main` is `display: contents` there, so its children are
   * items of this flex column and take their places by `order`. The desktop
   * DOM order and layout are unchanged.
   *
   * The catch: below 1280px `.keystats__main` has no box, so a gap, margin,
   * padding or border set on it silently stops applying there. The spacing
   * between its children is this column's gap at both widths.
   */
  .keystats {
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);

    @media (width >= 1280px) {
      flex-direction: row;
      align-items: flex-start;
    }

    /* With the alert drawer open (components/alert-drawer.css) the page is
       a drawer's width narrower than the window says, so the sidebar goes
       under the main column and the price chart keeps the width its alert
       lines are set against. */
    .app:has(.alert-drawer[open]) & {
      @media (width >= 1280px) {
        flex-direction: column;
        align-items: stretch;

        & .keystats__sidebar {
          order: 3;
          inline-size: auto;
        }
      }
    }
  }

  /* Ten years at a glance (companies/keystats/_financials; tasks/redesign,
     D9): the group's name and the row's label pinned on the left — the
     group column a fixed width, so the label column knows where to stick —
     ten years, the Trend bars, then the estimates. Below 640px the group
     column gives way to a full-width row above each group. */
  .ten-years {
    padding-block-end: var(--space-sm);
  }

  .ten-years__table {
    --group-width: 6.5rem;
  }

  .ten-years__group-cell {
    inline-size: var(--group-width);
    min-inline-size: var(--group-width);
    max-inline-size: var(--group-width);

    @media (width < 640px) {
      display: none;
    }
  }

  .ten-years__label {
    @media (width >= 640px) {
      inset-inline-start: var(--group-width);
    }
  }

  /* Pinned cells take the paper and no edge shadow: the hairline rows run
     under them, and the shadow fell across a column of labels. */
  :is(.ten-years__group-cell, .ten-years__label).data-table__label--pinned-start {
    box-shadow: none;
  }

  .ten-years__group-row {
    display: none;

    @media (width < 640px) {
      display: table-row;
    }

    & > th {
      padding-block-start: var(--space-sm);
      color: var(--color-ink-muted);
      font-size: var(--text-caps);
      font-weight: var(--weight-medium);
      letter-spacing: var(--tracking-caps);
      text-align: start;
      text-transform: uppercase;
    }
  }

  .ten-years__trend {
    padding-inline: var(--space-sm);
  }

  /* The trailing twelve months after the newest year, ruled off from the
     fiscal years it is not one of, its quarter under "TTM". */
  .ten-years__ttm {
    border-inline-start: var(--rule-hairline);
    white-space: nowrap;
  }

  .ten-years__ttm-period {
    display: block;
    color: var(--color-ink-subtle);
    font-size: var(--text-meta-xs);
    font-weight: var(--weight-regular);
  }

  .ten-years__foot {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--space-2xs) var(--space-lg);

    & .table-legend {
      margin-block-start: var(--space-xs);
    }
  }

  /* `powerpack_offers`: the row naming the table's two halves, wide screens
     only — a phone keeps neither half — and the two summary columns. */
  .ten-years__column-groups {
    @media (width < 640px) {
      display: none;
    }

    & > td {
      border-block-end: 0;
    }
  }

  .ten-years__column-group {
    padding-block-end: var(--space-2xs);
    border-block-end: var(--rule-hairline);
    color: var(--color-ink-soft);
    font-size: var(--text-caps);
    font-weight: var(--weight-medium);
    letter-spacing: var(--tracking-caps);
    text-align: start;
    text-transform: uppercase;

    & .lock {
      margin-inline-start: var(--space-xs);
      letter-spacing: normal;
      text-transform: none;
    }
  }

  .ten-years__column-group--forecast {
    background-color: var(--color-forecast);
  }

  .ten-years__change {
    padding-inline-start: var(--space-md);
    text-align: end;
    white-space: nowrap;
  }

  .ten-years__not-meaningful {
    color: var(--color-ink-muted);
  }

  /* The card's one cell, over every line below the teaser: the card at its
     top, the forecast tint below it. Wide enough for the card whatever the
     figures beside it: a company with short ones would otherwise squeeze it
     into a column of words. */
  .ten-years__offer-cell {
    min-inline-size: 24rem;
    padding: var(--space-sm);
    font-style: normal;
    text-align: start;
    vertical-align: top;
    white-space: normal;
  }

  /* The estimates' offer card (companies/keystats/_estimates_offer; its
     look is components/offer-card.css): centred in the cell over the
     forecast columns. Under the table it is the phone's own, there being no
     columns to sit over. */
  .estimates-offer {
    max-inline-size: 26rem;
    margin-inline: auto;
  }

  .estimates-offer--below {
    max-inline-size: none;
    margin-block: var(--space-md);
    box-shadow: none;

    @media (width >= 640px) {
      display: none;
    }
  }

  /* The overview's three forecast columns as one Powerpack lock, with
     paywall_v2 (M04-D4, G3): a cell spanning every row, still in the
     forecast tint, its lock in the middle. Upright: the italic is the
     forecast figures', and there are none. */
  .keystats__forecast-lock {
    vertical-align: middle;
    font-style: normal;
    white-space: normal;
  }

  /* Capital & Financial Ratios (companies/keystats/_capital_ratios): four
     groups, each a caps label over its rows, a little air between them —
     one column in the wide screen's sidebar, two where the card runs wider
     than two lists of label and figure need. */
  .keystats__ratios {
    container: ratios / inline-size;
  }

  /* A row the stat bar already shows: on paper only (print.css). */
  .keystats__ratio--stat-bar {
    display: none;
  }

  .keystats__ratio-groups {
    display: grid;
    gap: 0 var(--space-xl);

    @container ratios (width >= 40rem) {
      grid-template-columns: repeat(2, minmax(0, 1fr));
      align-items: start;
    }
  }

  .keystats__ratio-group {
    display: grid;
    gap: var(--space-2xs);
    padding-block-start: var(--space-sm);
  }

  /* Valuation's second half (companies/keystats/_valuation, M13-D7): the EV/Sales
     line, linked, then each valuation percentile's row over its range track. */
  .keystats__score-link {
    text-decoration: none;
  }

  /* The company among its peers (M17-D1): its own row
     bold, the median in the foot over a heavy rule, the figures right. */
  .peer-table {
    & tr[aria-current="true"] {
      font-weight: 600;
    }

    & tfoot th,
    & tfoot td {
      border-block-start: var(--rule-heavy);
      color: var(--color-ink-muted);
    }
  }

  /* A forward P/E's fiscal year after it, as a period note is set. */
  .peer-table__year {
    margin-inline-start: var(--space-3xs);
    color: var(--color-ink-subtle);
    font-size: var(--text-meta-xs);
    font-weight: var(--weight-regular);
    white-space: nowrap;
  }

  /* EV/Sales over the company's own ten years (M17-D8). */
  .keystats__history {
    padding-block: var(--space-sm);
    border-block-end: var(--rule-hairline);

    & .keystats__score-link {
      display: block;
      color: inherit;
    }
  }

  .keystats__percentile {
    padding-block-end: var(--space-xs);
    border-block-end: var(--rule-hairline);

    & .stat-list__row {
      border-block-end: 0;
    }

  }

  /* From 1280px, one column that never grows past its box: the charts and
     tables inside scroll within themselves instead of widening the page.

     Below it the sidebar gives up its box, as .keystats__main does, so its
     cards are items of the one column: the latest quarter straight after
     the chart and target (order 2, and earlier in the source than the
     annual grid), the rest where the sidebar always went. */
  .keystats__sidebar {
    order: 3;
    display: contents;

    & > * {
      order: 3;
      min-inline-size: 0;
    }

    & > .keystats__quarter {
      order: 2;
    }

    @media (width >= 1280px) {
      order: 1;
      display: grid;
      flex: none;
      grid-template-columns: minmax(0, 1fr);
      gap: var(--space-md);
      inline-size: 23.75rem;
    }
  }

  /* The Earnings Trends card (companies/keystats/_earnings_trends) in the
     sidebar's fixed column: the phone's plot and dots, not the tablet's. */
  .keystats__sidebar .earnings-trends {
    @media (width >= 1280px) {
      --earnings-trends-plot-height: 12rem;
      --earnings-trends-dot: 0.875rem;
    }
  }

  .keystats__main {
    display: contents;

    @media (width >= 1280px) {
      order: 2;
      display: grid;
      grid-template-columns: minmax(0, 1fr);
      gap: var(--space-lg);
      flex: 1;
      min-inline-size: 0;
    }
  }

  /* The main column's children, placed in the one-column reading order.
     From 1280px they are grid items of .keystats__main and keep its source
     order. */
  .keystats__financials,
  .keystats__overview,
  .keystats__flow,
  .keystats__peers,
  .keystats__profile,
  .keystats__commentary,
  .keystats__ratings,
  .keystats__holders,
  .keystats__proxy,
  .keystats__news,
  .keystats__metrics {
    min-inline-size: 0;
  }

  @media (width < 1280px) {
    .keystats__overview { order: 1; }
    .keystats__financials { order: 2; }
    .keystats__profile { order: 2; }
    .keystats__flow { order: 2; }
    .keystats__peers { order: 4; }
    .keystats__commentary { order: 4; }
    .keystats__ratings { order: 4; }
    .keystats__holders { order: 4; }
    .keystats__proxy { order: 4; }
    .keystats__news { order: 5; }
    .keystats__metrics { order: 6; }
  }

  .keystats__overview {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);

    @media (width >= 768px) {
      flex-direction: row;
    }
  }

  /* The price chart's height, read by the chart (.company-chart) and by the
     placeholder it replaces, so the page does not jump when it lands. 570px
     from 768px is `Companies::PriceChart::HEIGHT`; change both together. */
  .keystats__chart {
    --company-chart-height: 20rem;

    flex: 1;
    min-inline-size: 0;

    @media (width >= 768px) {
      --company-chart-height: 570px;
    }
  }

  /* Highcharts sizes a chart from its container when it is given no height,
     and the `stock-chart` controller draws into a div of its own inside the
     canvas, which has to fill it. The interval menu sits above the canvas
     inside the same height, so the placeholder's height still holds. */
  .company-chart {
    container: company-chart / inline-size;
    display: flex;
    flex-direction: column;
    block-size: var(--company-chart-height);
  }

  /* Two rows over the chart: the candle widths on the left and the spans on
     the right, every one a button, wrapping under each other where the
     chart is too narrow for both; then, under a hairline, what the chart
     flags. The buttons sit tighter than a segmented control's own gap, so
     eleven of them fit a phone in two lines. */
  .company-chart__head {
    display: flex;
    flex: none;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 0 var(--space-lg);

    & .segmented {
      gap: 0 var(--space-sm);
    }
  }

  .company-chart__ranges {
    justify-content: flex-end;
  }

  .company-chart__intervals {
    flex: none;
  }

  .company-chart__layers {
    display: flex;
    flex: none;
    flex-wrap: wrap;
    align-items: center;
    gap: 0 var(--space-sm);
    margin-block-end: var(--space-xs);
    border-block-start: var(--rule-hairline);

    & .segmented {
      gap: 0 var(--space-sm);
    }
  }

  .company-chart__canvas {
    flex: 1;
    min-block-size: 0;

    & > div {
      block-size: 100%;
    }
  }

  .keystats__aside {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-content: start;
    gap: var(--space-md);

    @media (width >= 768px) {
      flex: none;
      inline-size: 14.375rem;
    }
  }
}

/*
 * The analyst recommendation rating (companies/keystats/_recommendation_rating):
 * a 1–5 track in the gain → loss ramp and a marker at the rating. Its position
 * is data (--position, from `recommendation_position`), and its fill is one of
 * five bands (`recommendation_marker_classes`).
 */
@layer pages {
  .rating-scale {
    position: relative;
    margin-block: var(--space-3xl) var(--space-xs);
  }

  .rating-scale__track {
    block-size: 0.375rem;
    background: linear-gradient(
      to right,
      var(--color-ramp-gain-3),
      var(--color-ramp-gain-1) 50%,
      var(--color-ramp-loss-1) 75%,
      var(--color-ramp-loss-2)
    );
  }

  .rating-scale__marker {
    --marker: var(--color-ink);
    --marker-ink: var(--color-ink-inverse);

    position: absolute;
    inset-block-end: calc(100% + var(--space-2xs));
    inset-inline-start: var(--position);
    translate: -50% 0;
    padding: var(--space-3xs) var(--space-xs);
    border-radius: var(--radius-md);
    background-color: var(--marker);
    color: var(--marker-ink);
    font-size: var(--text-meta-xs);
    font-weight: var(--weight-semibold);
    font-variant-numeric: tabular-nums lining-nums;

    &::after {
      content: "";
      position: absolute;
      inset-block-start: 100%;
      inset-inline-start: 50%;
      translate: -50% 0;
      border: 4px solid transparent;
      border-block-start-color: var(--marker);
    }
  }

  .rating-scale__marker--1 { --marker: var(--color-ramp-gain-3); --marker-ink: var(--color-ramp-gain-3-ink); }
  .rating-scale__marker--2 { --marker: var(--color-ramp-gain-2); --marker-ink: var(--color-ramp-gain-2-ink); }
  .rating-scale__marker--3 { --marker: var(--color-ink-muted); --marker-ink: var(--color-ink-inverse); }
  .rating-scale__marker--4 { --marker: var(--color-ramp-loss-1); --marker-ink: var(--color-ramp-loss-1-ink); }
  .rating-scale__marker--5 { --marker: var(--color-ramp-loss-2); --marker-ink: var(--color-ramp-loss-2-ink); }

  /* Five ticks, each number over its caption, spread so the first sits under
     the start of the track and the last under its end. */
  .rating-scale__labels {
    display: flex;
    justify-content: space-between;
    margin-block-start: var(--space-xs);
    color: var(--color-ink-muted);
    font-size: var(--text-meta-xs);
    line-height: var(--leading-meta-xs);
    text-align: center;

    & > span {
      display: grid;
      min-inline-size: 1.5rem;
    }

    & > :first-child {
      text-align: start;
    }

    & > :last-child {
      text-align: end;
    }
  }
}

/*
 * The keystats report's own panels.
 */
@layer pages {
  /* The Dividends card (companies/keystats/_dividends): four figures in two
     columns, then a bar a year — what was paid in the series colour, a
     forecast outlined on the forecast tint, a forecast year's paid part
     filled from the foot — its total over it, its year and change under. */
  .dividend-stats {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-sm) var(--space-md);
    margin: 0;
    padding-block: var(--space-sm);
    border-block-end: var(--rule-hairline);

    & dd {
      margin: 0;
      font-weight: var(--weight-semibold);
    }
  }

  .dividend-stats__cell {
    display: grid;
    gap: var(--space-3xs);
  }

  .dividend-chart {
    --dividend-chart-height: 7rem;

    display: grid;
    grid-auto-columns: minmax(0, 1fr);
    grid-auto-flow: column;
    align-items: end;
    gap: var(--space-2xs);
    margin: var(--space-sm) 0 0;
    padding: 0;
    list-style: none;
    font-family: var(--font-data);
    font-variant-numeric: tabular-nums lining-nums;
  }

  /* One column, held to the year's width: an auto column grew to a label's,
     and took the bar with it. */
  .dividend-chart__year {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    justify-items: center;
    gap: var(--space-3xs);
    min-inline-size: 0;
  }

  .dividend-chart__total,
  .dividend-chart__change {
    color: var(--color-ink-subtle);
    font-size: var(--text-meta-xs);
    white-space: nowrap;
  }

  /* A line even with no change to show, or that year's foot drops below the
     others': the first year, and the year after one of no dividend. */
  .dividend-chart__change {
    min-block-size: 1lh;
  }

  .dividend-chart__bar {
    inline-size: 100%;
    block-size: calc(var(--share) * var(--dividend-chart-height));
    background: linear-gradient(to top, var(--color-series-1) calc(var(--paid) * 100%), transparent 0);
  }

  .is-forecast .dividend-chart__bar {
    border: var(--rule-width) dashed var(--color-rule-control);
    background-color: var(--color-forecast);
  }

  .dividend-chart__label {
    padding-block-start: var(--space-3xs);
    border-block-start: var(--rule-hairline);
    inline-size: 100%;
    color: var(--color-ink-muted);
    font-size: var(--text-meta-xs);
    text-align: center;
  }

  .dividend-key {
    display: inline-block;
    inline-size: 0.75rem;
    block-size: 0.75rem;
    vertical-align: middle;
  }

  .dividend-key--paid {
    background-color: var(--color-series-1);
  }

  .dividend-key--forecast {
    border: var(--rule-width) dashed var(--color-rule-control);
    background-color: var(--color-forecast);
  }

  /* Target price range: high, average and low on hairlines, the average —
     the one a reader quotes — set bold (tasks/redesign, D10). */
  .target-price__row {
    display: flex;
    align-items: baseline;
    gap: var(--space-xs);
    padding-block: var(--space-xs);
    border-block-end: var(--rule-hairline);
    font-size: var(--text-ui-sm);

    & > :first-child {
      flex: 1;
      color: var(--color-ink-muted);
    }
  }

  .target-price__row--mean {
    font-weight: var(--weight-semibold);

    & > :first-child {
      color: var(--color-ink);
    }
  }

  .target-price__figure {
    min-inline-size: 4rem;
    text-align: end;
  }

  /* The excerpts on the overview (the earnings call, the business profile):
     the prose, and the link to the full article beside it from 1024px. The
     prose takes what the link leaves, so its own measure is what stops it. */
  .commentary {
    display: grid;
    gap: var(--space-md);

    @media (width >= 1024px) {
      grid-template-columns: minmax(0, 1fr) auto;
    }
  }

  /* Under the annual grid on a phone, where it shows four years of ten: the
     way to the rest. */
  .keystats__all-years {
    margin: 0;
    padding-inline: var(--space-md);
    font-size: var(--text-ui-sm);
    font-weight: var(--weight-semibold);

    & a {
      display: inline-flex;
      align-items: center;
      min-block-size: var(--target-min);
    }

    @media (width >= 640px) {
      display: none;
    }
  }

  .commentary__more {
    font-size: var(--text-ui);
    font-weight: var(--weight-semibold);
  }
}

/*
 * The statement pages: the period switcher, the chart beside the statement's
 * description, and the table.
 */
@layer pages {
  .periods {
    margin-block: calc(var(--space-xs) * -1) var(--space-lg);
  }

  /* The period switcher and "Download Excel" on one row (paywall_v2). The
     tabs keep their own sideways scroll on a phone, so the row never grows
     wider than the page; the link drops under them when there is no room. */
  .statement-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-xs) var(--space-md);
    margin-block: calc(var(--space-xs) * -1) var(--space-lg);

    & > .tabs {
      flex: 1 1 20rem;
      min-inline-size: 0;
      margin-block: 0;
    }
  }

  /* "Download Excel": a caps text link in the green, not a button
     (tasks/redesign, D11). */
  .statement-toolbar__download {
    display: inline-flex;
    align-items: center;
    min-block-size: var(--target-min);
    color: var(--color-link);
    font-size: var(--text-meta-xs);
    font-weight: var(--weight-medium);
    letter-spacing: var(--tracking-caps);
    text-decoration: none;
    text-transform: uppercase;

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

  .statement-overview {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-lg);
    margin-block-end: var(--space-lg);

    @media (width >= 768px) {
      grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
    }

    @media (width >= 1024px) {
      grid-template-columns: minmax(0, 7fr) minmax(0, 3fr);
    }
  }

  /* The locked chart cell for a reader without Powerpack: not on a phone,
     where it would be a 300px panel between the reader and the table. */
  .statement-overview__locked-chart {
    @media (width < 768px) {
      display: none;
    }
  }

  /* A statement with no chart (Metrics & Ratios): the description alone, one
     full-width track at every width. */
  .statement-overview--no-chart {
    @media (width >= 768px) {
      grid-template-columns: minmax(0, 1fr);
    }
  }

  /* The picture over a statement (companies/financials/_*_picture,
     Companies::StatementPicture): the heading, a sentence about this company
     with the way to what the statement is, then the bridge, the balance
     sheet's columns or the trend. On a wide page the income statement's
     bridge and its margins sit side by side. */
  /* The sentence close under the heading, and the charts set well apart
     from it (owner, 2026-11-19). */
  .statement-picture {
    container: statement-picture / inline-size;
    display: grid;
    gap: var(--space-xs);
    margin-block-end: var(--space-lg);
  }

  /* On the card's children, to outweigh the cash flow's figures' own
     `margin: 0` further down. */
  .statement-picture > .statement-picture__lede + *,
  .statement-picture > .statement-picture__stats + .statement-picture__body {
    margin-block-start: var(--space-xl);
  }

  .statement-picture__body + .statement-picture__foot {
    margin-block-start: var(--space-xs);
  }

  .statement-picture__lede {
    max-inline-size: var(--measure);
    color: var(--color-ink-soft);
    font-family: var(--font-prose);
    font-size: var(--text-prose);
    line-height: var(--leading-prose);
    text-wrap: pretty;
  }

  .statement-picture__about {
    font-family: var(--font-ui);
    font-size: var(--text-ui-sm);
    white-space: nowrap;
  }

  /* On a phone the waterfall fits the card rather than scrolling (owner,
     2026-11-19): its columns share the width, and its figures, shares and
     names are turned to read upwards, set at the smallest size, each hung
     from the top of its row. Turned with `writing-mode` and a half turn, the
     inline end is the top and the inline start the foot. Below 41rem, where
     nine columns of 4.5rem stop fitting. */
  @container statement-picture (width < 41rem) {
    .statement-picture .waterfall-scroll {
      padding-block-end: 0;
      overflow: visible;
    }

    .statement-picture .waterfall {
      grid-template-columns: repeat(var(--steps), minmax(0, 1fr));
    }

    .statement-picture :is(.waterfall__value, .waterfall__share, .waterfall__label) {
      justify-self: center;
      padding: 0;
      font-size: var(--text-meta-xs);
      line-height: var(--leading-meta-xs);
      text-align: end;
      white-space: nowrap;
      writing-mode: vertical-rl;
      rotate: 180deg;
    }

    .statement-picture .waterfall__value {
      padding-inline-start: var(--space-2xs);
    }

    .statement-picture .waterfall__share,
    .statement-picture .waterfall:not(.waterfall--with-share) .waterfall__value {
      padding-inline-start: var(--space-xs);
    }

    .statement-picture .waterfall__label {
      padding-inline-end: var(--space-xs);
    }
  }

  /* One track the card's width: an implicit one grew to the waterfall's
     widest columns and pushed a phone's page wider than its screen, where
     the waterfall should scroll in its own box. */
  .statement-picture__body {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-xl);
  }

  /* The charts, and the cash flow's figures over them, stop stretching at
     the chart measure. */
  .statement-picture__body,
  .statement-picture__stats {
    max-inline-size: var(--chart-measure);
  }

  /* A statement's charts take at most half the screen (owner, 2026-11-19):
     stacked on a narrow card, the two together; side by side, each. The
     trend's drawing is capped here, through its width so its period labels
     stay under their points, and the chart beside it stretches to it. */
  .statement-picture__body .trend-chart__view {
    max-inline-size: calc(max(8rem, 25svh - 4rem) * var(--aspect));
  }

  @container statement-picture (width >= 48rem) {
    .statement-picture__body .trend-chart__view {
      max-inline-size: calc(max(12rem, 50svh - 7rem) * var(--aspect));
    }

    .statement-picture__body {
      grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
      gap: var(--space-2xl);
      align-items: start;
    }
  }

  /* The balance sheet's two columns (BalanceColumnsHelper): what it owns
     against what funds it, side by side and standing on one line, each
     block as tall as its share of the taller column's total (`--share`),
     each column as tall as its total's share of that (`--fill`). Beside
     the trend they stretch to its height, so the two end level; alone,
     on a narrow card, they are about a fifth of the screen. A block too small for its figure and
     name keeps room for both, so the smallest parts are drawn a little
     larger than their share. */
  .balance-columns {
    display: grid;
    grid-template-rows: auto minmax(clamp(8.5rem, 18svh, 20rem), 1fr) auto;
    gap: var(--space-sm);
    margin: 0;
  }

  @container statement-picture (width >= 48rem) {
    /* Every statement's two charts, side by side: each stretches to the
       other's height. */
    .statement-picture__body--paired {
      align-items: stretch;
    }

    .statement-picture__chart {
      display: grid;
    }

    /* A waterfall in half the card: narrower columns, so nine steps still
       fit without scrolling. */
    .statement-picture__chart .waterfall {
      grid-template-columns: repeat(var(--steps), minmax(3rem, 1fr));
    }

    .balance-columns {
      grid-template-rows: auto minmax(10rem, 1fr) auto;
    }

    /* The income statement's and the cash flow's: the waterfall and the
       trend on five shared rows (owner, 2026-11-19) — the waterfall's
       figures beside the trend's title; its shares; the two drawings; its
       names beside the trend's period labels, so its foot and the trend's x
       axis are one line; the trend's key. Each part is a subgrid down to
       its cells, with no gaps of its own, so the rows stay shared. */
    .statement-picture__body--aligned {
      grid-template-rows: auto auto minmax(0, 1fr) auto auto;
      row-gap: 0;
    }

    .statement-picture__body--aligned > *,
    .statement-picture__body--aligned .waterfall-scroll,
    .statement-picture__body--aligned .waterfall,
    .statement-picture__body--aligned .trend-chart {
      display: grid;
      grid-row: 1 / -1;
      grid-template-rows: subgrid;
      row-gap: 0;
    }

    /* Wide enough here not to scroll, and a scroller's padding would
       take room from the shared rows. */
    .statement-picture__body--aligned .waterfall-scroll {
      padding: 0;
      overflow: visible;
    }

    .statement-picture__body--aligned .waterfall__value,
    .statement-picture__body--aligned .trend-chart__caption {
      grid-row: 1;
    }

    .statement-picture__body--aligned .waterfall__share {
      grid-row: 2;
    }

    .statement-picture__body--aligned .waterfall__plot {
      grid-row: 3;
      min-block-size: 10rem;
    }

    .statement-picture__body--aligned .waterfall__label {
      grid-row: 4;
    }

    .statement-picture__body--aligned .trend-chart__view {
      grid-row: 3 / span 2;
      grid-template-rows: subgrid;
    }

    /* At the foot of its row, whichever chart sets the row's height, and
       drawn down by the strip under its x axis (a margin's percentage is of
       the width), so the axis itself is the row's foot and the strip, with
       the lowest axis label, hangs into the period labels' padding. */
    .statement-picture__body--aligned .trend-chart__plot {
      align-self: end;
      margin-block-end: calc(-100% * var(--foot));
    }

    .statement-picture__body--aligned .trend-chart__ticks {
      padding-block-start: var(--space-xs);
    }

    .statement-picture__body--aligned .trend-chart__keys {
      grid-row: 5;
      padding-block-start: var(--space-sm);
    }

    /* The balance sheet's on the same rows: the columns' date beside the
       trend's sentence, the two columns standing on the trend's x axis, and
       their note, its rule the same line, beside the period labels. The
       trend and its sentence share their wrapper's rows. */
    .statement-picture__body--aligned .statement-picture__trend .trend-chart {
      grid-column: 1;
    }

    .statement-picture__body--aligned :is(.balance-columns__caption, .statement-picture__trend-sentence) {
      grid-row: 1;
      grid-column: 1;
      padding-block-end: var(--space-sm);
    }

    .statement-picture__body--aligned .balance-columns__pair {
      grid-row: 3;
    }

    .statement-picture__body--aligned .balance-columns__note {
      grid-row: 4;
    }

    /* A container cannot be a subgrid, so here the trend is not one: which
       drawing it shows is read off the card's width instead, at the column
       width its own query uses (30rem, the card being two columns and a 2rem
       gap). Capped at the chart measure, a column never reaches the wide
       drawing's 48rem. */
    .statement-picture__body--aligned .trend-chart {
      container-type: normal;
    }

    .statement-picture__body--aligned .trend-chart__view.trend-chart__view--wide,
    .statement-picture__body--aligned .trend-chart__view.trend-chart__view--narrow {
      display: none;
    }

    .statement-picture__body--aligned .trend-chart__view.trend-chart__view--small {
      display: grid;
    }
  }

  @container statement-picture (width >= 62rem) {
    .statement-picture__body--aligned .trend-chart__view.trend-chart__view--narrow {
      display: grid;
    }

    .statement-picture__body--aligned .trend-chart__view.trend-chart__view--small {
      display: none;
    }
  }

  .balance-columns__caption,
  .balance-columns__note {
    color: var(--color-ink-subtle);
    font-size: var(--text-meta);
    line-height: var(--leading-meta);
  }

  .balance-columns__note {
    padding-block-start: var(--space-xs);
    border-block-start: var(--rule-hairline);
  }

  .balance-columns__pair {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: var(--space-md);
  }

  .balance-columns__side {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    gap: var(--space-2xs);
  }

  .balance-columns__heading {
    text-align: center;
  }

  /* The room a column stands in; the column takes its share of it from the
     foot up. */
  .balance-columns__frame {
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    min-block-size: 0;
  }

  .balance-columns__stack {
    display: flex;
    flex-direction: column;
    gap: 2px;
    block-size: calc(var(--fill) * 100%);
  }

  .balance-columns__block {
    display: flex;
    flex: var(--share) 1 0;
    flex-direction: column;
    justify-content: center;
    min-block-size: 2.75rem;
    padding: var(--space-2xs) var(--space-xs);
    color: var(--color-ink);
  }

  .balance-columns__block--long-term { background: var(--color-ramp-gain-1); }
  .balance-columns__block--short-term { background: var(--color-ramp-gain-2); }
  .balance-columns__block--equity { background: var(--color-mask); }
  .balance-columns__block--liabilities { background: var(--color-warn-tint); }

  .balance-columns__block--cash {
    background: var(--color-ramp-gain-3);
    color: var(--color-ramp-gain-3-ink);
  }

  .balance-columns__block--debt {
    background: var(--color-ramp-loss-2);
    color: var(--color-ramp-loss-2-ink);
  }

  .balance-columns__figure {
    font-size: var(--text-ui);
    font-weight: var(--weight-semibold);
    line-height: var(--leading-ui);
  }

  .balance-columns__name {
    font-size: var(--text-meta);
    line-height: var(--leading-meta);
  }

  /* The trend beside the columns, its sentence over it. */
  .statement-picture__trend {
    display: grid;
    gap: var(--space-sm);
  }

  .statement-picture__trend-sentence {
    color: var(--color-ink-soft);
    font-size: var(--text-ui-sm);
    line-height: var(--leading-ui-sm);
  }

  /* Metrics & Ratios: four panels, two by two once there is room. */
  .statement-picture__panels {
    display: grid;
    gap: var(--space-xl) var(--space-2xl);
  }

  /* Four panels in a row on a wide page, two on a narrower one, where a
     panel's chart stops growing at a little past its drawn size. */
  @container statement-picture (width >= 36rem) {
    .statement-picture__panels {
      grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .statement-picture__panel .trend-chart__view {
      max-inline-size: 24rem;
    }

    /* Panels side by side share their rows — heading, sentence, drawing,
       period labels, key — so a sentence a line longer than its
       neighbour's no longer lifts or drops its chart, and every chart's x
       axis is one line (owner, 2026-11-19). The drawing stands at the foot
       of its row, pulled down by the strip under its axis. */
    .statement-picture__panels {
      row-gap: var(--space-xs);
    }

    .statement-picture__panel {
      grid-row: span 5;
      grid-template-rows: subgrid;
      padding-block-end: var(--space-lg);
    }

    .statement-picture__panel .trend-chart {
      grid-row: span 3;
      grid-template-rows: subgrid;
    }

    .statement-picture__panel .trend-chart__view {
      grid-row: span 2;
      grid-template-rows: subgrid;
    }

    .statement-picture__panel .trend-chart__plot {
      align-self: end;
      margin-block-end: calc(-100% * var(--foot));
    }
  }

  @container statement-picture (width >= 68rem) {
    .statement-picture__panels {
      grid-template-columns: repeat(4, minmax(0, 1fr));
    }
  }

  .statement-picture__panel {
    display: grid;
    gap: var(--space-xs);
    align-content: start;
    padding-block-start: var(--space-xs);
    border-block-start: var(--rule-hairline);
  }

  .statement-picture__fact {
    color: var(--color-ink-soft);
    font-size: var(--text-ui);
    line-height: var(--leading-ui);
  }

  .statement-picture__stats {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-md) var(--space-lg);
    margin: 0;
    padding-block: var(--space-sm);
    border-block: var(--rule-hairline);

    & dd {
      display: grid;
      gap: var(--space-3xs);
      margin: 0;
    }
  }

  @container statement-picture (width >= 40rem) {
    .statement-picture__stats {
      grid-template-columns: repeat(4, minmax(0, 1fr));
    }
  }

  .statement-picture__stat {
    display: grid;
    gap: var(--space-3xs);
    align-content: start;
  }

  .statement-picture__figure {
    font-family: var(--font-prose);
    font-size: var(--text-stat);
    font-weight: var(--weight-semibold);
    line-height: var(--leading-stat);
  }

  .statement-picture__note,
  .statement-picture__foot {
    color: var(--color-ink-subtle);
    font-size: var(--text-meta);
    line-height: var(--leading-meta);
  }

  .statement-description {
    display: grid;
    gap: var(--space-xs);
    align-content: start;
    font-size: var(--text-ui-sm);
    line-height: 1.55;
    color: var(--color-ink-soft);
  }

  .statement-table {
    & .data-table__label {
      inline-size: clamp(9rem, 40vw, 18rem);
      white-space: normal;
    }

    & th:not(.data-table__label),
    & td:not(.data-table__label) {
      inline-size: 6rem;
    }
  }

  /* Under a column's date, while its figures are the filing's rather than
     Zacks' (tasks/growth/milestones/28, D8). */
  .statement-table__filed {
    display: block;
    font-weight: var(--weight-regular);
    font-size: var(--text-meta-xs);
    line-height: var(--leading-meta-xs);
    text-transform: none;
    letter-spacing: normal;
    white-space: normal;
  }

  /* The one lock column a statement carries with paywall_v2 (M04-D4, G2):
     a cell spanning every row at the older end of the periods, its lock held
     near the top where the sticky header leaves it in view. Wider than a
     period column, because it holds a sentence; wider again when it holds
     Powerpack's offer card (shared/_powerpack_offer). */
  .statement-table {
    & th.statement-table__lock-head,
    & td.statement-table__lock {
      inline-size: 12rem;
    }

    &:has(td.statement-table__lock .offer-card) :is(th.statement-table__lock-head, td.statement-table__lock) {
      inline-size: 20rem;
    }
  }

  .statement-table__lock {
    vertical-align: top;
    white-space: normal;
    background-color: var(--color-surface-sunken);

    & :is(.lock-panel, .offer-card) {
      position: sticky;
      inset-block-start: var(--space-2xl);
    }

    /* A table's cells set their figures to the end; the card reads as text. */
    & .offer-card {
      text-align: start;
    }
  }

  .statement-table__label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-xs);
  }

  /* The name takes the room between the chevron and the wiki glyph. */
  .statement-table__name {
    flex: 1;
  }

  /* A row's definition (M09-D6) opens in the row rather than over the rows
     below it: the table scrolls inside its own box, which would clip a
     popover, and the pinned label cells stack over one another. */
  .statement-table .definition {
    display: block;

    /* The chevron, drawn rather than inlined a hundred times: two sides of
       a small square, turned to point down, and up once open. */
    & > .disclosure__summary::after {
      content: "";
      inline-size: 0.3125rem;
      block-size: 0.3125rem;
      margin-block-start: calc(-1 * var(--space-2xs));
      border-inline-end: var(--rule-width-strong) solid var(--color-ink-subtle);
      border-block-end: var(--rule-width-strong) solid var(--color-ink-subtle);
      rotate: 45deg;
      transition: rotate var(--duration-fast);
    }

    &[open] > .disclosure__summary::after {
      margin-block-start: var(--space-2xs);
      rotate: 225deg;
    }

    & > .disclosure__body {
      position: static;
      inline-size: auto;
      margin-block: var(--space-2xs);
      box-shadow: none;
      white-space: normal;
    }
  }

  /* The chevron that shows the Advanced lines folded under a line (M09-D5).
     It points right while they are hidden and down once they are shown —
     the state is the button's aria-expanded, which the row-group controller
     keeps. */
  .statement-table__toggle {
    flex: none;
    inline-size: 1.5rem;
    block-size: 1.5rem;

    @media (pointer: coarse) {
      inline-size: var(--target-min);
      block-size: var(--target-min);
    }

    & .icon {
      transition: rotate var(--duration-fast);
    }

    &[aria-expanded="true"] .icon {
      rotate: 90deg;
    }
  }

  /* "Show all line items": the same table unfolded on the server. */
  .statement-table__fold {
    padding: var(--space-sm) var(--space-md);
    border-block-start: var(--rule-width) solid var(--color-rule);
    font-size: var(--text-ui-sm);
  }
}

/*
 * The Latest quarter card (companies/keystats/_latest_quarter,
 * LatestQuarterHelper): first in the sidebar on a wide screen, straight after
 * the price chart on a narrow one. Laid out by its own width: where it is
 * wide (the one-column page), the lines and the growth chart sit side by
 * side and the two notes under them do too; in the sidebar they stack; and
 * under 30rem each line takes two rows, its label and figure over its
 * change and its result against the consensus.
 */
@layer pages {
  .latest-quarter {
    container: latest-quarter / inline-size;
  }

  .latest-quarter__lede {
    display: grid;
    gap: var(--space-2xs);
    margin-block-end: var(--space-md);
  }

  .latest-quarter__headline {
    margin: 0;
    max-inline-size: var(--measure);
    font-family: var(--font-prose);
    font-size: var(--text-lead);
    font-weight: var(--weight-semibold);
    line-height: var(--leading-lead);
    text-wrap: balance;

    & a {
      color: var(--color-ink);
      text-decoration: none;

      &:hover {
        color: var(--color-link-hover);
        text-decoration: underline;
        text-decoration-thickness: 1px;
        text-underline-offset: 0.2em;
      }
    }
  }

  .latest-quarter__dateline {
    margin: 0;
    color: var(--color-ink-muted);
    font-size: var(--text-ui-sm);
  }

  .latest-quarter__body {
    display: grid;
    gap: var(--space-lg);

    @container latest-quarter (width >= 44rem) {
      grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
      gap: var(--space-2xl);
      align-items: start;
    }
  }

  /* The three lines: a table's columns from rows of a subgrid. */
  .latest-quarter__lines {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto auto;
    font-family: var(--font-data);
    font-size: var(--text-data);
    line-height: var(--leading-data);
    font-variant-numeric: tabular-nums lining-nums;
  }

  .latest-quarter__row {
    display: grid;
    grid-column: 1 / -1;
    grid-template-columns: subgrid;
    align-items: baseline;
    border-block-end: var(--rule-hairline);

    & > * {
      padding: 0.4375rem 0 0.4375rem var(--space-md);
      text-align: end;
    }

    & > :first-child {
      padding-inline-start: 0;
      text-align: start;
    }
  }

  .latest-quarter__row--head {
    border-block-end-color: var(--color-rule-strong);

    & > * {
      padding-block: var(--space-2xs);
      color: var(--color-ink-muted);
      font-size: var(--text-table-head);
      line-height: var(--leading-table-head);
      white-space: nowrap;
    }
  }

  .latest-quarter__label {
    font-family: var(--font-ui);
    font-size: var(--text-ui-sm);
  }

  .latest-quarter__value {
    font-family: var(--font-prose);
    font-size: var(--text-prose);
    font-weight: var(--weight-semibold);
  }

  .latest-quarter__inline-label {
    display: none;
    color: var(--color-ink-subtle);
    font-size: var(--text-meta);
  }

  .latest-quarter__against {
    display: grid;
    justify-items: end;
  }

  .latest-quarter__result {
    font-weight: var(--weight-semibold);
    white-space: nowrap;
  }

  .latest-quarter__result--beat { color: var(--color-gain); }
  .latest-quarter__result--missed { color: var(--color-loss); }
  .latest-quarter__result--met { color: var(--color-ink); }

  .latest-quarter__consensus {
    color: var(--color-ink-subtle);
    font-size: var(--text-meta);
    white-space: nowrap;
  }

  /* A line's last quarters (LatestQuarterHelper#latest_quarter_bars_tag):
     a strip of bars across the row, under its figures, from a zero line,
     the latest darker, a loss below the line in brick; the first and last
     quarters named at its ends. Each bar's foot and height arrive as shares
     of the plot. */
  .latest-quarter__row > .latest-quarter__bars {
    display: grid;
    grid-column: 1 / -1;
    grid-template-columns: 1fr 1fr;
    padding: 0 0 var(--space-3xs);
    text-align: start;
  }

  .latest-quarter__bars-plot {
    position: relative;
    display: grid;
    grid-column: 1 / -1;
    grid-template-columns: repeat(var(--quarters), minmax(0, 1fr));
    column-gap: var(--space-xs);
    block-size: 2.5rem;

    &::after {
      content: "";
      position: absolute;
      inset-inline: 0;
      inset-block-end: var(--zero);
      border-block-start: var(--rule-width) solid var(--color-rule-strong);
    }
  }

  .latest-quarter__bar {
    position: relative;

    &::before {
      content: "";
      position: absolute;
      inset-inline: 0;
      inset-block-end: var(--foot);
      block-size: var(--height);
      background: color-mix(in srgb, var(--color-bar-gain) 50%, var(--color-ground));
    }
  }

  .latest-quarter__bar--loss::before {
    background: color-mix(in srgb, var(--color-bar-loss) 50%, var(--color-ground));
  }

  .latest-quarter__bar--latest::before {
    background: var(--color-bar-gain);
  }

  .latest-quarter__bar--latest.latest-quarter__bar--loss::before {
    background: var(--color-bar-loss);
  }

  .latest-quarter__bars-end {
    padding-block-start: var(--space-3xs);
    color: var(--color-ink-subtle);
    font-size: var(--text-meta-xs);
    line-height: var(--leading-meta-xs);

    &:last-child {
      text-align: end;
    }
  }

  .latest-quarter__footnote {
    margin: var(--space-xs) 0 0;
    color: var(--color-ink-subtle);
    font-size: var(--text-meta);
    line-height: var(--leading-meta);
  }

  /* Narrow: a line's label and figure, then its change and its result. */
  @container latest-quarter (width < 30rem) {
    .latest-quarter__lines {
      grid-template-columns: minmax(0, 1fr) auto;
    }

    .latest-quarter__row {
      row-gap: var(--space-3xs);
      padding-block: var(--space-xs);

      & > * {
        padding: 0;
      }

      & > :nth-child(3) {
        text-align: start;
      }
    }

    .latest-quarter__row--head {
      display: none;
    }

    .latest-quarter__inline-label {
      display: inline;
    }
  }

  .latest-quarter__growth {
    display: grid;
    gap: var(--space-xs);
    margin: 0;
  }

  .latest-quarter__sentence {
    margin: 0;
    color: var(--color-ink-soft);
    font-family: var(--font-prose);
    font-size: var(--text-prose-sm);
    line-height: var(--leading-prose-sm);
    text-wrap: pretty;
  }

  /* Growth a quarter, from a zero line: each bar's foot and height, the
     zero line and a label's place arrive as shares of the plot. */
  .growth-chart {
    --growth-chart-plot: 8.5rem;

    display: grid;
    grid-template-columns: repeat(var(--quarters), minmax(0, 1fr));
    grid-template-rows: var(--growth-chart-plot) auto;
    column-gap: var(--space-2xs);
    margin-block-start: var(--space-sm);
  }

  .growth-chart__plot {
    position: relative;
    display: grid;
    grid-column: 1 / -1;
    grid-template-columns: subgrid;
  }

  .growth-chart__zero {
    position: absolute;
    inset-inline: 0;
    inset-block-end: var(--zero);
    border-block-start: var(--rule-width) solid var(--color-ink-muted);
  }

  .growth-chart__column {
    position: relative;
  }

  .growth-chart__bar {
    position: absolute;
    inset-inline: 18%;
    inset-block-end: var(--foot);
    block-size: var(--height);
    background: color-mix(in srgb, var(--color-bar-gain) 50%, var(--color-ground));
  }

  .growth-chart__bar--loss {
    background: color-mix(in srgb, var(--color-bar-loss) 50%, var(--color-ground));
  }

  .growth-chart__column--latest {
    & .growth-chart__bar {
      background: var(--color-bar-gain);
    }

    & .growth-chart__bar--loss {
      background: var(--color-bar-loss);
    }

    & .growth-chart__value {
      color: var(--color-ink);
      font-weight: var(--weight-semibold);
    }
  }

  .growth-chart__value {
    position: absolute;
    inset-inline: calc(-1 * var(--space-xs));
    inset-block-end: calc(var(--label) + var(--space-2xs));
    color: var(--color-ink-muted);
    font-size: var(--text-meta-xs);
    line-height: 1;
    text-align: center;
    font-variant-numeric: tabular-nums lining-nums;
    white-space: nowrap;
  }

  .growth-chart__quarter {
    padding-block-start: var(--space-2xs);
    color: var(--color-ink-muted);
    font-size: var(--text-meta-xs);
    line-height: var(--leading-meta-xs);
    text-align: center;

    & > span {
      display: block;
    }

    @container latest-quarter (width >= 30rem) {
      & > span {
        display: inline;
      }
    }
  }

  /* What drove it, and the outlook: a caps label over a line each. */
  .latest-quarter__notes {
    display: grid;
    gap: var(--space-md);
    margin-block-start: var(--space-lg);
    padding-block-start: var(--space-md);
    border-block-start: var(--rule-hairline);

    @container latest-quarter (width >= 44rem) {
      grid-template-columns: repeat(2, minmax(0, 1fr));
      gap: var(--space-2xl);
    }
  }

  .latest-quarter__note {
    display: grid;
    gap: var(--space-2xs);
    align-content: start;

    & p {
      margin: 0;
      color: var(--color-ink-soft);
      font-size: var(--text-ui);
      line-height: var(--leading-ui);
    }
  }

  .latest-quarter__note .latest-quarter__guide {
    color: var(--color-ink);
    font-family: var(--font-prose);
    font-size: var(--text-prose);
    line-height: var(--leading-prose);
  }

  .latest-quarter__note .latest-quarter__source {
    color: var(--color-ink-muted);
    font-size: var(--text-meta);
    line-height: var(--leading-meta);
  }

  .latest-quarter__next {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--space-xs) var(--space-lg);
    margin-block-start: var(--space-lg);
    padding-block-start: var(--space-sm);
    border-block-start: var(--rule-hairline);
    font-size: var(--text-ui-sm);
  }

  .latest-quarter__next-date {
    margin: 0;
    color: var(--color-ink-soft);
  }
}
