/* =============================================================================
   Settlement preview — the method pages (LC-205, temporary)

   Step by step, pro rata, per kWh and the comparison of all of them, under the Settlement Preview tab.
   One stylesheet rather than a <style> block per page: a component's style block is not scoped, and
   these pages share every piece below.

   The idea the pages are built on: a calculation is read left to right, like a spreadsheet. Each
   column is one step, its formula is written under its heading, and the bars inside the cells are the
   same numbers drawn, so the picture and the figure can never disagree.

   Two colours carry one meaning each, everywhere on these pages:
     --looc-meter-draw      the meter above zero: the site draws from the grid, energy tax is due
     --looc-meter-deliver   the meter below zero: the site delivers to the grid, feed-in costs are due
   Money is green in the customer's favour and red against them, as on the preview's charts, and is
   never told apart by colour alone: every amount carries its sign. Green and red mean nothing else on
   these pages. What Looc steers is marked in the ink colour, not in the brand green: the amount the
   settlement is about is often a cost, and a cost in a green frame says two things at once.

   Goes when the customer has chosen a method, together with the pages.
   ============================================================================= */

.settlement-method {
  display: flex;
  flex-direction: column;
  gap: var(--looc-space-4);
}

/* The classes the method pages share with the preview's own charts. The preview declares them in its
   <style> block, which only exists once that page has rendered, so they are repeated here under this
   wrapper for the pages that are opened without it. */
.settlement-method .settlement-preview__figure {
  font-variant-numeric: tabular-nums;
}

.settlement-method .settlement-preview__horizon-chart {
  height: 280px;
  width: 100%;
}

.settlement-method .settlement-preview__horizon-legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--looc-space-1) var(--looc-space-4);
  margin: 0 0 var(--looc-space-2);
  padding: 0;
  list-style: none;
  font-size: 0.8125rem;
  color: var(--rz-text-secondary-color);
}

.settlement-method .settlement-preview__year-to-date-toggle {
  display: flex;
  align-items: center;
  gap: var(--looc-space-2);
}

.settlement-method .settlement-preview__horizon-legend > li {
  display: flex;
  align-items: center;
  gap: var(--looc-space-1);
}

.settlement-method .settlement-preview__horizon-swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
}

.settlement-method .settlement-preview__horizon-swatch--gain {
  background: var(--looc-green);
}

.settlement-method .settlement-preview__horizon-swatch--loss {
  background: var(--looc-red);
}

.settlement-method .settlement-preview__horizon-swatch--total {
  width: 16px;
  height: 2px;
  border-radius: 0;
  background: var(--looc-chart-running-total);
}

/* -----------------------------------------------------------------------------
   The bar on top: which method, which moment, which period.
   ----------------------------------------------------------------------------- */
.settlement-toolbar {
  display: flex;
  flex-direction: column;
  gap: var(--looc-space-3);
  padding: var(--looc-space-3) var(--looc-space-4);
  background: var(--rz-base-background-color);
  border: 1px solid var(--looc-border-color);
  border-radius: var(--looc-radius-md);
}

.settlement-toolbar__row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--looc-space-2) var(--looc-space-6);
}

.settlement-toolbar__row + .settlement-toolbar__row {
  padding-top: var(--looc-space-3);
  border-top: 1px solid var(--looc-border-color);
}

.settlement-toolbar__field {
  display: flex;
  align-items: center;
  gap: var(--looc-space-2);
}

/* The method picker: one segmented strip, and under it what the chosen method does in one line. */
.settlement-methods {
  display: flex;
  flex-direction: column;
  gap: var(--looc-space-2);
  min-width: 0;
}

.settlement-segments {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 2px;
  padding: 3px;
  background: var(--rz-base-100);
  border: 1px solid var(--looc-border-color);
  border-radius: 10px;
  max-width: 100%;
}

.settlement-segment {
  display: inline-flex;
  align-items: center;
  gap: var(--looc-space-2);
  padding: 0.375rem 0.875rem;
  background: none;
  border: 0;
  border-radius: 7px;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--rz-text-secondary-color);
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.18s var(--ease-out-quart), color 0.18s var(--ease-out-quart);
}

.settlement-segment .rzi {
  font-size: 1.125rem;
}

.settlement-segment:hover {
  color: var(--rz-text-color);
  background: var(--rz-base-200);
}

.settlement-segment.is-active {
  color: var(--rz-text-color);
  background: var(--rz-base-background-color);
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.1), 0 0 0 1px var(--looc-border-color);
}

.settlement-segment.is-active .rzi {
  color: var(--rz-primary-dark);
}

/* LC-207: the fees are not one of the three questions the bar asks, so they keep to the far end: the
   switch last, and the two rates before it once the fees are on. */
