/* ===== REP GROWTH - has each rep's book of locations grown? ==================
   Counted in LOCATIONS, never in dollars. Prefix .rg-*.

   THE COLOURS ARE THE HOUSE'S AND NONE IS NEW.
     * ok / bad mean STATE here - a book that grew, a book that shrank - and each
       is always beside a word, a sign or an arrow, never alone.
     * --s1..--s4 encode the compared reps (a rep keeps its colour while it stays
       selected) and --s2 / --s4 the independent / consolidator split, each with
       a name beside it.
     * gold is chrome: the active tab, the baseline rule, a selected segment.
       The lead band paints exactly ONE gold figure (.rg-bk.is-lead .rg-bk-v);
       scripts/lib/band-gold.js reads this file and enforces it.
   Every ink sits on a token with a value in both themes, so nothing here is
   declared twice. The band is dark in both themes, and its three band-local
   colours below are the dark theme's own ok / warn / bad.                    */

.rg-vh {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

/* The first tab stop on the page: out of sight until it has focus, then an
   ordinary button above the band. It carries .rg-btn, so its ring is the one
   every control here has. */
.rg-skip { margin: 0 0 .6rem; }
.rg-skip:not(:focus) {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}
/* A landing point for the skip link, not a control: no ring around the region. */
.rg-body:focus { outline: none; }

/* ============================== THE LEAD BAND ============================= */
/* The ground, the wash, the top row, the chip and the skeleton live in base.css
   with the other seven bands. What is here is what only this page has. */
.rg-band {
  margin: 0 0 .85rem; padding: 1.1rem 1.35rem 1.15rem;
  /* --rg-up / --rg-dn / --rg-warn are the dark theme's own ok / bad / warn,
     measured on #141310 and #1E1C17 - the band stays dark in both themes, so a
     light-theme --ok (#16803C) would be 3:1 on it and unreadable. */
  --rg-up: #5BC27E; --rg-dn: #EE7C70; --rg-warn: #E4BC6C;
}
.rg-band-top { align-items: flex-start; margin-bottom: 1rem; }
.rg-band-ttl { min-width: 0; }
.rg-band-h {
  margin: 0; font-size: var(--fs-2xl); font-weight: var(--fw-bold);
  letter-spacing: -.02em; line-height: 1.15; color: #FFFFFF;
}
.rg-band-sub { margin: .25rem 0 0; font-size: var(--fs-sm); color: rgba(255, 255, 255, .72); }
.rg-band-fresh.is-warn {
  background: rgba(228, 188, 108, .13); border-color: rgba(228, 188, 108, .42); color: var(--rg-warn);
}

.rg-band-hero {
  display: grid; align-items: center; gap: 1.2rem 2.2rem;
  grid-template-columns: minmax(15rem, 25rem) minmax(0, 1fr);
}
.rg-band-chart { min-width: 0; max-width: 40rem; justify-self: end; width: 100%; }
.rg-bchart { display: block; width: 100%; height: auto; overflow: visible; }
.rg-bref { stroke: rgba(255, 255, 255, .3); stroke-width: 1; stroke-dasharray: 3 4; }
.rg-barea { fill: rgba(255, 255, 255, .07); }
.rg-bline {
  fill: none; stroke: rgba(255, 255, 255, .92); stroke-width: 2.4;
  stroke-linecap: round; stroke-linejoin: round;
}
.rg-bline.is-part { stroke-dasharray: 3 4; }
/* A background-less dot: gold here is chrome, the point the line ends on. */
.rg-bend { fill: var(--gold-400); stroke: var(--shell-800); stroke-width: 2; }
.rg-btx { fill: rgba(255, 255, 255, .92); font-size: var(--fs-sm); font-weight: var(--fw-bold); font-variant-numeric: tabular-nums; }
.rg-btx.is-dim { fill: rgba(255, 255, 255, .62); font-weight: var(--fw-normal); font-size: var(--fs-xs); }

/* The figures. A <button> where the figure opens its locations, a <div> where
   it does not; both read the same. */
.rg-bk {
  display: block; min-width: 0; margin: 0; padding: 0; border: 0; background: none;
  text-align: left; color: inherit; font: inherit; cursor: help; border-radius: 10px;
}
button.rg-bk { cursor: pointer; padding: .25rem .5rem; margin: -.25rem -.5rem; transition: background .14s ease; }
button.rg-bk:hover { background: rgba(255, 255, 255, .07); }
.rg-bk:focus-visible, .rg-bs:focus-visible { outline: 2px solid var(--gold-300); outline-offset: 2px; }
.rg-bk-v {
  display: block; font-size: var(--fs-2xl); font-weight: var(--fw-bold); line-height: 1.22;
  letter-spacing: -.015em; font-variant-numeric: tabular-nums; color: #FFFFFF; white-space: nowrap;
}
/* ONE figure is gold. A second would leave the band with no focal point. */
.rg-bk.is-lead .rg-bk-v { display: inline; font-size: var(--fs-5xl); color: var(--gold-300); }
.rg-bk-u { font-size: var(--fs-xl); font-weight: var(--fw-bold); color: rgba(255, 255, 255, .86); }
.rg-bk-l { display: block; margin-top: .18rem; font-size: var(--fs-xs); line-height: 1.35; color: rgba(255, 255, 255, .72); }
.rg-bk.is-lead .rg-bk-l { font-size: var(--fs-md); font-weight: var(--fw-medium); color: rgba(255, 255, 255, .86); }
.rg-bk-s { display: block; margin-top: .12rem; font-size: var(--fs-2xs); line-height: 1.4; color: rgba(255, 255, 255, .62); font-variant-numeric: tabular-nums; }
.rg-bk-s b { color: rgba(255, 255, 255, .88); font-weight: var(--fw-bold); }
.rg-bk.is-lead .rg-bk-s { font-size: var(--fs-xs); }

.rg-band-kpis {
  display: grid; gap: .9rem 1.4rem; margin-top: 1.1rem; padding-top: 1rem;
  border-top: 1px solid var(--shell-line);
  grid-template-columns: repeat(auto-fit, minmax(8.6rem, 1fr));
  /* Top-aligned: the three event figures carry a second and third line of provenance, and a button centres its content
     inside a stretched grid cell, so the shorter figures beside them drifted down the row. */
  align-items: start;
}
.rg-bk-reps { grid-column: span 2; cursor: default; }
.rg-bs-row { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .35rem; }
.rg-bs {
  display: inline-flex; align-items: center; gap: .35rem; margin: 0;
  padding: .28rem .65rem; border-radius: 999px; cursor: pointer;
  background: rgba(255, 255, 255, .07); border: 1px solid var(--shell-line);
  color: rgba(255, 255, 255, .86); font: inherit; font-size: var(--fs-sm);
  transition: background .14s ease, border-color .14s ease;
}
.rg-bs:hover { background: rgba(255, 255, 255, .13); }
.rg-bs.is-on { background: rgba(255, 255, 255, .2); border-color: rgba(255, 255, 255, .55); }
.rg-bs b { color: #FFFFFF; font-weight: var(--fw-bold); font-variant-numeric: tabular-nums; }
.rg-bs-up i { color: var(--rg-up); }
.rg-bs-down i { color: var(--rg-dn); }
.rg-bs-flat i { color: rgba(255, 255, 255, .72); }

.rg-band-note {
  margin: 1rem 0 0; padding-top: .75rem; border-top: 1px solid var(--shell-line);
  font-size: var(--fs-xs); line-height: 1.55; color: rgba(255, 255, 255, .66);
}
.rg-band-off {
  display: flex; gap: .8rem; align-items: flex-start; padding: .9rem 1rem;
  border: 1px dashed var(--shell-line); border-radius: 10px;
}
.rg-band-off > i { font-size: 1.3rem; color: rgba(255, 255, 255, .72); }
.rg-band-off b { display: block; color: #FFFFFF; font-size: var(--fs-lg); }
.rg-band-off span { display: block; margin-top: .15rem; max-width: 70ch; font-size: var(--fs-sm); line-height: 1.5; color: rgba(255, 255, 255, .78); }

.rg-sk-row { display: flex; gap: 1.2rem; margin-top: .9rem; }
.rg-band.is-busy { opacity: .62; transition: opacity .15s ease; }

/* ========================== THE DATA-HONESTY STRIP ======================== */
.rg-hon { margin: 0 0 .85rem; }
.rg-hon-row { display: flex; flex-wrap: wrap; align-items: center; gap: .45rem .5rem; }
.rg-hn {
  display: inline-flex; align-items: center; gap: .38rem; padding: .22rem .7rem; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border); cursor: help;
  font-size: var(--fs-xs); color: var(--text-soft); font-weight: var(--fw-medium);
}
.rg-hn .bi { font-size: var(--fs-sm); }
.rg-hn.is-warn { background: var(--warn-weak); border-color: var(--warn-line); color: var(--warn-ink); }
.rg-how {
  margin-left: auto; display: inline-flex; align-items: center; gap: .4rem; padding: .22rem .4rem;
  border: 0; background: none; border-radius: 8px; cursor: pointer;
  font: inherit; font-size: var(--fs-sm); font-weight: var(--fw-medium); color: var(--accent-ink);
}
.rg-how:hover { background: var(--accent-weak); }
.rg-how-c { font-size: var(--fs-xs); }
.rg-how[aria-expanded="true"] .rg-how-c { transform: rotate(180deg); }
.rg-how-body {
  margin-top: .6rem; padding: 1rem 1.2rem 1.1rem; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--r); box-shadow: var(--shadow);
}
.rg-defs { display: grid; grid-template-columns: repeat(auto-fit, minmax(19rem, 1fr)); gap: .75rem 1.6rem; margin: 0 0 1.1rem; }
.rg-df dt { font-size: var(--fs-sm); font-weight: var(--fw-bold); color: var(--text); }
.rg-df dd { margin: .1rem 0 0; font-size: var(--fs-xs); line-height: 1.55; color: var(--text-soft); }
.rg-how-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(20rem, 1fr)); gap: 1rem 1.8rem; }
.rg-how-cols h3 { margin: 0 0 .3rem; font-size: var(--fs-sm); font-weight: var(--fw-bold); }
.rg-how-cols ul { margin: 0; padding-left: 1.1rem; font-size: var(--fs-xs); line-height: 1.55; color: var(--text-soft); }
.rg-how-cols li + li { margin-top: .25rem; }
.rg-how-id { margin: 1rem 0 0; padding-top: .75rem; border-top: 1px solid var(--border-soft); font-size: var(--fs-sm); font-weight: var(--fw-medium); color: var(--text); }

