/* Metra Hub: the Reports tab, and how a report prints. Loaded after style.css and hub.css.

   A report is drawn once (reports-view.js) and coloured twice: with the
   page's own tokens on screen, and with the iPhone app's paper colours
   (`ReportStyle` in ReportBlocks.swift) in print. Every colour a report uses
   is one of the --rp-* properties below. Mint stays the only accent on
   screen; the right leg has its own colour, as everywhere in the app. */

/* -------------------------------------------------------------- layout */

.rp-cols { display: grid; grid-template-columns: minmax(0, 1fr); gap: 24px; align-items: start; }
.rp-side { display: flex; flex-direction: column; gap: 22px; min-width: 0; }
.rp-side .section-label { margin: 0 4px; }
.rp-side .footnote { padding: 0 4px; }
.rp-main { min-width: 0; }
.rp-main:focus { outline: none; }
.rp-scope { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 30px; }
.rp-side .row-value { max-width: 68%; }
.rp-side .srow { font: inherit; font-size: 15px; }
.rp-side .srow:disabled, .rp-side .row:disabled { opacity: .45; }
.rp-side button.srow:disabled:hover { background: none; }
.rp-disc { flex: none; width: 34px; height: 34px; border-radius: 50%; background: rgba(111, 216, 192, .14); color: var(--mint); display: flex; align-items: center; justify-content: center; }
.rp-report-card { display: flex; flex-direction: column; gap: 12px; padding: 14px 16px; }
.rp-report-what { display: flex; flex-direction: column; gap: 3px; }
.rp-report-what strong { font-size: 17px; font-weight: 600; }
.rp-report-card .primary.compact { align-self: flex-start; }
.rp-inner-rows { margin: 0 -16px; border-top: 1px solid var(--hair); }
.rp-inner-rows:last-child { margin-bottom: -14px; }
.rp-switch-row { margin: 0 -16px -14px; padding: 7px 16px; border-top: 1px solid var(--hair); cursor: pointer; }
.rp-inner-rows + .rp-switch-row { margin-top: -12px; }
.rp-contents { overflow: hidden; margin-top: 12px; }
.rp-contents-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; padding: 0 16px; background: var(--sub); }
.rp-contents-head h3 { font-size: 14px; font-weight: 600; }
.rp-contents .check-list { padding: 0 16px; }
.rp-more { margin-top: 14px; }

@media (min-width: 1100px) {
  .rp-cols { grid-template-columns: 360px minmax(0, 1fr); gap: 32px; }
  .rp-side { position: sticky; top: calc(var(--top) + 16px); max-height: calc(100vh - var(--top) - 32px); overflow: auto; overscroll-behavior: contain; padding-bottom: 4px; scrollbar-width: thin; }
}

/* -------------------------------------------------------------- report */

.rp-doc {
  --rp-ink: var(--ink);
  --rp-grey: var(--i60);
  --rp-faint: var(--i45);
  --rp-rule: var(--rule);
  --rp-strong-rule: var(--rule2);
  --rp-accent: var(--mint);
  --rp-tint: rgba(111, 216, 192, .08);
  --rp-right: var(--leg-r);
  --rp-bar: rgba(244, 244, 243, .22);
  --rp-paper: var(--surface);
  max-width: 900px;
  padding: 28px 32px 22px;
  border-radius: 16px;
  border: 1px solid var(--hair);
  background: var(--rp-paper);
  color: var(--rp-ink);
  font-size: 14px;
  line-height: 1.4;
}

.rp-brand { display: flex; align-items: center; gap: 8px; min-height: 24px; }
.rp-mark { width: 22px; height: 22px; display: block; flex: none; }
.rp-brand-name { font-size: 13px; font-weight: 600; }
.rp-brand .rp-kicker { margin-left: auto; text-align: right; }
.rp-kicker { margin: 0; font-size: 11px; font-weight: 600; letter-spacing: 1.2px; text-transform: uppercase; color: var(--rp-accent); }
.rp-kicker.quiet { color: var(--rp-grey); }
.rp-title { margin-top: 18px; font-size: 32px; font-weight: 700; letter-spacing: -.02em; line-height: 1.12; overflow-wrap: anywhere; }
.rp-title:focus { outline: none; }
.rp-sub { margin-top: 6px; padding-bottom: 16px; border-bottom: 1px solid var(--rp-rule); font-size: 14px; color: var(--rp-grey); }
.rp-note { margin-top: 10px; font-size: 13.5px; font-style: italic; color: var(--rp-grey); overflow-wrap: anywhere; }