.settlement-toolbar__fees {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--looc-space-2) var(--looc-space-6);
  margin-left: auto;
}

/* Not a method but all of them beside each other, so it stands a little apart. */
.settlement-segment--compare {
  margin-left: var(--looc-space-2);
}

.settlement-methods__idea {
  margin: 0;
  font-size: 0.9375rem;
  color: var(--rz-text-color);
}

/* -----------------------------------------------------------------------------
   The three prices of a quarter hour, as the cells a spreadsheet would call its inputs.
   ----------------------------------------------------------------------------- */
.settlement-rates {
  display: flex;
  flex-wrap: wrap;
  gap: var(--looc-space-2);
  align-items: stretch;
}

.settlement-rate {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 170px;
  /* A cap, so a rate with a line about the method wraps inside its card and the three stay side by side. */
  max-width: 16.5rem;
  padding: var(--looc-space-2) var(--looc-space-3);
  background: var(--rz-base-background-color);
  border: 1px solid var(--looc-border-color);
  border-radius: var(--looc-radius-md);
}

.settlement-rate__label {
  display: flex;
  align-items: center;
  gap: var(--looc-space-2);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--rz-text-secondary-color);
}

.settlement-rate__value {
  font-size: 1.125rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--rz-text-color);
}

.settlement-rate__value small {
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--rz-text-secondary-color);
}

.settlement-rate__when {
  font-size: 0.75rem;
  color: var(--rz-text-secondary-color);
}

.settlement-rate__method {
  font-size: 0.75rem;
  font-style: italic;
  color: var(--rz-text-secondary-color);
}

/* The rate the meter is charged at in this quarter hour. */
.settlement-rate.is-charged--draw {
  background: var(--looc-meter-draw-tint);
  border-color: var(--looc-meter-draw);
}

.settlement-rate.is-charged--deliver {
  background: var(--looc-meter-deliver-tint);
  border-color: var(--looc-meter-deliver);
}

.settlement-rate.is-charged--draw .settlement-rate__when,
.settlement-rate.is-charged--deliver .settlement-rate__when {
  font-weight: 600;
  color: var(--rz-text-color);
}

/* The dot that ties a rate, a zone of the meter and a column together. */
.settlement-dot {
  display: inline-block;
  flex: none;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--rz-base-400);
}

.settlement-dot--draw {
  background: var(--looc-meter-draw);
}

.settlement-dot--deliver {
  background: var(--looc-meter-deliver);
}

.settlement-dot--gain {
  background: var(--looc-green);
}

.settlement-dot--cost {
  background: var(--rz-danger);
}

.settlement-dot--energy {
  border-radius: 2px;
  background: var(--rz-text-secondary-color);
}

/* -----------------------------------------------------------------------------
   A card of the page: a heading, optionally something beside it, and the content.
   ----------------------------------------------------------------------------- */
.settlement-panel {
  padding: var(--looc-space-4);
  background: var(--rz-base-background-color);
  border: 1px solid var(--looc-border-color);
  border-radius: var(--looc-radius-md);
  box-shadow: var(--rz-card-shadow);
}

.settlement-panel__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--looc-space-2) var(--looc-space-4);
  margin-bottom: var(--looc-space-3);
}

.settlement-panel__title {
  margin: 0;
  font-size: 1.0625rem;
  font-weight: 600;
  color: var(--rz-text-color);
}

.settlement-panel__subtitle {
  margin: 0;
  font-size: 0.875rem;
  color: var(--rz-text-secondary-color);
}

.settlement-panel__section {
  margin-top: var(--looc-space-6);
}

/* What the colours mean, once per card rather than once per bar. */
.settlement-legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--looc-space-1) var(--looc-space-4);
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 0.8125rem;
  color: var(--rz-text-secondary-color);
}

.settlement-legend > li {
  display: flex;
  align-items: center;
  gap: var(--looc-space-2);
}

/* -----------------------------------------------------------------------------
   The equation: what the table adds up to, in the fewest boxes that say it.
   ----------------------------------------------------------------------------- */
.settlement-equation {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: var(--looc-space-2);
  margin: 0 0 var(--looc-space-4);
}

.settlement-equation__operator {
  display: flex;
  align-items: center;
  font-size: 1.5rem;
  font-weight: 300;
  color: var(--rz-text-secondary-color);
}

.settlement-equation__term {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  min-width: 150px;
  padding: var(--looc-space-2) var(--looc-space-4);
  background: var(--rz-base-50);
  border: 1px solid var(--looc-border-color);
  border-radius: var(--looc-radius-md);
}

.settlement-equation__label {
  display: flex;
  align-items: center;
  gap: var(--looc-space-2);
  font-size: 0.8125rem;
  color: var(--rz-text-secondary-color);
}