/* ================================= THE PANEL =============================== */
.rg-panel { padding: 0; }
.rg-panel.is-busy .rg-body { opacity: .5; transition: opacity .15s ease; cursor: progress; }
.rg-toolbar { padding: 1rem 1.2rem .8rem; }
.rg-tb-row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .75rem 1.2rem; }
.rg-tb-b { margin-top: .8rem; padding-top: .8rem; border-top: 1px solid var(--border-soft); }
.rg-f { display: flex; flex-direction: column; gap: .24rem; min-width: 0; }
.rg-f-q { flex: 0 1 12rem; }
.rg-fl {
  display: inline-flex; align-items: center; gap: .3rem; cursor: help;
  font-size: var(--fs-xs); font-weight: var(--fw-medium); color: var(--text-soft);
}
.rg-fl .bi { font-size: .85em; opacity: .7; }

/* A segmented control: one choice of a few, always on screen. */
.rg-seg {
  display: inline-flex; gap: 2px; padding: 2px; border-radius: 10px;
  background: var(--inset); border: 1px solid var(--border);
}
.rg-sb {
  display: inline-flex; align-items: center; gap: .4rem; margin: 0; padding: .3rem .8rem;
  border: 0; border-radius: 8px; background: transparent; cursor: pointer; white-space: nowrap;
  font: inherit; font-size: var(--fs-sm); font-weight: var(--fw-medium); color: var(--text-soft);
}
.rg-sb:hover { color: var(--text); background: var(--surface-3); }
.rg-sb.is-on {
  background: var(--surface); color: var(--text); font-weight: var(--fw-bold);
  box-shadow: 0 1px 2px rgba(17, 17, 19, .14), inset 0 0 0 1px var(--accent-line);
}
.rg-sb:focus-visible, .rg-btn:focus-visible, .rg-select:focus-visible, .rg-tab:focus-visible, .rg-hb:focus-visible,
.rg-nb:focus-visible, .rg-rn:focus-visible, .rg-gb:focus-visible, .rg-how:focus-visible, .rg-pen:focus-visible,
.rg-frame:focus-visible, .rg-lk:focus-visible, .rg-mreset:focus-visible, .rg-qx:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px;
}
.rg-tag {
  padding: .04rem .4rem; border-radius: 999px; font-style: normal; line-height: 1.4;
  font-size: var(--fs-3xs); font-weight: var(--fw-bold);
  background: var(--warn-weak); color: var(--warn-ink); border: 1px solid var(--warn-line);
}