.rp-highlights { margin-top: 18px; padding: 14px 18px 10px; border-radius: 12px; background: var(--rp-tint); }
.rp-highlights ul { list-style: none; margin: 9px 0 0; padding: 0; }
.rp-highlights li { position: relative; padding: 0 0 7px 15px; font-size: 14px; line-height: 1.42; }
.rp-highlights li::before { content: ""; position: absolute; left: 0; top: .58em; width: 5px; height: 5px; border-radius: 50%; background: var(--rp-accent); }

.rp-sec-head, .rp-sub-head { display: flex; align-items: baseline; justify-content: space-between; gap: 6px 16px; flex-wrap: wrap; }
.rp-sec-head { margin-top: 26px; padding-bottom: 6px; }
.rp-sec-head h3 { font-size: 17px; font-weight: 600; letter-spacing: -.01em; }
.rp-sub-head { margin-top: 18px; padding-bottom: 3px; }
.rp-sub-head h4 { margin: 0; font-size: 14px; font-weight: 600; }
.rp-meta { font-size: 12.5px; color: var(--rp-grey); }

.rp-table-wrap { overflow-x: auto; }
.rp-table-wrap:focus-visible { outline-offset: 2px; border-radius: 4px; }
.rp-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.rp-table th, .rp-table td { padding: 0 0 0 16px; height: 34px; white-space: nowrap; font-size: 14px; font-weight: 400; border-bottom: 1px solid var(--rp-rule); }
.rp-table th:first-child, .rp-table td:first-child { padding-left: 0; }
.rp-table thead th { height: 28px; vertical-align: bottom; padding-bottom: 6px; font-size: 10.5px; font-weight: 600; letter-spacing: .9px; text-transform: uppercase; color: var(--rp-grey); border-bottom: 1px solid var(--rp-strong-rule); }
.rp-l { text-align: left; }
.rp-r { text-align: right; }
.rp-table tbody th { color: var(--rp-ink); }
.rp-cell { display: inline-flex; align-items: baseline; gap: 5px; }
.rp-cell strong { font-weight: 700; }
.rp-small { font-size: 11.5px; color: var(--rp-faint); }
.rp-dash { color: var(--rp-faint); }
.rp-pb { align-self: center; padding: 1px 4px; border-radius: 4px; box-shadow: inset 0 0 0 1px var(--rp-accent); font-size: 9px; font-weight: 700; letter-spacing: .6px; line-height: 1.3; color: var(--rp-accent); }
.rp-total th, .rp-total td { border-top: 1px solid var(--rp-strong-rule); border-bottom: 0; font-weight: 600; }

.rp-caption { margin-top: 8px; font-size: 12px; line-height: 1.45; color: var(--rp-faint); }

.rp-charts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; margin-top: 16px; }
.rp-figure { margin: 0; min-width: 0; }
.rp-chart-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.rp-chart-title { font-size: 10.5px; font-weight: 600; letter-spacing: .9px; text-transform: uppercase; color: var(--rp-grey); }
.rp-legend { display: flex; gap: 12px; font-size: 11.5px; color: var(--rp-grey); white-space: nowrap; }
.rp-legend-item { display: inline-flex; align-items: center; gap: 5px; }
.rp-legend-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--rp-accent); }
.rp-legend-dot.s1 { background: var(--rp-right); }
.rp-chart, .rp-bars { display: block; width: 100%; height: auto; overflow: visible; }
.rp-chart text, .rp-bars text { font-family: var(--font); }
.rp-axis { font-size: 7px; fill: var(--rp-faint); font-variant-numeric: tabular-nums; }
.rp-grid { stroke: var(--rp-rule); stroke-width: .5; }
.rp-line { fill: none; stroke: var(--rp-accent); stroke-width: 1.3; stroke-linecap: round; stroke-linejoin: round; }
.rp-line.s1 { stroke: var(--rp-right); }
.rp-dot { fill: var(--rp-paper); stroke: var(--rp-accent); stroke-width: 1; }
.rp-dot.s1 { stroke: var(--rp-right); }
.rp-dot.last { fill: var(--rp-accent); }
.rp-dot.s1.last { fill: var(--rp-right); }