.settlement-equation__value {
  font-size: 1.375rem;
  font-weight: 600;
  line-height: 1.2;
  color: var(--rz-text-color);
}

.settlement-equation__note {
  font-size: 0.8125rem;
  color: var(--rz-text-secondary-color);
}

/* The term the settlement is about: what Looc's steered equipment came to. A heavier frame in the ink
   colour marks it as the one to look at; the wash behind it is the amount's own colour, green in the
   customer's favour and red against them. */
.settlement-equation__term--looc {
  background: var(--rz-base-background-color);
  border: 2px solid var(--rz-text-color);
}

.settlement-equation__term--looc.is-gain {
  background: var(--rz-success-lighter);
}

.settlement-equation__term--looc.is-cost {
  background: var(--rz-danger-lighter);
}

.settlement-equation__term--looc .settlement-equation__label {
  color: var(--rz-text-color);
  font-weight: 600;
}

.settlement-equation__term--total {
  background: var(--rz-base-background-color);
  border-color: var(--rz-text-color);
}

.settlement-equation__note--gain {
  color: var(--rz-primary-darker);
  font-weight: 600;
}

.settlement-equation__note--cost {
  color: var(--rz-on-danger-lighter);
  font-weight: 600;
}

/* -----------------------------------------------------------------------------
   The sheet: a calculation laid out as a spreadsheet.

   Grid lines both ways, a row of step names over the columns, a row of formulas under them and a
   total under a rule. Figures are flush right in tabular numerals so a column can be added up by eye.
   ----------------------------------------------------------------------------- */
.settlement-sheet-scroll {
  overflow-x: auto;
  border: 1px solid var(--looc-border-color);
  border-radius: var(--looc-radius-md);
}

.settlement-sheet {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.875rem;
  font-variant-numeric: tabular-nums;
  color: var(--rz-text-color);
}

.settlement-sheet th,
.settlement-sheet td {
  padding: 0.4375rem 0.5rem;
  border-bottom: 1px solid var(--looc-border-color);
  border-right: 1px solid var(--looc-border-color);
  text-align: right;
  vertical-align: middle;
  white-space: nowrap;
}

.settlement-sheet th:last-child,
.settlement-sheet td:last-child {
  border-right: 0;
}

.settlement-sheet tfoot tr:last-child td,
.settlement-sheet:not(:has(tfoot)) tbody tr:last-child td {
  border-bottom: 0;
}

.settlement-sheet th.settlement-sheet__text,
.settlement-sheet td.settlement-sheet__text {
  text-align: left;
}

/* The row that names the steps. */
.settlement-sheet__steps th {
  padding-top: var(--looc-space-2);
  padding-bottom: var(--looc-space-2);
  background: var(--rz-base-50);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  text-align: left;
  color: var(--rz-text-secondary-color);
}

.settlement-step {
  display: inline-flex;
  align-items: center;
  gap: var(--looc-space-2);
}

.settlement-step__number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 50%;
  background: var(--rz-text-color);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0;
  color: var(--rz-base-background-color);
}

.settlement-sheet__columns th {
  background: var(--rz-base-background-color);
  font-weight: 600;
  color: var(--rz-text-color);
}

.settlement-sheet__heading {
  display: inline-flex;
  align-items: center;
  gap: var(--looc-space-2);
}

/* The formula row. Set like a spreadsheet's formula bar: quieter than the figures, and never bold. */
.settlement-sheet__formulas th {
  padding-top: 0.25rem;
  padding-bottom: 0.25rem;
  background: var(--rz-base-50);
  font-size: 0.75rem;
  font-weight: 400;
  font-style: italic;
  line-height: 1.3;
  color: var(--rz-text-secondary-color);
  white-space: normal;
  vertical-align: top;
}

.settlement-sheet tbody tr:hover td {
  background: var(--rz-base-50);
}

/* A row for something that is not a device: the connection, or the gap to the bill. */
.settlement-sheet__row--apart td {
  background: var(--rz-base-50);
  font-style: italic;
}

.settlement-sheet tfoot td {
  background: var(--rz-base-background-color);
  font-weight: 600;
}

/* The rule above a total, as an accountant draws it. The second selector is a total kept in the body
   of its table, where the row above it is one of the things it is the difference of. */
.settlement-sheet tfoot tr:first-child td,
.settlement-sheet tbody tr.settlement-preview__total-row td {
  border-top: 2px solid var(--rz-text-color);
}

.settlement-sheet tbody tr.settlement-preview__total-row td {
  font-weight: 600;
}

.settlement-sheet tbody tr.settlement-sheet__looc-total:hover td {
  background: var(--looc-grid-frame-tint);
}