.rg-select, .rg-input {
  height: 34px; padding: 0 .7rem; border-radius: 9px; border: 1px solid var(--border);
  background-color: var(--surface); color: var(--text); font-size: var(--fs-sm);
}
.rg-select { min-width: 7rem; padding-right: .4rem; }
.rg-input { width: 100%; height: 38px; margin: .3rem 0 .9rem; }
.rg-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-weak); }

.rg-search { position: relative; min-width: 11rem; }
.rg-search > .bi-search {
  position: absolute; left: .7rem; top: 50%; transform: translateY(-50%);
  color: var(--text-dim); font-size: var(--fs-md); pointer-events: none;
}
.rg-search input {
  width: 100%; height: 34px; padding: 0 2rem 0 2.1rem; border-radius: 9px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); font-size: var(--fs-sm);
}
.rg-search input::placeholder { color: var(--text-dim); }
.rg-search input::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; display: none; }
.rg-search input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-weak); }
.rg-qx {
  position: absolute; right: .25rem; top: 50%; transform: translateY(-50%);
  width: 26px; height: 26px; border: 0; border-radius: 7px; padding: 0; display: grid; place-items: center;
  background: transparent; color: var(--text-dim); font-size: var(--fs-xs); cursor: pointer;
}
.rg-qx:hover { background: var(--accent-weak); color: var(--accent-ink); }

.rg-btn {
  display: inline-flex; align-items: center; gap: .4rem; height: 34px; margin: 0; padding: 0 .85rem;
  border: 1px solid var(--border); border-radius: 9px; background: var(--surface); color: var(--text);
  font: inherit; font-size: var(--fs-sm); font-weight: var(--fw-medium); cursor: pointer; white-space: nowrap;
}
.rg-btn:hover { background: var(--surface-2); border-color: var(--accent-line); }
.rg-btn.is-on { background: var(--accent-weak); border-color: var(--accent-line); color: var(--accent-ink); }
.rg-btn.is-primary { background: var(--accent-fill); border-color: transparent; color: var(--accent-on); }
.rg-btn.is-primary:hover { filter: brightness(1.06); }
.rg-btn.is-quiet { background: transparent; border-color: transparent; color: var(--text-soft); }
.rg-btn.is-quiet:hover { background: var(--surface-3); color: var(--text); }
.rg-btn.is-busy, .rg-btn[aria-disabled="true"] { opacity: .55; cursor: progress; }

/* The Columns menu is Bootstrap's dropdown, dressed in the house surface. */
.rg-menu {
  min-width: 15.5rem; padding: .5rem; border: 1px solid var(--border); border-radius: 12px;
  background: var(--surface); box-shadow: var(--lift-3);
}
.rg-mh { padding: .4rem .5rem .15rem; font-size: var(--fs-xs); font-weight: var(--fw-bold); color: var(--text-soft); }
.rg-mi {
  display: flex; align-items: center; gap: .55rem; padding: .32rem .5rem; border-radius: 7px; cursor: pointer;
  font-size: var(--fs-sm); color: var(--text);
}
.rg-mi:hover { background: var(--surface-2); }
.rg-mi input { accent-color: var(--accent-fill); }
.rg-mreset {
  display: block; width: 100%; margin-top: .45rem; padding: .4rem .5rem; border: 0; border-radius: 7px;
  background: var(--inset); color: var(--text-soft); font: inherit; font-size: var(--fs-sm); font-weight: var(--fw-medium); cursor: pointer;
}
.rg-mreset:hover { background: var(--accent-weak); color: var(--accent-ink); }

.rg-tabrow {
  display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: .3rem 1rem;
  padding: 0 1.2rem; border-bottom: 1px solid var(--border);
}
.rg-tabs { display: flex; gap: .2rem; }
.rg-acts { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; padding-bottom: .45rem; }
.rg-dd { position: relative; display: inline-block; }
.rg-tab {
  display: inline-flex; align-items: center; gap: .45rem; margin: 0 0 -1px; padding: .7rem .95rem;
  border: 0; border-bottom: 2px solid transparent; background: none; cursor: pointer;
  font: inherit; font-size: var(--fs-md); font-weight: var(--fw-medium); color: var(--text-soft);
}
.rg-tab:hover { color: var(--text); }
.rg-tab.is-on { color: var(--text); font-weight: var(--fw-bold); border-bottom-color: var(--accent-fill); }

.rg-body { padding: 1rem 1.2rem 1.25rem; min-height: 14rem; }
.rg-lede { margin: 0 0 .85rem; max-width: 84ch; font-size: var(--fs-sm); line-height: 1.5; color: var(--text-soft); }
.rg-note { margin: .45rem 0; max-width: 90ch; font-size: var(--fs-xs); line-height: 1.5; color: var(--text-soft); }
.rg-h3 { margin: 1.3rem 0 .45rem; font-size: var(--fs-lg); font-weight: var(--fw-bold); color: var(--text); }