.rp-bars-wrap { margin: 10px 0 6px; max-width: 760px; }
.rp-bar { fill: var(--rp-bar); }
.rp-bar.best { fill: var(--rp-accent); }
.rp-bar.leg-l { fill: var(--rp-accent); fill-opacity: .32; }
.rp-bar.leg-r { fill: var(--rp-right); fill-opacity: .32; }
.rp-bar.leg-l.best, .rp-bar.leg-r.best { fill-opacity: 1; }
.rp-bar-value { font-size: 7px; font-weight: 600; fill: var(--rp-ink); font-variant-numeric: tabular-nums; }
.rp-avg { stroke: var(--rp-ink); stroke-width: .6; stroke-dasharray: 2.5 2.5; }
.rp-avg-label { font-size: 7.5px; fill: var(--rp-grey); }

.rp-defs { margin-top: 30px; }
.rp-defs dl { margin: 6px 0 0; }
.rp-defs dl > div { margin-top: 4px; font-size: 12.5px; line-height: 1.45; color: var(--rp-grey); }
.rp-defs dt, .rp-defs dd { display: inline; margin: 0; }
.rp-defs dt { font-weight: 600; color: var(--rp-ink); }
.rp-defs-more { margin-top: 6px; font-size: 12.5px; color: var(--rp-grey); }

.rp-foot { display: flex; justify-content: space-between; gap: 6px 16px; flex-wrap: wrap; margin-top: 28px; padding-top: 10px; border-top: 1px solid var(--rp-rule); font-size: 11.5px; color: var(--rp-faint); }

/* `screen`: a printed page is narrower than this too, and is not a phone. */
@media screen and (max-width: 859px) {
  .rp-doc { padding: 20px 16px 16px; margin: 0 -6px; }
  .rp-title { font-size: 26px; }
  .rp-charts { grid-template-columns: minmax(0, 1fr); gap: 18px; }
  .rp-table th, .rp-table td { padding-left: 12px; }
  .rp-brand { flex-wrap: wrap; }
}

/* --------------------------------------------------------------- print */

/* "Save as PDF" is this browser's print window. Only the report prints, on
   white paper with dark ink, on whatever paper is chosen there (A4 or
   Letter). The page number goes in the margin where the browser can put it. */

@page {
  margin: 14mm 15.5mm 16mm;
  @bottom-right {
    content: counter(page) " / " counter(pages);
    font: 7.5pt -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: #9A9DA1;
  }
}