.settlement-sheet tfoot .settlement-sheet__looc-total td,
.settlement-sheet tbody .settlement-sheet__looc-total td,
.settlement-sheet td.settlement-sheet__looc-cell,
.settlement-sheet th.settlement-sheet__looc-cell {
  background: var(--looc-grid-frame-tint);
}

/* A hovered row must not wash the Looc tint out: it is the one column the comparison is read by. */
.settlement-sheet tbody tr:hover td.settlement-sheet__looc-cell {
  background: var(--looc-grid-frame-tint);
}

/* LC-207: Looc's fee is an addition to the settlement, not a part of it, so its columns are set off
   by a dashed rule rather than tinted like the Looc column. */
.settlement-sheet td.settlement-sheet__fee-cell,
.settlement-sheet th.settlement-sheet__fee-cell {
  border-left: 1px dashed var(--looc-border-color);
}

.settlement-sheet__muted {
  color: var(--rz-text-secondary-color);
}

.settlement-sheet__strong {
  font-weight: 600;
}

/* A step number in the first column of the step-by-step sheet. */
.settlement-sheet__index {
  width: 1%;
  text-align: center !important;
  color: var(--rz-text-secondary-color);
}

/* A figure with its bar: the bar takes whatever the column has left, the figure keeps its width so
   the figures of a column still line up. */
.settlement-cell {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--looc-space-3);
}

.settlement-cell__figure {
  flex: none;
  min-width: 4.25rem;
  text-align: right;
}

.settlement-cell__figure--wide {
  min-width: 5.75rem;
}

/* The device in the first column: what it is called, what it is, and whether Looc steers it. */
.settlement-device {
  display: flex;
  align-items: center;
  gap: var(--looc-space-3);
  min-width: 0;
}

.settlement-device__icon {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: var(--looc-radius-md);
  background: var(--rz-base-100);
  color: var(--rz-text-secondary-color);
}

.settlement-device__icon .rzi {
  font-size: 1.125rem;
}

.settlement-device__icon--steered {
  background: var(--rz-text-color);
  color: var(--rz-base-background-color);
}

.settlement-device__text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.25;
}

.settlement-device__name {
  display: flex;
  align-items: center;
  gap: var(--looc-space-2);
  font-weight: 600;
}

.settlement-device__type {
  font-size: 0.75rem;
  color: var(--rz-text-secondary-color);
}

.settlement-pill {
  display: inline-flex;
  align-items: center;
  padding: 0 0.4375rem;
  border-radius: 999px;
  background: var(--rz-base-100);
  font-size: 0.6875rem;
  font-weight: 600;
  line-height: 1.5;
  color: var(--rz-text-secondary-color);
  white-space: nowrap;
}

.settlement-pill--looc {
  background: var(--rz-text-color);
  color: var(--rz-base-background-color);
}

/* -----------------------------------------------------------------------------
   Bars inside cells. One track per cell, a hairline where zero is, and the bar growing out of it.
   ----------------------------------------------------------------------------- */
.settlement-bar {
  position: relative;
  flex: 1 1 auto;
  display: block;
  min-width: 48px;
  height: 18px;
}

/* The zero line, drawn over the whole height of the cell so the rows share one axis. */
.settlement-bar::before {
  content: "";
  position: absolute;
  top: -6px;
  bottom: -6px;
  left: var(--settlement-bar-zero, 50%);
  width: 1px;
  background: var(--rz-base-400);
}

.settlement-bar__fill {
  position: absolute;
  top: 5px;
  height: 8px;
  min-width: 2px;
  background: var(--rz-text-secondary-color);
}

.settlement-bar__fill--positive {
  border-radius: 0 3px 3px 0;
}

.settlement-bar__fill--negative {
  border-radius: 3px 0 0 3px;
}

.settlement-bar__fill--gain {
  background: var(--looc-green);
}

.settlement-bar__fill--cost {
  background: var(--rz-danger);
}

/* The meter in the step-by-step sheet: the two zones either side of zero as a wash, and the device's
   move drawn over them. The part of a move above zero is what changes the energy tax, the part below
   it what changes the feed-in costs, so a device that crosses zero shows both in one bar. */
.settlement-meter {
  position: relative;
  display: block;
  min-width: 180px;
  height: 22px;
}

.settlement-meter__zone {
  position: absolute;
  top: -7px;
  bottom: -7px;
}

.settlement-meter__zone--deliver {
  left: 0;
  width: var(--settlement-bar-zero, 50%);
  background: var(--looc-meter-deliver-tint);
}

.settlement-meter__zone--draw {
  left: var(--settlement-bar-zero, 50%);
  right: 0;
  background: var(--looc-meter-draw-tint);
}