.rg-calm {
  display: flex; flex-direction: column; align-items: center; gap: .35rem;
  padding: 2.6rem 1rem; text-align: center; color: var(--text-soft);
}
.rg-calm > .bi { font-size: 1.7rem; opacity: .6; }
.rg-calm b { color: var(--text); font-size: var(--fs-lg); }
.rg-calm span { max-width: 62ch; font-size: var(--fs-md); line-height: 1.5; }
.rg-calm-hint { font-size: var(--fs-sm); }
.rg-retry { display: flex; justify-content: center; margin-top: .9rem; }

/* ================================ THE TABLE ================================ */
/* The frame is the scroller: it scrolls both ways inside a bounded height, so
   the header can stay put without anything on the chain to the page being a
   scroll container (overflow-x forces overflow-y, and a sticky header sticks
   to its nearest scroller). The rep's name stays put while it scrolls sideways. */
.rg-frame {
  overflow: auto; max-height: min(78vh, 58rem); position: relative;
  border: 1px solid var(--border); border-radius: 12px; background: var(--surface);
}
/* --rg-min and --rg-cols are written on the table by the page (inline, so each
   table carries its own); the declared default is what a table with neither
   would fall back to, and is what lets the token sweep see them defined. */
.rg-tbl { --rg-min: 0px; min-width: var(--rg-min); font-size: var(--fs-md); }
.rg-tr {
  --rg-bg: var(--surface);
  display: grid; grid-template-columns: var(--rg-cols); column-gap: .5rem; align-items: center;
  padding-right: .9rem; background: var(--rg-bg);
}
.rg-c {
  display: flex; align-items: center; justify-content: flex-end; min-width: 0; padding: 0 .1rem;
  font-variant-numeric: tabular-nums;
}
.rg-cname {
  position: sticky; left: 0; z-index: 2; background: var(--rg-bg);
  display: flex; flex-direction: column; align-items: flex-start; justify-content: center;
  min-width: 0; padding-left: .9rem;
}
.rg-rw { border-bottom: 1px solid var(--border-soft); }
.rg-den-comfortable .rg-rw { min-height: 3.1rem; }
.rg-den-compact .rg-rw { min-height: 2.15rem; }
.rg-rw:hover { --rg-bg: var(--surface-2); }

.rg-thead { position: sticky; top: 0; z-index: 4; background: var(--surface-2); }
.rg-thead .rg-tr { --rg-bg: var(--surface-2); }
.rg-thead .rg-cname { z-index: 5; }
.rg-yr { align-items: end; }
.rg-yb {
  padding: .45rem 0 .25rem; text-align: center; font-size: var(--fs-xs); font-weight: var(--fw-bold);
  color: var(--text); border-bottom: 2px solid var(--accent-line);
}
.rg-yb em { margin-left: .35rem; font-style: normal; font-weight: var(--fw-normal); color: var(--text-soft); }
.rg-yb.is-empty { border-bottom-color: transparent; }
.rg-yb.is-part, .rg-h.is-part {
  background-image: repeating-linear-gradient(135deg, transparent 0 5px, var(--border) 5px 6px);
}
.rg-hr { border-bottom: 1px solid var(--border); }
.rg-h { display: flex; align-items: flex-end; justify-content: flex-end; padding: .4rem .1rem .5rem; min-width: 0; }
/* .rg-cname is a flex COLUMN, so across is the cross axis: the heading sits at
   the left edge, over the names, and at the bottom of its row. */
.rg-h.rg-cname { align-items: flex-start; justify-content: flex-end; }
.rg-hb {
  display: inline-flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 0 .25rem;
  margin: 0; padding: .1rem .25rem; border: 0; border-radius: 6px; background: none; text-align: right;
  font: inherit; font-size: var(--fs-xs); font-weight: var(--fw-bold); line-height: 1.25; color: var(--text-soft); cursor: pointer;
}
.rg-hb em { flex-basis: 100%; font-style: normal; font-weight: var(--fw-normal); font-size: var(--fs-2xs); }
.rg-hb:hover { color: var(--text); background: var(--accent-weak); }
.rg-hb.is-static { cursor: help; }
.rg-hb.is-static:hover { background: none; }
.rg-hb .bi { font-size: .75em; color: var(--accent-ink); }

.rg-gr { --rg-bg: var(--surface-3); min-height: 2.3rem; border-bottom: 1px solid var(--border); font-weight: var(--fw-bold); }
.rg-gb {
  display: inline-flex; align-items: center; gap: .45rem; margin: 0; padding: 0; border: 0; background: none;
  font: inherit; font-weight: var(--fw-bold); color: var(--text); cursor: pointer; text-align: left;
}
.rg-gb em { font-style: normal; font-weight: var(--fw-normal); font-size: var(--fs-xs); color: var(--text-soft); }
.rg-gc { font-size: var(--fs-xs); color: var(--text-soft); }
.rg-gr.is-open .rg-gc { transform: rotate(90deg); }
.rg-tfoot { position: sticky; bottom: 0; z-index: 4; background: var(--surface-2); border-top: 2px solid var(--border); }
.rg-tot { --rg-bg: var(--surface-2); min-height: 2.8rem; font-weight: var(--fw-bold); }
.rg-tn { font-size: var(--fs-md); font-weight: var(--fw-black); color: var(--text); }

.rg-nr { display: flex; align-items: center; gap: .3rem; max-width: 100%; min-width: 0; }
.rg-rn {
  margin: 0; padding: 0; border: 0; background: none; text-align: left; cursor: pointer;
  font: inherit; font-size: var(--fs-md); font-weight: var(--fw-bold); color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%;
}
.rg-rn:hover { color: var(--accent-ink); text-decoration: underline; text-underline-offset: 3px; }
.rg-rs {
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: var(--fs-xs); font-weight: var(--fw-normal); color: var(--text-soft);
}
/* The pencil appears on the row you are on, and on keyboard focus. A hover
   reveal, not a resting opacity of zero: the control is in the tab order and
   shows the moment it is reached. */