@media print {
  /* Scoped to the Reports tab (`:has`): printing another tab is left as it was. */
  html:has(.rp-screen), html:has(.rp-screen) body { background: #fff !important; color-scheme: light; }
  body:has(.rp-screen) { min-height: 0; padding: 0 !important; color: #0E0F10; }
  body:has(.rp-screen) > :not(main), body:has(.rp-screen) .hub-invites, .rp-noprint { display: none !important; }
  .rp-screen { display: block; max-width: none; margin: 0; padding: 0; }
  .rp-cols { display: block; }
  .rp-main > .empty, .rp-main > .state { color: #6A6D72; }

  .rp-doc {
    --rp-ink: #0E0F10;
    --rp-grey: #6A6D72;
    --rp-faint: #9A9DA1;
    --rp-rule: #E4E5E1;
    --rp-strong-rule: #0E0F10;
    --rp-accent: #0C8570;
    --rp-tint: #EFF7F4;
    --rp-right: #4470D6;
    --rp-bar: #CFE3DD;
    --rp-paper: #fff;
    max-width: none; margin: 0; padding: 0; border: 0; border-radius: 0; background: none;
    font-size: 9pt; line-height: 1.35;
    -webkit-print-color-adjust: exact; print-color-adjust: exact;
  }
  .rp-brand { min-height: 18pt; gap: 6pt; }
  .rp-mark { width: 17pt; height: 17pt; }
  .rp-brand-name { font-size: 9pt; }
  .rp-kicker { font-size: 7.5pt; letter-spacing: 1.1pt; }
  .rp-title { margin-top: 14pt; font-size: 24pt; letter-spacing: -.4pt; }
  .rp-sub { margin-top: 4pt; padding-bottom: 13pt; border-bottom-width: .75pt; font-size: 10pt; }
  .rp-note { margin-top: 8pt; font-size: 9pt; }
  .rp-highlights { margin-top: 14pt; padding: 11pt 13pt 6pt; border-radius: 8pt; break-inside: avoid; }
  .rp-highlights ul { margin-top: 7pt; }
  .rp-highlights li { padding: 0 0 5pt 11pt; font-size: 9.5pt; line-height: 1.35; }
  .rp-highlights li::before { width: 4pt; height: 4pt; }

  .rp-sec-head { margin-top: 18pt; padding-bottom: 5pt; }
  .rp-sec-head h3 { font-size: 12pt; letter-spacing: -.15pt; }
  .rp-sub-head { margin-top: 12pt; padding-bottom: 3pt; }
  .rp-sub-head h4 { font-size: 9.5pt; }
  .rp-meta { font-size: 8.5pt; }
  .rp-sub-head .rp-meta { font-size: 8pt; }

  .rp-table-wrap { overflow: visible; }
  .rp-table th, .rp-table td { height: 17pt; padding-left: 8pt; font-size: 9pt; border-bottom-width: .5pt; }
  .rp-table thead th { height: 17pt; padding-bottom: 3pt; font-size: 6.8pt; letter-spacing: .7pt; border-bottom-width: .75pt; }
  .rp-total th, .rp-total td { border-top-width: .75pt; }
  .rp-small { font-size: 7.5pt; }
  .rp-pb { padding: .6pt 2.4pt; border-radius: 2.5pt; font-size: 6pt; letter-spacing: .5pt; box-shadow: inset 0 0 0 .6pt var(--rp-accent); }
  .rp-caption { margin-top: 5pt; font-size: 7.5pt; }
  .rp-charts { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16pt; margin-top: 10pt; }
  .rp-chart-title { font-size: 6.8pt; letter-spacing: .7pt; }
  .rp-legend { font-size: 7pt; }
  .rp-bars-wrap { margin: 8pt 0 4pt; max-width: none; }
  .rp-defs { margin-top: 20pt; }
  .rp-defs dl > div, .rp-defs-more { margin-top: 3pt; font-size: 8pt; }
  .rp-foot { margin-top: 18pt; padding-top: 7pt; border-top-width: .75pt; font-size: 7.5pt; }

  /* What stays together (the app's own rules, `ReportDocument.table` and the
     glue between blocks): a heading with what follows it, a short table, a
     table's first two rows and its last, a pair of rows, a chart with its
     table, a caption with what it explains. */
  .rp-head, .rp-sec-head, .rp-sub-head.glue, .rp-table thead { break-after: avoid; }
  .rp-sub-head { break-after: avoid; }
  .rp-sub-head.glue, .rp-table-wrap, .rp-charts, .rp-bars-wrap, .rp-caption { break-before: avoid; }
  .rp-sub-head:not(.glue) { break-before: auto; }
  .rp-table thead { display: table-header-group; }
  .rp-table tr, .rp-keep, .rp-figure, .rp-bars-wrap, .rp-defs, .rp-foot { break-inside: avoid; }
  .rp-foot { break-before: avoid; }
}