.settlement-meter__zero {
  position: absolute;
  top: -7px;
  bottom: -7px;
  left: var(--settlement-bar-zero, 50%);
  width: 1px;
  background: var(--rz-text-secondary-color);
}

.settlement-meter__move {
  position: absolute;
  top: 7px;
  height: 8px;
}

.settlement-meter__move--draw {
  background: var(--looc-meter-draw);
}

.settlement-meter__move--deliver {
  background: var(--looc-meter-deliver);
}

/* Where the meter stands after this device, and which way it got there. An arrowhead drawn the usual
   way: a box of no size whose one coloured border is the triangle. */
.settlement-meter__head {
  position: absolute;
  top: 3px;
  width: 0;
  height: 0;
  border-top: 8px solid transparent;
  border-bottom: 8px solid transparent;
}

.settlement-meter__head--up {
  border-left: 9px solid var(--rz-text-color);
  transform: translateX(-2px);
}

.settlement-meter__head--down {
  border-right: 9px solid var(--rz-text-color);
  transform: translateX(-7px);
}

.settlement-meter__head--still {
  top: 5px;
  width: 4px;
  height: 12px;
  border: 0;
  border-radius: 2px;
  background: var(--rz-text-color);
  transform: translateX(-2px);
}

/* The heading over the meter column: which side is which. */
.settlement-meter-axis {
  position: relative;
  display: block;
  min-width: 180px;
  height: 1.125rem;
  font-size: 0.6875rem;
  font-weight: 600;
  font-style: normal;
  color: var(--rz-text-secondary-color);
  overflow: hidden;
}

.settlement-meter-axis__side {
  position: absolute;
  top: 0;
  display: inline-flex;
  align-items: center;
  gap: var(--looc-space-1);
  white-space: nowrap;
}

.settlement-meter-axis__side--deliver {
  right: calc(100% - var(--settlement-bar-zero, 50%) + var(--looc-space-2));
}

.settlement-meter-axis__side--draw {
  left: calc(var(--settlement-bar-zero, 50%) + var(--looc-space-2));
}

/* A share of a whole: the pro rata method's own picture. */
.settlement-share {
  display: flex;
  width: 100%;
  height: 28px;
  gap: 2px;
}

.settlement-share__part {
  display: flex;
  align-items: center;
  min-width: 2px;
  padding: 0 var(--looc-space-2);
  overflow: hidden;
  border-radius: 4px;
  font-size: 0.8125rem;
  font-weight: 600;
  white-space: nowrap;
  /* Near-black on both colours: white on the brand blue or orange is under 3.5:1. */
  color: var(--rz-text-color);
}

.settlement-share--draw {
  --settlement-share-colour: var(--looc-meter-draw);
}

.settlement-share--deliver {
  --settlement-share-colour: var(--looc-meter-deliver);
}

.settlement-share__part {
  background: color-mix(in srgb, var(--settlement-share-colour) 70%, var(--rz-base-background-color));
}

/* Neighbouring parts are told apart by the gap and by a step in strength, not by a new colour: they
   are the same thing, shared. */
.settlement-share__part:nth-child(even) {
  background: color-mix(in srgb, var(--settlement-share-colour) 42%, var(--rz-base-background-color));
}

.settlement-share-caption {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--looc-space-1) var(--looc-space-4);
  margin-bottom: var(--looc-space-2);
  font-size: 0.875rem;
  color: var(--rz-text-secondary-color);
}

.settlement-share-caption strong {
  color: var(--rz-text-color);
}

/* -----------------------------------------------------------------------------
   The order devices are added in, on the step-by-step page.
   ----------------------------------------------------------------------------- */