.rg-pen {
  flex: 0 0 auto; margin: 0; padding: .15rem .3rem; border: 0; border-radius: 6px; background: none;
  font-size: var(--fs-xs); color: var(--text-dim); cursor: pointer; opacity: 0;
}
.rg-rw:hover .rg-pen, .rg-rw:focus-within .rg-pen, .rg-pen:focus-visible { opacity: 1; }
.rg-pen:hover { color: var(--accent-ink); background: var(--accent-weak); }
.rg-rw.is-un .rg-rn { color: var(--text-soft); }
.rg-rw.is-nobook .rg-rn, .rg-rw.is-nobook .rg-nz { color: var(--text-dim); }

/* A number that opens the locations behind it. */
.rg-nb {
  margin: 0; padding: .15rem .4rem; border: 0; border-radius: 6px; background: none; cursor: pointer;
  font: inherit; font-weight: var(--fw-medium); color: var(--text); font-variant-numeric: tabular-nums;
}
.rg-nb:hover { background: var(--accent-weak); color: var(--accent-ink); }
.rg-nz { padding: .15rem .4rem; color: var(--text-dim); cursor: default; font-variant-numeric: tabular-nums; }
.rg-np { padding: .15rem .4rem; font-weight: var(--fw-bold); color: var(--text); cursor: help; font-variant-numeric: tabular-nums; }
.rg-np.rg-up { color: var(--ok-ink); }
.rg-np.rg-down { color: var(--bad-ink); }
.rg-up { color: var(--ok-ink); }
.rg-down { color: var(--bad-ink); }
.rg-flat { color: var(--text-soft); }
.rg-none { color: var(--text-dim); }
.rg-nb.rg-up:hover { color: var(--ok-ink); }
.rg-nb.rg-down:hover { color: var(--bad-ink); }

/* The state chip: a sign, an arrow and a hidden word, never colour alone. */
.rg-pill {
  display: inline-flex; align-items: center; gap: .25rem; padding: .12rem .55rem; border-radius: 999px;
  border: 1px solid transparent; cursor: help; white-space: nowrap;
  font-size: var(--fs-xs); font-weight: var(--fw-bold); font-variant-numeric: tabular-nums;
}
.rg-pill.rg-up { background: var(--ok-weak); border-color: var(--ok-line); color: var(--ok-ink); }
.rg-pill.rg-down { background: var(--bad-weak); border-color: var(--bad-line); color: var(--bad-ink); }
.rg-pill.rg-flat { background: var(--inset); border-color: var(--border); color: var(--text-soft); }
.rg-pill.rg-none { background: transparent; border-color: var(--border); color: var(--text-soft); }

.rg-since { display: inline-flex; flex-direction: column; align-items: flex-end; gap: 3px; width: 100%; }
.rg-dbar { position: relative; display: block; width: 100%; max-width: 5.2rem; height: 5px; border-radius: 3px; background: var(--border-soft); }
.rg-dbar > i { --w: 0; position: absolute; top: 0; bottom: 0; display: block; width: calc(var(--w) * 50%); border-radius: 3px; }
.rg-dbar > .rg-up { left: 50%; background: var(--ok); transform-origin: left; }
.rg-dbar > .rg-down { right: 50%; background: var(--bad); transform-origin: right; }

.rg-spark { display: block; overflow: visible; }
.rg-sp-l { fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.rg-sp-l.is-part { stroke-dasharray: 2 3; }
.rg-sp-up .rg-sp-l { stroke: var(--ok); }     .rg-sp-up .rg-sp-e { fill: var(--ok); }
.rg-sp-down .rg-sp-l { stroke: var(--bad); }  .rg-sp-down .rg-sp-e { fill: var(--bad); }
.rg-sp-flat .rg-sp-l { stroke: var(--text-soft); }  .rg-sp-flat .rg-sp-e { fill: var(--text-soft); }

.rg-mix { display: inline-flex; flex-direction: column; align-items: flex-end; gap: 3px; width: 100%; cursor: help; }
.rg-mixbar { display: flex; gap: 2px; width: 100%; max-width: 6.4rem; height: 7px; }
.rg-mi-i, .rg-mi-c { --w: 0; display: block; width: calc(var(--w) * 1%); min-width: 0; }
.rg-mi-i { background: var(--s2); border-radius: 3px 0 0 3px; }
.rg-mi-c { background: var(--s4); border-radius: 0 3px 3px 0; }
.rg-mixt { font-size: var(--fs-2xs); color: var(--text-soft); white-space: nowrap; }
.rg-rank { font-size: var(--fs-sm); font-weight: var(--fw-bold); color: var(--text-soft); cursor: help; }

/* ================================ THE HEATMAP ============================== */
.rg-hm-top { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem 1.2rem; margin-bottom: .8rem; }
.rg-hm-top .rg-lede { flex: 1 1 24rem; margin: 0; }
.rg-heat-f { max-height: min(78vh, 58rem); }
.rg-heat {
  --rg-hname: 13rem; --rg-hw: 2rem; --rg-n: 56;
  min-width: calc(var(--rg-hname) + var(--rg-n) * var(--rg-hw));
}
.rg-hr2 {
  display: grid; grid-template-columns: var(--rg-hname) repeat(var(--rg-n), var(--rg-hw));
  align-items: stretch; background: var(--rg-bg, var(--surface)); --rg-bg: var(--surface);
}
.rg-hhead { position: sticky; top: 0; z-index: 4; background: var(--surface-2); }
.rg-hhead .rg-hr2 { --rg-bg: var(--surface-2); }
.rg-hhead .rg-cname { z-index: 5; }
.rg-hy-r { border-bottom: 1px solid var(--border-soft); }
.rg-hm-r { border-bottom: 1px solid var(--border); }
.rg-hy {
  padding: .4rem .3rem .15rem; border-left: 1px solid var(--border); text-align: left;
  font-size: var(--fs-xs); font-weight: var(--fw-bold); color: var(--text);
}
.rg-hy.is-pad { border-left: 0; }
.rg-hm {
  padding: .2rem 0 .35rem; text-align: center; font-size: var(--fs-2xs); color: var(--text-soft);
}
.rg-hm.rg-cname { align-items: flex-start; justify-content: flex-end; padding-bottom: .35rem; font-size: var(--fs-xs); font-weight: var(--fw-bold); }
.rg-hc0 { padding-right: .5rem; }
.rg-hbody .rg-rw { min-height: 2.15rem; }
.rg-heat.rg-den-comfortable .rg-hbody .rg-rw { min-height: 2.35rem; }
.rg-hbody .rg-gr { min-height: 2.3rem; }
.rg-hc {
  display: flex; align-items: center; justify-content: center; margin: 1px; border-radius: 4px;
  background: var(--surface-2); color: var(--text); font-size: var(--fs-2xs); font-weight: var(--fw-medium);
  font-variant-numeric: tabular-nums; cursor: default; --hm-c: transparent; --i: 0;
}
.rg-hc.is-pos { --hm-c: var(--ok); }
.rg-hc.is-neg { --hm-c: var(--bad); }
.rg-hc.is-act { --hm-c: var(--accent-fill); }
.rg-hc.is-pos, .rg-hc.is-neg, .rg-hc.is-act {
  background: color-mix(in srgb, var(--hm-c) calc(var(--i) * 58%), var(--surface));
}
.rg-hc.is-na { background: transparent; color: var(--text-dim); }
.rg-hc.is-link { cursor: pointer; }
.rg-hc.is-link:hover { outline: 2px solid var(--accent); outline-offset: -1px; }
.rg-hc.is-b, .rg-hm.is-b { border-right: 2px dashed var(--accent); }
.rg-hc.is-part, .rg-hm.is-part {
  background-image: repeating-linear-gradient(135deg, transparent 0 4px, color-mix(in srgb, var(--text) 22%, transparent) 4px 5px);
}

/* =============================== THE COMPARISON ============================ */
.rg-cbar { display: flex; flex-wrap: wrap; align-items: center; gap: .55rem .75rem; margin-bottom: .9rem; }
.rg-cchip {
  display: inline-flex; align-items: center; gap: .45rem; padding: .22rem .3rem .22rem .7rem;
  border: 1px solid var(--border); border-radius: 999px; background: var(--surface);
  font-size: var(--fs-sm); font-weight: var(--fw-medium);
}
.rg-cchip button {
  display: grid; place-items: center; width: 1.5rem; height: 1.5rem; margin: 0; padding: 0; border: 0;
  border-radius: 50%; background: none; color: var(--text-soft); font-size: var(--fs-xs); cursor: pointer;
}
.rg-cchip button:hover { background: var(--accent-weak); color: var(--accent-ink); }
.rg-cdot { display: inline-block; flex: 0 0 .7rem; width: .7rem; height: .7rem; border-radius: 50%; }
.rg-d1 { fill: var(--s1); background: var(--s1); }
.rg-d2 { fill: var(--s2); background: var(--s2); }
.rg-d3 { fill: var(--s3); background: var(--s3); }
.rg-d4 { fill: var(--s4); background: var(--s4); }
.rg-l1 { stroke: var(--s1); }
.rg-l2 { stroke: var(--s2); }
.rg-l3 { stroke: var(--s3); }
.rg-l4 { stroke: var(--s4); }

.rg-chartwrap { margin: .5rem 0 .2rem; padding: .4rem .2rem; }
.rg-chart { display: block; width: 100%; height: auto; overflow: visible; }
.rg-wf { max-width: 56rem; }
.rg-grid { stroke: var(--border-soft); stroke-width: 1; }
.rg-ax { fill: var(--text-soft); font-size: var(--fs-xs); font-variant-numeric: tabular-nums; }
.rg-ax-b { fill: var(--accent-ink); font-weight: var(--fw-bold); }
.rg-ax-n { font-size: var(--fs-2xs); }
.rg-basel { stroke: var(--accent); stroke-width: 1.5; stroke-dasharray: 4 4; }
.rg-band-sel { fill: var(--accent-weak); }
.rg-ln { fill: none; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.rg-ln.is-heavy { stroke-width: 3; }
.rg-ln.is-part { stroke-dasharray: 3 4; }
.rg-end { stroke: var(--surface); stroke-width: 2; }
.rg-end.is-part { stroke-width: 2.6; }
.rg-endl { fill: var(--text); font-size: var(--fs-sm); }
.rg-endn { font-weight: var(--fw-bold); }
.rg-endv { fill: var(--text-soft); font-variant-numeric: tabular-nums; }
.rg-xh { fill: transparent; cursor: crosshair; }
.rg-xh:hover { fill: var(--accent-weak); }

.rg-cmp-t {
  --rg-cols: minmax(11rem, 1.6fr) repeat(7, minmax(4.6rem, 1fr));
  margin-top: 1rem; border: 1px solid var(--border); border-radius: 12px; overflow: hidden;
}
.rg-cr { min-height: 2.9rem; border-bottom: 1px solid var(--border-soft); }
.rg-cr:last-child { border-bottom: 0; }
.rg-cr .rg-cname { flex-direction: row; align-items: center; gap: .5rem; }

.rg-wfgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(24rem, 1fr)); gap: 1rem; }
.rg-wfc { margin: 0; padding: .8rem 1rem .6rem; border: 1px solid var(--border-soft); border-radius: 12px; }
.rg-wfc figcaption { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin-bottom: .2rem; }
.rg-wfc figcaption span { margin-left: auto; font-size: var(--fs-xs); color: var(--text-soft); }