.settlement-order {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

/* -----------------------------------------------------------------------------
   The comparison: one row per method, or one column per method.
   ----------------------------------------------------------------------------- */
.settlement-compare-method__link {
  padding: 0;
  background: none;
  border: 0;
  font: inherit;
  font-weight: 600;
  color: var(--rz-primary-darker);
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

.settlement-compare-method__link:hover {
  color: var(--rz-text-color);
}

.settlement-note {
  display: flex;
  align-items: center;
  gap: var(--looc-space-2);
  margin: var(--looc-space-3) 0 0;
  font-size: 0.8125rem;
  color: var(--rz-text-secondary-color);
}

.settlement-note .rzi {
  font-size: 1.125rem;
}

.settlement-note--ok .rzi {
  color: var(--rz-primary-dark);
}

@media (max-width: 1279.98px) {
  .settlement-meter,
  .settlement-meter-axis {
    min-width: 150px;
  }
}

/* What is on screen while newer figures are on their way: still there, so the page does not jump,
   and dimmed, so it is not read as the answer. */
.settlement-refresh {
  transition: opacity 0.15s var(--ease-out-quart);
}

.settlement-refresh.is-refreshing {
  opacity: 0.45;
  pointer-events: none;
}

/* A cell that holds a sentence rather than a figure: it wraps, where figures never do. */
.settlement-sheet td.settlement-sheet__wrap,
.settlement-sheet th.settlement-sheet__wrap {
  white-space: normal;
}

/* An amount with the working under it, as a spreadsheet user would check it: the price it was
   multiplied by. Small and quiet, so the column still reads as a column of amounts. */
.settlement-working {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-end;
  line-height: 1.25;
}

.settlement-working__how {
  font-size: 0.6875rem;
  color: var(--rz-text-secondary-color);
}

/* The order devices are added in, said on every period of the step-by-step page: it decides who
   gets what, and a day or a year added up in another order than the reader thinks is a wrong answer
   that looks like a right one. */
.settlement-order-strip {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--looc-space-2) var(--looc-space-3);
  padding: var(--looc-space-2) var(--looc-space-4);
  background: var(--rz-base-background-color);
  border: 1px solid var(--looc-border-color);
  border-radius: var(--looc-radius-md);
  font-size: 0.875rem;
}

.settlement-order-strip__label {
  color: var(--rz-text-secondary-color);
}

.settlement-order-strip__devices {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--looc-space-1) var(--looc-space-2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.settlement-order-strip__devices > li {
  display: flex;
  align-items: center;
  gap: var(--looc-space-2);
  font-weight: 600;
}

/* The arrow between two devices: decoration, the list is ordered without it. */
.settlement-order-strip__devices > li + li::before {
  content: "→";
  font-weight: 400;
  color: var(--rz-text-secondary-color);
}

.settlement-order-strip__state {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: var(--looc-space-3);
  color: var(--rz-text-secondary-color);
}

/* Sections of the with/without page a reader rarely needs, folded away under their own heading. */
.settlement-details > summary {
  cursor: pointer;
  list-style-position: inside;
}

.settlement-details > summary > * {
  display: inline-flex;
}

.settlement-details[open] > summary {
  margin-bottom: var(--looc-space-3);
}

/* -----------------------------------------------------------------------------
   LC-209: where a figure comes from. Every figure of a sheet can be selected as a cell is in a
   spreadsheet. The formula bar above the sheet shows its formula with the figures filled in, and the
   cells it refers to light up in the colour of their chip in the bar, as Excel colours the ranges of a
   formula. The figures that use the selected one get a dashed frame.

   The colours are drawn with a box-shadow and a pseudo-element rather than a background: the sheet's
   own row hover and the LOOC tint already set backgrounds, at higher specificity, and a reference must
   show through both.
   ----------------------------------------------------------------------------- */
.is-trace-ref--1,
.settlement-trace-chip--1 {
  --settlement-trace-colour: var(--looc-trace-1);
  --settlement-trace-tint: var(--looc-trace-1-tint);
}

.is-trace-ref--2,
.settlement-trace-chip--2 {
  --settlement-trace-colour: var(--looc-trace-2);
  --settlement-trace-tint: var(--looc-trace-2-tint);
}

.is-trace-ref--3,
.settlement-trace-chip--3 {
  --settlement-trace-colour: var(--looc-trace-3);
  --settlement-trace-tint: var(--looc-trace-3-tint);
}

.is-trace-ref--4,
.settlement-trace-chip--4 {
  --settlement-trace-colour: var(--looc-trace-4);
  --settlement-trace-tint: var(--looc-trace-4-tint);
}

.is-trace-ref--5,
.settlement-trace-chip--5 {
  --settlement-trace-colour: var(--looc-trace-5);
  --settlement-trace-tint: var(--looc-trace-5-tint);
}

/* A cell that can be selected: the button is the whole cell, so the padding moves onto it. */
.settlement-sheet td.settlement-trace-cell {
  position: relative;
  padding: 0;
}

.settlement-trace-cell__button {
  display: block;
  width: 100%;
  padding: 0.4375rem 0.5rem;
  background: none;
  border: 0;
  font: inherit;
  color: inherit;
  text-align: inherit;
  white-space: nowrap;
  cursor: cell;
}

/* The ring of a focused cell sits inside it, so the neighbours' grid lines do not cover it. */
.settlement-trace-cell__button:focus-visible {
  outline-offset: -3px;
}

.settlement-sheet td.settlement-trace-cell:hover {
  box-shadow: inset 0 0 0 1px var(--rz-base-400);
}

/* The tint of a reference, over the cell's own background, and the handle in its corner. The handle
   stays inside the cell: in the last column a pixel outside it scrolls the whole sheet sideways. */
.settlement-sheet td.settlement-trace-cell.is-trace-ref::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--settlement-trace-tint);
  pointer-events: none;
}