.rg-wb-open { fill: var(--text-dim); }
.rg-wb-close { fill: var(--accent-fill); }
.rg-wb-up { fill: var(--ok); }
.rg-wb-down { fill: var(--bad); }
.rg-wb-xfer { fill: var(--s4); }
.rg-wv { fill: var(--text); font-size: var(--fs-sm); font-weight: var(--fw-bold); font-variant-numeric: tabular-nums; }
.rg-wl { fill: var(--text-soft); font-size: var(--fs-xs); }
.rg-wc { stroke: var(--border); stroke-width: 1; stroke-dasharray: 2 3; }
.rg-wbar { cursor: help; }
.rg-wbar.is-link { cursor: pointer; }
.rg-wbar.is-link:hover rect { filter: brightness(1.12); }
.rg-wbar:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ================================== DIALOGS ================================ */
.rg-wide { max-width: min(1180px, 96vw); }
.rg-drill-h { align-items: flex-start; }
.rg-drill-what { max-width: 92ch; margin-top: .25rem; font-size: var(--fs-sm); line-height: 1.5; color: var(--text-soft); }
.rg-drill-what b { color: var(--text); }
.rg-drill-scope { display: block; margin-top: .25rem; font-size: var(--fs-xs); }
.rg-drill-bar { padding: .65rem 1.2rem; border-bottom: 1px solid var(--border-soft); }
.rg-drill-tools { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; }
.rg-drill-n { margin-left: auto; font-size: var(--fs-sm); color: var(--text-soft); font-variant-numeric: tabular-nums; }
.rg-drill-n b { color: var(--text); }
.rg-drill-foot { display: flex; justify-content: flex-end; gap: .5rem; padding: .6rem 1.2rem; border-top: 1px solid var(--border-soft); }
.rg-drill-foot:empty { display: none; }

.rg-drt { font-size: var(--fs-sm); }
.rg-dr {
  display: grid; align-items: start; gap: .6rem; padding: .55rem 1.2rem; border-bottom: 1px solid var(--border-soft);
  grid-template-columns: minmax(13rem, 2.2fr) minmax(8rem, 1.3fr) 4.5rem minmax(7.5rem, 1.2fr) 6rem 5.8rem 5.8rem 5rem;
}
.rg-dr > span { min-width: 0; overflow-wrap: anywhere; }
.rg-dr .n { text-align: right; font-variant-numeric: tabular-nums; }
.rg-dr em { display: block; font-style: normal; font-size: var(--fs-xs); color: var(--text-soft); }
.rg-dr-h {
  position: sticky; top: 0; z-index: 2; background: var(--surface-2); border-bottom: 1px solid var(--border);
  font-size: var(--fs-xs); font-weight: var(--fw-bold); color: var(--text-soft);
}
.rg-lk { font-weight: var(--fw-bold); color: var(--text); text-decoration: none; }
a.rg-lk:hover { color: var(--accent-ink); text-decoration: underline; text-underline-offset: 3px; }
.rg-lk.is-plain { cursor: help; }
.rg-co { font-weight: var(--fw-bold); }

.rg-rep { padding: 1.2rem 1.4rem 1.4rem; }
.rg-rep-h { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; }
.rg-rep-t { margin: 0; font-size: var(--fs-2xl); font-weight: var(--fw-bold); letter-spacing: -.01em; }
.rg-rep-s { margin: .2rem 0 0; font-size: var(--fs-sm); color: var(--text-soft); max-width: 70ch; line-height: 1.5; }
.rg-rep-ctl { margin: .9rem 0 .6rem; }
.rg-rk { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem 1.3rem; margin: .6rem 0 .2rem; }
.rg-rk > div span { display: block; font-size: var(--fs-3xl); font-weight: var(--fw-bold); line-height: 1.1; font-variant-numeric: tabular-nums; }
.rg-rk > div em { font-style: normal; font-size: var(--fs-xs); color: var(--text-soft); }
.rg-rk > .bi { font-size: 1.2rem; color: var(--text-dim); }
.rg-rk-net { padding-left: 1.3rem; border-left: 1px solid var(--border); }
.rg-rep-lists { display: grid; grid-template-columns: repeat(auto-fit, minmax(20rem, 1fr)); gap: 1.2rem; margin-top: 1.3rem; }
.rg-rl { min-height: 6rem; padding: .8rem 1rem; border: 1px solid var(--border-soft); border-radius: 12px; }
.rg-rl-h { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: .4rem; }
.rg-rl-h span { font-weight: var(--fw-bold); font-variant-numeric: tabular-nums; }
.rg-rl ul { margin: 0; padding: 0; list-style: none; }
.rg-rl li { display: flex; justify-content: space-between; gap: .6rem; padding: .35rem 0; border-bottom: 1px solid var(--border-soft); font-size: var(--fs-sm); }
.rg-rl li em { display: block; font-style: normal; font-size: var(--fs-xs); color: var(--text-soft); }
.rg-rl li .n { white-space: nowrap; color: var(--text-soft); }
.rg-rl li a { color: var(--text); font-weight: var(--fw-medium); text-decoration: none; }
.rg-rl li a:hover { color: var(--accent-ink); text-decoration: underline; }
.rg-rl > .rg-btn { margin-top: .7rem; }
.rg-name { padding: 1.3rem 1.4rem 1.4rem; }
.rg-name-a { display: flex; gap: .5rem; }

/* ============================== BOOK HEALTH ================================ */
/* The toolbar of this view is two controls and a sentence: the controls of the
   other views do not apply to it, and the sentence says so. */
.rg-tb-h { align-items: flex-end; }
.rg-tb-n {
  flex: 1 1 22rem; max-width: 64ch; margin: 0; align-self: center;
  font-size: var(--fs-xs); line-height: 1.5; color: var(--text-soft);
}

/* The five figures. A button where the figure picks which books to show (with
   a pressed state), a plain tile where it is only a number. */
.rg-bh-tiles { display: grid; gap: .75rem; margin: 0 0 1rem; grid-template-columns: repeat(auto-fit, minmax(11.5rem, 1fr)); }
.rg-bh-t {
  display: block; min-width: 0; margin: 0; padding: .8rem 1rem; text-align: left; cursor: help;
  border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--text); font: inherit;
}
button.rg-bh-t { cursor: pointer; transition: background .14s ease, border-color .14s ease; }
button.rg-bh-t:hover { background: var(--surface-2); border-color: var(--accent-line); }
button.rg-bh-t[aria-pressed="true"] { background: var(--accent-weak); border-color: var(--accent-line); }
button.rg-bh-t:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.rg-bh-v { display: block; font-size: var(--fs-3xl); font-weight: var(--fw-bold); line-height: 1.15; letter-spacing: -.015em; font-variant-numeric: tabular-nums; }
.rg-bh-l { display: block; margin-top: .15rem; font-size: var(--fs-sm); font-weight: var(--fw-medium); color: var(--text); }
.rg-bh-s { display: block; margin-top: .1rem; font-size: var(--fs-xs); line-height: 1.4; color: var(--text-soft); }
.rg-bh-count { margin: 0 0 .15rem; }
.rg-bh-rule { margin: 0 0 .7rem; }
.rg-bh-rule b { color: var(--text); }

/* The table is the matrix's own (.rg-tbl, .rg-tr, .rg-c) with these additions. A
   flagged row says so in WORDS (the pill) and in a bar down its left edge, never
   in colour alone. */
.rg-bh-rw { min-height: 3.5rem; }
.rg-bh-rw.is-dormant .rg-cname { box-shadow: inset 3px 0 0 var(--warn-ink); }
.rg-bh-flag { margin-top: .22rem; background: var(--warn-weak); border-color: var(--warn-line); color: var(--warn-ink); cursor: help; }
.rg-rt {
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: var(--fs-md); font-weight: var(--fw-bold); color: var(--text);
}
.rg-rw.is-un .rg-rt { color: var(--text-soft); }
.rg-cs { display: inline-flex; flex-direction: column; align-items: flex-end; gap: 1px; }
.rg-bh-sub { padding: 0 .4rem; font-size: var(--fs-xs); font-variant-numeric: tabular-nums; cursor: help; }
.rg-bh-share { display: inline-flex; align-items: center; justify-content: flex-end; gap: .5rem; width: 100%; cursor: help; }
.rg-bh-bar { position: relative; display: block; flex: 0 1 4.6rem; min-width: 2rem; height: 7px; border-radius: 4px; background: var(--border-soft); }
.rg-bh-fill {
  --w: 0; position: absolute; top: 0; bottom: 0; left: 0; display: block; transform-origin: left;
  width: calc(var(--w) * 1%); border-radius: 4px; background: var(--accent-fill);
}
/* The line below which a large book is flagged. */
.rg-bh-tick { --w: 0; position: absolute; top: -3px; bottom: -3px; left: calc(var(--w) * 1%); width: 2px; border-radius: 1px; background: var(--text-soft); }
.rg-bh-pct { min-width: 3.3rem; text-align: right; font-weight: var(--fw-bold); font-variant-numeric: tabular-nums; }

.rg-bh-prov { margin-top: 1rem; padding-top: .8rem; border-top: 1px solid var(--border-soft); }
.rg-bh-prov p { margin: .3rem 0; max-width: 100ch; font-size: var(--fs-xs); line-height: 1.55; color: var(--text-soft); }
.rg-bh-prov b { color: var(--text); }
.rg-bh-late { margin-left: .4rem; }

/* ================================ THE FOOTER ================================ */
.rg-hn-x { cursor: help; }
.rg-hn-x .bi { color: var(--accent-ink); }
.rg-hn-live .bi { color: var(--ok-ink); }
.rg-hn-ext .bi { color: var(--text-dim); }
.rg-src {
  margin: .85rem 0 0; padding: 1rem 1.2rem 1.1rem; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--r); box-shadow: var(--shadow);
}
.rg-src-h { display: flex; align-items: center; gap: .5rem; margin: 0 0 .7rem; font-size: var(--fs-lg); font-weight: var(--fw-bold); }
.rg-src-h .bi { color: var(--accent-ink); }
.rg-src-feed { margin-bottom: .6rem; }
.rg-src-l { display: grid; gap: .45rem; margin: 0; padding: 0; list-style: none; }
.rg-src-l li { display: grid; align-items: center; gap: .25rem .9rem; grid-template-columns: minmax(0, 21rem) minmax(0, 1fr); }
.rg-src-l li > .rg-hn { justify-self: start; }
.rg-src-n .rg-lk { color: var(--accent-ink); text-decoration: underline; text-underline-offset: 3px; }
.rg-src-p { flex: 1 1 22rem; min-width: 0; margin: 0; font-size: var(--fs-xs); line-height: 1.5; color: var(--text-soft); }
.rg-src-x { flex: none; margin-top: .55rem; max-width: 70ch; }
.rg-src-w {
  display: flex; align-items: flex-start; gap: .5rem; margin: .6rem 0 0; padding: .5rem .75rem; border-radius: 10px;
  background: var(--warn-weak); border: 1px solid var(--warn-line); color: var(--warn-ink); font-size: var(--fs-sm);
}
.rg-src-notes { margin-top: .4rem; }
.rg-src-n { max-width: 110ch; margin: 0; padding-left: 1.1rem; font-size: var(--fs-xs); line-height: 1.6; color: var(--text-soft); }
.rg-src-n li + li { margin-top: .3rem; }

/* ================================== MOTION ================================= */
/* Bars grow from their base. Keyframed transforms, never a transition on width:
   these elements are rebuilt on every repaint, so a transition would never run.
   `backwards` fill: a bar that never gets a frame is a bar at its full size. */
@keyframes rg-grow-x { from { transform: scaleX(0); } }
@keyframes rg-grow-y { from { transform: scaleY(0); } }
.rg-gx { animation: rg-grow-x .7s var(--ease-out) backwards; }
.rg-gy { transform-box: fill-box; transform-origin: bottom; animation: rg-grow-y .65s var(--ease-out) backwards; }
@media (prefers-reduced-motion: reduce) {
  .rg-gx, .rg-gy { animation: none; }
  .rg-band.is-busy, .rg-panel.is-busy .rg-body { transition: none; }
}

/* ================================= BREAKPOINTS ============================= */
@media (max-width: 1100px) {
  .rg-band-hero { grid-template-columns: minmax(0, 1fr); }
  .rg-band-chart { justify-self: stretch; max-width: none; }
  .rg-src-l li { grid-template-columns: minmax(0, 1fr); }
}