.settlement-sheet td.settlement-trace-cell.is-trace-ref::after,
.settlement-sheet td.settlement-trace-cell.is-trace-selected::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: 0;
  z-index: 1;
  width: 6px;
  height: 6px;
  border: 1px solid var(--rz-base-background-color);
  background: var(--settlement-trace-colour, var(--rz-text-color));
  pointer-events: none;
}

.settlement-sheet td.settlement-trace-cell.is-trace-ref {
  box-shadow: inset 0 0 0 2px var(--settlement-trace-colour);
}

/* The selected cell: a heavy frame in the ink colour, as the one cell a spreadsheet has active. */
.settlement-sheet td.settlement-trace-cell.is-trace-selected {
  box-shadow: inset 0 0 0 2px var(--rz-text-color);
}

/* A figure that is worked out from the selected one. */
.settlement-sheet td.settlement-trace-cell.is-trace-user {
  outline: 1.5px dashed var(--rz-text-secondary-color);
  outline-offset: -4px;
}

/* A figure outside a sheet that can be selected: a rate on its card, or a box of the sum. */
.settlement-trace-target {
  font: inherit;
  color: inherit;
  text-align: inherit;
  cursor: cell;
  transition: box-shadow 0.15s var(--ease-out-quart);
}

.settlement-trace-target:hover {
  box-shadow: 0 0 0 1px var(--rz-base-400);
}

.settlement-trace-target.is-trace-selected {
  box-shadow: 0 0 0 2px var(--rz-text-color);
}

.settlement-trace-target.is-trace-ref {
  box-shadow: 0 0 0 2px var(--settlement-trace-colour);
  background-color: var(--settlement-trace-tint);
}

.settlement-trace-target.is-trace-user {
  outline: 1.5px dashed var(--rz-text-secondary-color);
  outline-offset: 2px;
}

.settlement-rate__value.settlement-trace-target {
  align-self: flex-start;
  margin: 0 calc(-1 * var(--looc-space-1));
  padding: 0 var(--looc-space-1);
  background: none;
  border: 0;
  border-radius: var(--looc-radius-sm);
}

/* The rate the selected figure is charged at: its whole card takes the colour, not only the figure. */
.settlement-rate:has(.settlement-trace-target.is-trace-ref) {
  border-color: var(--settlement-trace-colour);
}

.settlement-rate:has(.is-trace-ref--1) { --settlement-trace-colour: var(--looc-trace-1); }
.settlement-rate:has(.is-trace-ref--2) { --settlement-trace-colour: var(--looc-trace-2); }
.settlement-rate:has(.is-trace-ref--3) { --settlement-trace-colour: var(--looc-trace-3); }
.settlement-rate:has(.is-trace-ref--4) { --settlement-trace-colour: var(--looc-trace-4); }
.settlement-rate:has(.is-trace-ref--5) { --settlement-trace-colour: var(--looc-trace-5); }

.settlement-equation__term.settlement-trace-target {
  text-align: left;
}

/* -----------------------------------------------------------------------------
   The formula bar. Stays at the top of the screen while the sheet under it scrolls.
   ----------------------------------------------------------------------------- */
/* The reseller layout's content area declares a scroll region of its own, but it grows with the page,
   so it never scrolls: the body around it does. A sticky element sticks to the nearest scroll region,
   though, whether it scrolls or not, so the bar would never stick. Only on a page with a formula bar
   is that region given back to the page, and the body it scrolls in is what the bar sticks to. */
.page-content--scroll:has(.settlement-formula-bar) {
  overflow: visible;
}

.settlement-formula-bar {
  position: sticky;
  top: 0;
  z-index: 4;
  margin: 0 0 var(--looc-space-3);
  background: var(--rz-base-background-color);
  border: 1px solid var(--rz-base-400);
  border-radius: var(--looc-radius-md);
  box-shadow: 0 4px 12px -6px color-mix(in srgb, var(--rz-text-color) 30%, transparent);
}

.settlement-formula-bar.is-empty {
  border-color: var(--looc-border-color);
  box-shadow: none;
}

.settlement-formula-bar__line {
  display: flex;
  align-items: stretch;
  min-height: 2.5rem;
}

/* The name box: which cell is selected. */
.settlement-formula-bar__name {
  flex: none;
  display: flex;
  align-items: center;
  width: 15rem;
  max-width: 30%;
  padding: 0 var(--looc-space-3);
  overflow: hidden;
  background: var(--rz-base-50);
  border-right: 1px solid var(--looc-border-color);
  border-radius: var(--looc-radius-md) 0 0 var(--looc-radius-md);
  font-size: 0.8125rem;
  font-weight: 600;
  white-space: nowrap;
  text-overflow: ellipsis;
  color: var(--rz-text-color);
}

.settlement-formula-bar.is-empty .settlement-formula-bar__name {
  font-weight: 400;
  color: var(--rz-text-secondary-color);
}

.settlement-formula-bar__fx {
  flex: none;
  display: flex;
  align-items: center;
  padding: 0 var(--looc-space-3);
  border-right: 1px solid var(--looc-border-color);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 0.9375rem;
  font-style: italic;
  font-weight: 600;
  color: var(--rz-text-secondary-color);
}

.settlement-formula-bar__formula {
  flex: 1 1 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--looc-space-1) 0.125rem;
  min-width: 0;
  padding: 0.375rem var(--looc-space-3);
  font-size: 0.9375rem;
  font-variant-numeric: tabular-nums;
  color: var(--rz-text-color);
}

.settlement-formula-bar__operator {
  padding: 0 0.25rem;
  font-weight: 600;
  color: var(--rz-text-secondary-color);
}

.settlement-formula-bar__text {
  white-space: pre-wrap;
}

.settlement-formula-bar__result {
  font-size: 1rem;
  font-weight: 700;
  white-space: nowrap;
}

.settlement-formula-bar__hint {
  font-size: 0.875rem;
  color: var(--rz-text-secondary-color);
}

.settlement-formula-bar__actions {
  flex: none;
  display: flex;
  align-items: center;
  gap: 0.125rem;
  padding: 0 var(--looc-space-1);
}

.settlement-formula-bar__detail {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  padding: var(--looc-space-2) var(--looc-space-3);
  border-top: 1px solid var(--looc-border-color);
  font-size: 0.8125rem;
  line-height: 1.45;
}

.settlement-formula-bar__explanation {
  margin: 0;
  max-width: 120ch;
  color: var(--rz-text-color);
}

.settlement-formula-bar__source {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: var(--looc-space-1) var(--looc-space-2);
  margin: 0;
  color: var(--rz-text-secondary-color);
}

.settlement-formula-bar__source-kind {
  display: inline-flex;
  align-items: center;
  gap: var(--looc-space-1);
  padding: 0 var(--looc-space-2);
  border-radius: 999px;
  background: var(--rz-base-100);
  font-weight: 600;
  white-space: nowrap;
  color: var(--rz-text-color);
}

.settlement-formula-bar__source-kind .rzi {
  font-size: 0.9375rem;
}

.settlement-formula-bar__used-in {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--looc-space-1);
}

.settlement-formula-bar__used-in-label {
  margin-right: var(--looc-space-1);
  font-weight: 600;
  color: var(--rz-text-secondary-color);
}

/* A reference in the formula: what it is, small and in its colour, and the figure that goes in. */
.settlement-trace-chip {
  display: inline-flex;
  align-items: baseline;
  gap: 0.375rem;
  padding: 0.0625rem 0.5rem;
  background: var(--settlement-trace-tint, transparent);
  border: 1.5px solid var(--settlement-trace-colour, var(--rz-base-400));
  border-radius: var(--looc-radius-sm);
  font: inherit;
  font-size: 0.8125rem;
  line-height: 1.5;
  white-space: nowrap;
  color: var(--rz-text-color);
}

button.settlement-trace-chip {
  cursor: pointer;
}

button.settlement-trace-chip:hover {
  background: color-mix(in srgb, var(--settlement-trace-colour, var(--rz-base-400)) 22%, var(--rz-base-background-color));
}

.settlement-trace-chip__label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--settlement-trace-colour, var(--rz-text-secondary-color));
}

.settlement-trace-chip__value {
  font-weight: 600;
}

/* A figure from outside the page, such as the price of a device's trades: nothing to go to. */
.settlement-trace-chip--plain {
  border-style: dotted;
  background: var(--rz-base-50);
}

/* A figure that uses the selected one, in the same dashes as its frame in the sheet. */
.settlement-trace-chip--user {
  border-style: dashed;
}

.settlement-trace-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--looc-space-1);
  margin-left: var(--looc-space-2);
  padding: 0 var(--looc-space-2);
  border-radius: 999px;
  background: var(--rz-base-100);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--rz-text-secondary-color);
}

.settlement-trace-badge .rzi {
  font-size: 0.875rem;
}

@media (max-width: 767.98px) {
  .settlement-formula-bar__line {
    flex-wrap: wrap;
  }

  .settlement-formula-bar__name {
    width: 100%;
    max-width: none;
    min-height: 2rem;
    border-right: 0;
    border-bottom: 1px solid var(--looc-border-color);
    border-radius: var(--looc-radius-md) var(--looc-radius-md) 0 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .settlement-trace-target {
    transition: none;
  }
}
