/* Shared list-screen chrome - see TagHelpers/AppGridTagHelper.cs and
   wwwroot/js/app-grid.js.

   BOOTSTRAP VARIABLES ONLY, NO COLOUR LITERALS. The theme flips at runtime via
   data-bs-theme on <html> and there is no reload to re-evaluate a hard-coded
   hex, so a literal here is a colour that survives into the wrong theme. Every
   rule below resolves through var(--bs-*), which Bootstrap redefines under the
   dark selector for us. The one place site.css does use literals for a panel
   (.filter-bar) it pays for it with a whole parallel [data-bs-theme="dark"]
   block; this file deliberately does not take that on. */

.app-grid {
  /* Establishes the containing block for the busy overlay, and the stacking
     context that keeps a sticky header below .act-as-banner's z-index: 1080. */
  position: relative;
}

/* ── Toolbar ─────────────────────────────────────────────────────────────
   Count on the left, chips beside it, rows-per-page pushed right. Wraps to
   two lines on a phone rather than shrinking the controls. */
.app-grid-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
  margin-bottom: 0.5rem;
  min-height: 2rem;
}

/* The count is a <p> for the sake of role="status", so it needs its margin
   removed rather than inherited from prose. */
.app-grid-summary {
  margin: 0;
  color: var(--bs-secondary-color);
  font-size: 0.875rem;
  /* Reserves the line so the toolbar does not change height between "No
     events" and "Showing 1-50 of 2,282 events". A toolbar that jumps by a
     line every time you filter is the same layout shift the busy overlay's
     min-height exists to prevent, just smaller. */
  min-height: 1.5rem;
}

.app-grid-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}

.app-grid-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.125rem 0.25rem 0.125rem 0.5rem;
  font-size: 0.8125rem;
  line-height: 1.4;
  border: var(--bs-border-width) solid var(--bs-border-color);
  border-radius: 10rem;
  background-color: var(--bs-tertiary-bg);
  color: var(--bs-body-color);
}

.app-grid-chip-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.125rem;
  height: 1.125rem;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--bs-secondary-color);
  line-height: 1;
}

.app-grid-chip-remove:hover,
.app-grid-chip-remove:focus-visible {
  background-color: var(--bs-secondary-bg);
  color: var(--bs-body-color);
}

.app-grid-tools {
  margin-left: auto;
}

.app-grid-page-size-form {
  display: flex;
  align-items: center;
  gap: 0.375rem;
}

.app-grid-page-size-label {
  font-size: 0.8125rem;
  color: var(--bs-secondary-color);
  margin: 0;
}

.app-grid-page-size {
  width: auto;
}

/* ── Viewport, busy state ───────────────────────────────────────────────── */

.app-grid-viewport {
  position: relative;
}

/* Dim rather than blank. The rows on screen were true a moment ago and are
   almost always the rows about to come back; replacing them with a spinner
   loses the reader's place for the sake of admitting we are fetching. Held
   above 0.55 because the point is still to be readable - this is "settling",
   not "gone". */
.app-grid-loading .app-grid-scroll {
  opacity: 0.55;
  transition: opacity 120ms ease-out;
  pointer-events: none;
}

/* A live region being refilled by a live link (Manage Roster's tabs,
   2026-10-14): dimmed the same way, for the same reason - what is on screen
   stays readable until the answer replaces it. */
[data-app-live].app-live-loading {
  opacity: 0.55;
  transition: opacity 120ms ease-out;
  pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
  [data-app-live].app-live-loading {
    transition: none;
  }
}

.app-grid-busy {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 4rem;
  /* Above the dimmed table, far below .act-as-banner (1080) and Bootstrap's
     modal backdrop (1050). */
  z-index: 2;
  pointer-events: none;
}

.app-grid-busy[hidden] {
  display: none;
}

.app-grid-busy .spinner-border {
  color: var(--bs-secondary-color);
}

/* ── Sticky header ──────────────────────────────────────────────────────── */

/* Opt-in per grid: below about a screenful of rows a pinned header is just a
   row that will not scroll. Needs a background of its own - a transparent
   sticky cell paints the rows sliding underneath it. */
.app-grid-sticky .app-grid-scroll {
  max-height: 70vh;
  overflow-y: auto;
}

.app-grid-sticky thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background-color: var(--bs-body-bg);
  /* box-shadow rather than border-bottom: a sticky cell's own border scrolls
     away with the border-collapse model, which leaves the header floating
     over the rows with nothing separating them. */
  box-shadow: inset 0 -1px 0 var(--bs-border-color);
}

/* ── Frozen columns (2026-10-14) ────────────────────────────────────────────
   <app-column sticky="start|end">: the column stays put while the table scrolls
   sideways - Manage Roster's team on the left and its buttons on the right,
   with the money and contact columns scrolling between them. The cells keep
   Bootstrap's own opaque table background, so what slides underneath is
   hidden, row states (hover, table-*) still show, and a row dimmed with
   opacity fades as one layer. app-grid.js stacks a second frozen column on
   the same side beside the first and toggles the edge shadows. */
.app-grid .app-grid-sticky-start,
.app-grid .app-grid-sticky-end {
  position: sticky;
  z-index: 1;
}

.app-grid .app-grid-sticky-start { left: 0; }
.app-grid .app-grid-sticky-end { right: 0; }

/* The corner: a frozen header cell over both the frozen body cells and, on a
   grid with a pinned header, the header cells scrolling under it. */
.app-grid thead .app-grid-sticky-start,
.app-grid thead .app-grid-sticky-end {
  z-index: 3;
}

/* An open menu in a frozen cell - Manage Roster's More - paints above the
   frozen cells of the rows below it, which would otherwise cover it: each
   frozen cell is its own stacking layer, and later rows paint on top. */
.app-grid .app-grid-sticky-start:has(.show),
.app-grid .app-grid-sticky-end:has(.show) {
  z-index: 4;
}

/* A soft edge where columns slide under, only while there is something under
   it - a permanent line would say "more this way" when there is none. Drawn
   on the innermost frozen cell of each side. */
.app-grid .app-grid-sticky-start::after,
.app-grid .app-grid-sticky-end::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  width: 10px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 120ms ease-out;
}

.app-grid .app-grid-sticky-start::after {
  right: -10px;
  background: linear-gradient(to right, rgba(0, 0, 0, 0.14), rgba(0, 0, 0, 0));
}

.app-grid .app-grid-sticky-end::after {
  left: -10px;
  background: linear-gradient(to left, rgba(0, 0, 0, 0.14), rgba(0, 0, 0, 0));
}

[data-bs-theme="dark"] .app-grid .app-grid-sticky-start::after {
  background: linear-gradient(to right, rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0));
}

[data-bs-theme="dark"] .app-grid .app-grid-sticky-end::after {
  background: linear-gradient(to left, rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0));
}

.app-grid-scrolled-start .app-grid-sticky-start:not(:has(+ .app-grid-sticky-start))::after,
.app-grid-scrolled-end .app-grid-sticky-end:not(.app-grid-sticky-end + .app-grid-sticky-end)::after {
  opacity: 1;
}

@media (prefers-reduced-motion: reduce) {
  .app-grid .app-grid-sticky-start::after,
  .app-grid .app-grid-sticky-end::after {
    transition: none;
  }
}

/* ── Sortable headers ───────────────────────────────────────────────────── */

.app-grid-sort-link {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  color: inherit;
  text-decoration: none;
  white-space: nowrap;
}

.app-grid-sort-link:hover {
  color: var(--bs-link-hover-color);
}

/* The unsorted arrows sit at low opacity so a row of eight headers does not
   read as eight competing controls, then come up on hover and stay up on the
   column actually in force. */
.app-grid-sort-icon {
  font-size: 0.75em;
  opacity: 0.35;
}

.app-grid-sort-link:hover .app-grid-sort-icon {
  opacity: 0.75;
}

.app-grid-sorted .app-grid-sort-icon {
  opacity: 1;
  color: var(--bs-link-color);
}

/* ── Empty state ────────────────────────────────────────────────────────── */

/* A panel, not a <td colspan> row. An empty table with headers still reads as
   a table that is loading; a centred panel with an icon and a sentence reads
   as an answer. It replaces the table rather than sitting under it - the
   tag helper hides one when it shows the other. */
.app-grid-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 2.5rem 1rem;
  text-align: center;
  border: var(--bs-border-width) dashed var(--bs-border-color);
  border-radius: var(--bs-border-radius);
  background-color: var(--bs-tertiary-bg);
  color: var(--bs-secondary-color);
}

.app-grid-empty[hidden] {
  display: none;
}

.app-grid-empty-icon {
  font-size: 1.75rem;
  opacity: 0.6;
}

.app-grid-empty-message {
  margin: 0;
  max-width: 45ch;
}

/* When the empty state is showing there is nothing to page through, so the
   table and the pager both go. Done in CSS rather than JS so the server-
   rendered page is already correct before any script runs.

   CHILD COMBINATORS, NOT DESCENDANTS (2026-11-03). A grid can hold another
   grid - My District opens an organization in place, and each of its
   programs brings a teams grid. With `:has(.app-grid-empty...)` and a
   descendant `.app-grid-scroll`, a program with no teams made the OUTER grid
   match through the nested "No teams yet" panel and hide its own table: a
   district contact's 27 organizations vanished, and because the open row is
   reopened on load, Back did it again. Only the grid's own panel (a direct
   child) counts, and only its own table (inside its own viewport) and pager
   (the one direct child that is not the viewport) go. */
.app-grid:has(> .app-grid-empty:not([hidden])) > .app-grid-viewport > .app-grid-scroll,
.app-grid:has(> .app-grid-empty:not([hidden])) > :not(.app-grid-viewport) .pagination {
  display: none;
}

/* ── Row highlight after a save ─────────────────────────────────────────── */

/* The row you just edited, called out for a moment after the grid repaints.
   Without it a modal save closes onto a table that looks identical, and the
   only way to confirm the change landed is to find the row and read it.

   Fades rather than blinks, and only once: a persistent highlight becomes a
   second selection state nobody asked for. */
.app-grid-row-flash > td,
.app-grid-row-flash > th {
  animation: app-grid-row-flash 2.4s ease-out;
}

@keyframes app-grid-row-flash {
  0%, 25% { background-color: var(--bs-warning-bg-subtle); }
  100% { background-color: transparent; }
}

/* Respect the OS setting. Someone who has asked for less motion has usually
   asked because motion is a problem, not a preference - so the highlight
   becomes a static tint that simply disappears when the class is removed. */
@media (prefers-reduced-motion: reduce) {
  .app-grid-row-flash > td,
  .app-grid-row-flash > th {
    animation: none;
    background-color: var(--bs-warning-bg-subtle);
  }

  .app-grid-loading .app-grid-scroll {
    transition: none;
  }
}

/* ── Modal ──────────────────────────────────────────────────────────────── */

.app-modal-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 8rem;
  color: var(--bs-secondary-color);
}

/* While a save is in flight the form stays visible and readable but stops
   accepting input - the same reasoning as the grid's dim. The buttons are
   disabled in JS as well; this covers the rest of the form. */
.app-modal-saving .modal-body {
  opacity: 0.6;
  pointer-events: none;
}

/* ── Toolbar slot ───────────────────────────────────────────────────────── */

/* The screen's own controls, kept together and separated from the component's
   by a hairline rather than by spacing alone - "New award" and "Rows 25" are
   different kinds of control and reading as one group makes both harder to
   find. */
.app-grid-toolbar-slot {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  padding-right: 0.625rem;
  margin-right: 0.25rem;
  border-right: var(--bs-border-width) solid var(--bs-border-color);
}

.app-grid-toolbar-slot:last-child {
  border-right: 0;
  padding-right: 0;
  margin-right: 0;
}

.app-grid-tools {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: auto;
}

/* ── Selection ──────────────────────────────────────────────────────────── */

.app-grid-select-cell {
  width: 1%;
  padding-right: 0;
}

/* The bar that appears once rows are ticked. Accent-tinted rather than plain,
   because it is a mode: things that happen while it is open apply to a subset
   of the table rather than to a row you clicked. */
.app-grid-bulk {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  padding: 0.5rem 0.75rem;
  border: var(--bs-border-width) solid var(--bs-primary-border-subtle);
  border-radius: var(--bs-border-radius);
  background-color: var(--bs-primary-bg-subtle);
  color: var(--bs-emphasis-color);
}

.app-grid-bulk[hidden] {
  display: none;
}

.app-grid-bulk-count {
  font-size: 0.875rem;
  font-weight: 600;
}

.app-grid-bulk-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.375rem;
  margin-left: auto;
}

/* ── Totals ─────────────────────────────────────────────────────────────── */

/* A total is a different kind of number from the ones above it, so it gets a
   rule and a weight rather than just sitting at the bottom of the column. */
.app-grid-totals td {
  border-top: 2px solid var(--bs-border-color);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* Pinned to the bottom of a scrolling grid for the same reason the header is
   pinned to the top: a total you have to scroll to is a total you do not read. */
.app-grid-sticky .app-grid-totals td {
  position: sticky;
  bottom: 0;
  z-index: 1;
  background-color: var(--bs-body-bg);
  box-shadow: inset 0 2px 0 var(--bs-border-color);
  border-top: 0;
}

/* Digits that line up, wherever a column is right-aligned or summed. */
.app-grid td.text-end,
.app-grid th.text-end {
  font-variant-numeric: tabular-nums;
}

/* ── Small screens ──────────────────────────────────────────────────────── */

@media (max-width: 575.98px) {
  /* The rows-per-page control stops being pushed to the right once the
     toolbar has wrapped, otherwise it lands alone on a line of its own. */
  .app-grid-tools {
    margin-left: 0;
  }

  .app-grid-toolbar-slot {
    border-right: 0;
    padding-right: 0;
    margin-right: 0;
  }

  .app-grid-bulk-actions {
    margin-left: 0;
  }

  .app-grid-empty {
    padding: 1.5rem 0.75rem;
  }
}

/* ── Card layout on a phone ─────────────────────────────────────────────────
   A seven-column table on a 375px screen is a table you scroll sideways, and
   the heading you need has always just gone off the left edge. Below the md
   breakpoint each row becomes a card and every cell carries its own heading,
   read from the data-label the component puts there - which it can only do
   because it renders the cells.

   Opt out per grid with responsive="table" when the columns really are meant
   to be compared across rows: a matrix, a report somebody reads in columns.

   fee-selection.css MIRRORS THESE RULES for the selectable fee list, which is
   deliberately not an <app-grid> (every row is an input in one form) and so
   cannot inherit them. The two should read as one system on a phone - if you
   change the shape here, look there. */
@media (max-width: 767.98px) {
  .app-grid-cards thead,
  .app-grid-cards .app-grid-totals {
    /* clip, not display:none - a display:none header is removed from the
       accessibility tree, and the cells below still reference it. */
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  .app-grid-cards,
  .app-grid-cards tbody,
  .app-grid-cards tr,
  .app-grid-cards td {
    display: block;
    width: auto;
  }

  .app-grid-cards tr {
    padding: 0.75rem 0.875rem;
    margin-bottom: 0.625rem;
    border: var(--bs-border-width) solid var(--bs-border-color);
    border-radius: var(--bs-border-radius);
    background-color: var(--bs-body-bg);
  }

  .app-grid-cards td {
    display: flex;
    gap: 0.75rem;
    align-items: baseline;
    justify-content: space-between;
    padding: 0.1875rem 0;
    border: 0;
    /* Alignment is a column idea. Down a card everything reads left. */
    text-align: left !important;
  }

  .app-grid-cards td[data-label]::before {
    content: attr(data-label);
    flex: 0 0 40%;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--bs-secondary-color);
  }

  /* A cell with no heading - the actions column - spans the card instead of
     being squeezed into the value half, and gets a rule above it so the
     buttons read as the end of the card rather than another field. */
  .app-grid-cards td:not([data-label]) {
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 0.375rem;
    margin-top: 0.5rem;
    padding-top: 0.625rem;
    border-top: var(--bs-border-width) solid var(--bs-border-color);
  }

  /* An empty cell would otherwise render as a lone heading with nothing after
     it, which reads as missing data rather than as "not applicable here". */
  .app-grid-cards td:empty {
    display: none;
  }

  .app-grid-cards .app-grid-select-cell {
    justify-content: flex-start;
    padding-bottom: 0.375rem;
  }

  /* The pinned header has nothing to pin to once rows are cards, and a
     max-height would trap the cards in a short scroller inside the page. */
  .app-grid-sticky .app-grid-scroll {
    max-height: none;
    overflow-y: visible;
  }

  /* Nor do frozen columns: a card does not scroll sideways. !important over
     the offsets app-grid.js writes inline for the table layout. */
  .app-grid-cards .app-grid-sticky-start,
  .app-grid-cards .app-grid-sticky-end {
    position: static;
    left: auto !important;
    right: auto !important;
  }

  .app-grid-cards .app-grid-sticky-start::after,
  .app-grid-cards .app-grid-sticky-end::after {
    display: none;
  }
}

/* ── Header slot ────────────────────────────────────────────────────────────
   Anything a view writes between the <app-grid> tags that is not a column: a
   band of summary tiles, a filter-aware download link. It sits INSIDE the
   swapped region on purpose, so those totals are re-rendered with the rows
   rather than going stale the moment somebody filters. */
.app-grid-header {
  margin-bottom: 0.75rem;
}

.app-grid-header:empty {
  display: none;
}

/* ── The house table look ───────────────────────────────────────────────────
   One appearance for every list in the app. Before this, each grid wore
   whatever classes its hand-written table had - ten combinations across
   thirty-nine grids - so moving between two admin screens meant re-reading
   what a table looked like.

   Everything here is scoped to .app-grid, so nothing leaks onto the tables
   that are deliberately NOT grids (a confirmation summary, a facts rail). */

/* The table fills its scroll box; the gap below is the pager's own mt-3.
   Bootstrap's .table carries margin-bottom: 1rem, which stacked with that and
   was the reason several screens had reached for mb-0 and mb-4. */
.app-grid table {
  margin-bottom: 0;
}

/* Header: separated by weight and colour rather than by a rule box. Small,
   semibold and secondary-toned so it reads as a label for the column instead
   of competing with the first row of data.

   NOT uppercase. It is the usual move for a data-grid header and it is wrong
   here - these headings are multi-word ("Registration Start", "Advances?"),
   and capitals cost more legibility on those than they buy in formality. */
.app-grid thead th {
  background-color: var(--bs-tertiary-bg);
  color: var(--bs-secondary-color);
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
  border-bottom: var(--bs-border-width) solid var(--bs-border-color);
}

/* A sortable header is a control, so it gets the body colour - the muted tone
   above is for labels you cannot act on, and applying it to a link makes the
   whole row of headers look disabled. */
.app-grid thead th.app-grid-sortable .app-grid-sort-link {
  color: var(--bs-body-color);
}

/* Horizontal hairlines only. Bootstrap draws a row border via --bs-table-*;
   this keeps it and makes sure no vertical rule survives a screen that used to
   ask for table-bordered. */
.app-grid table > :not(caption) > * > * {
  border-left: 0;
  border-right: 0;
}

/* DO NOT ADD `overflow-wrap: anywhere` TO THESE CELLS. It was here for an
   hour on 2026-10-01, to stop a QA team named with hundreds of digits of pi
   making the Teams grid's Team column 7,755px wide - and it did, by telling
   the browser every cell could shrink to one character. The browser then
   squeezed the text columns to keep the action buttons on one row and broke
   "Middle School" and "eventpartner@example.com" mid-word; Chris: "they are
   smushed now". `break-word` would not have helped: it leaves min-content
   alone, so the long word still sets the column. CSS has no "break only an
   absurd word"; the table overflowing sideways for one junk record is the
   better failure. If a real name ever does this, fix the name. */

/* Rows breathe a little more than table-sm alone gives, because these cells
   routinely stack a link over a muted sub-line. */
.app-grid tbody td {
  padding-top: 0.45rem;
  padding-bottom: 0.45rem;
}

/* The last row should not draw a line into the gap above the pager - or, on a
   grid with totals, into the totals rule that already separates them. */
.app-grid tbody tr:last-child > td {
  border-bottom: 0;
}

/* Buttons inside a row sit on one line and keep their own spacing without each
   screen adding a wrapper for it. */
.app-grid tbody td .btn + .btn,
.app-grid tbody td .btn + form,
.app-grid tbody td form + form,
.app-grid tbody td form + .btn {
  margin-left: 0.25rem;
}

.app-grid tbody td form.d-inline,
.app-grid tbody td form {
  display: inline-block;
}

/* The sticky header has to paint over the rows sliding under it, so it takes
   the same ground as the header above rather than the body's. */
.app-grid-sticky thead th {
  background-color: var(--bs-tertiary-bg);
}

/* ── Tree mode ─────────────────────────────────────────────────────────
   <app-grid tree="true"> indents the first cell by depth and puts a
   disclosure chevron in front of it. */

/* The indent is a padding on an inline-flex lead rather than a margin on the
   cell, so the chevron and the value stay on one baseline and the value does
   not wrap underneath the chevron on a narrow column. --app-grid-depth is
   stamped per row by the tag helper; the step lives here with the rest of the
   look. */
.app-grid-tree-lead {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding-left: calc(var(--app-grid-depth, 0) * 1.25rem);
}

/* Sized to match the chevron button so a leaf's text lines up with a branch's
   text at the same depth. Without it every leaf sits a chevron-width to the
   left and the indent stops reading as depth. */
.app-grid-tree-toggle,
.app-grid-tree-toggle-spacer {
  display: inline-block;
  width: 1.25rem;
  min-width: 1.25rem;
  text-align: left;
}

/* Muted rather than link-coloured: there is one of these on most rows, and a
   column of blue chevrons competes with the real links in the row. It takes
   the body colour on hover so it still answers a pointer. A bare chevron,
   not one of the library's buttons (2026-10-18), so it resets the browser's
   button chrome itself - it borrowed btn btn-link p-0 for that before. */
.app-grid-tree-toggle {
  color: var(--bs-secondary-color);
  text-decoration: none;
  line-height: 1;
  background: none;
  border: 0;
  padding: 0;
  font-size: 0.875rem;
  cursor: pointer;
}

.app-grid-tree-toggle:hover,
.app-grid-tree-toggle:focus-visible {
  color: var(--bs-body-color);
}

/* The ancestor path is for cards only. On the table the indent already says
   it, and a breadcrumb on every row would be noise beside it. */
.app-grid-tree-path,
.app-grid-tree-count {
  display: none;
}

/* ── Tree mode on a phone ───────────────────────────────────────────────
   THE HARD CASE, AND THE FIRST VERSION GOT IT WRONG. A card is a block of
   its own, so an indent has nowhere to go - the first attempt simply zeroed
   it, on the reasoning that width is the scarce thing at this breakpoint.
   The result was 21 identical cards with nothing to say that Dallas Metro
   sits three levels inside South Central. The structure was not compressed,
   it was deleted.

   So depth is carried three ways instead, none of which costs much width:
   a stated ancestor path, a coloured rule down the left edge, and a small
   step per level that stops growing after a few. */
@media (max-width: 767.98px) {
  /* THE CELL HAS TO WRAP, AND FORGETTING THIS DELETED THE NAME.
     Card cells are display:flex with the default flex-wrap:nowrap, so a
     flex-basis:100% path in there cannot take its own line - it takes the
     whole line, and the Name label and value get squeezed to zero and
     pushed out past the right edge. On screen: a nested card showing its
     path, then Type and Boundary, and no name at all.

     Scoped to the cell the tree actually renders into rather than to every
     card cell, because wrapping the others would reflow grids that have
     nothing to do with trees.

     BY CLASS, NOT BY POSITION, and that is a bug fix. This was
     `td:first-child`, which was the tree's cell right up until the Regions
     screen gained selectable="true" - then the tick box became the first
     cell, this rule stopped matching the cell it was written for, and the
     ancestor path went back to being unwrappable. On a 375px screen that
     pushed the path, the collapse chevron and the child count off the right
     edge, so a branch could not be collapsed on a phone at all. The tag
     helper stamps app-grid-tree-cell on the one cell that holds them. */
  .app-grid-cards .app-grid-tree-cell {
    flex-wrap: wrap;
  }

  /* A full-width line at the top of the card. order:-1 lifts it above the
     Name label/value pair inside the same flex cell, so it reads as a
     heading for the card rather than as another field. */
  .app-grid-cards .app-grid-tree-path {
    display: block;
    flex: 0 0 100%;
    order: -1;
    margin-bottom: 0.125rem;
    font-size: 0.75rem;
    line-height: 1.3;
    color: var(--bs-secondary-color);
    /* A four-level path on a 375px screen wraps to three lines and pushes
       the name off the first screenful. One line, clipped. */
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* The left rule is what makes a nested card read as nested at a glance,
     before anything is read. Applied to the row, not the cell, so it runs
     the full height of the card.

     Depth is capped at 4 steps: past that the indent eats more width than
     the structure is worth on a phone, and the path line is carrying the
     exact depth anyway. */
  .app-grid-cards tr[data-app-grid-depth]:not([data-app-grid-depth="0"]) {
    border-left: 3px solid var(--bs-primary-border-subtle);
    margin-left: calc(min(var(--app-grid-depth, 0), 4) * 0.5rem);
  }

  /* --app-grid-depth is stamped on the lead span, not the row, so the row
     cannot read it - restate it per level. Four rules, because four is the
     cap above. */
  .app-grid-cards tr[data-app-grid-depth="1"] { --app-grid-depth: 1; }
  .app-grid-cards tr[data-app-grid-depth="2"] { --app-grid-depth: 2; }
  .app-grid-cards tr[data-app-grid-depth="3"] { --app-grid-depth: 3; }
  .app-grid-cards tr[data-app-grid-depth="4"] { --app-grid-depth: 4; }

  /* The in-cell indent goes: the left rule and the path have taken over,
     and keeping both would indent twice.

     margin-left:auto groups the chevron and count with the value instead of
     leaving them stranded mid-row. The cell is justify-content:space-between
     over three items - label, this, the name text - so without it the free
     space lands on both sides of the lead and reads as
     "Name  ⌄ 1     North Texas". Absorbing the space before it gives
     "Name        ⌄ 1 North Texas", which is one control beside the thing it
     acts on. */
  .app-grid-cards .app-grid-tree-lead {
    padding-left: 0;
    margin-left: auto;
  }

  /* A leaf needs no chevron-width placeholder once nothing is aligning to a
     column - and removing it buys back a chevron of width on every card. */
  .app-grid-cards .app-grid-tree-toggle-spacer {
    display: none;
  }

  /* 44px: a chevron sized for a pointer is not a tap target. Ordered after
     the count so the pair reads "3 ›" as one control. */
  .app-grid-cards .app-grid-tree-toggle {
    width: 2.75rem;
    min-width: 2.75rem;
    height: 2.75rem;
    margin: -0.75rem -0.5rem -0.75rem 0;
    text-align: center;
  }

  /* The number a collapsed card would otherwise not have. Not a Bootstrap
     badge: this sits inside a flex cell next to the value and a pill would
     read as a status, which it is not - it is a count of what is hidden. */
  .app-grid-cards .app-grid-tree-count {
    display: inline-block;
    min-width: 1.5rem;
    padding: 0 0.375rem;
    border-radius: var(--bs-border-radius-pill);
    background-color: var(--bs-tertiary-bg);
    color: var(--bs-secondary-color);
    font-size: 0.75rem;
    font-variant-numeric: tabular-nums;
    text-align: center;
  }
}

/* ── Row actions: one line of buttons ───────────────────────────────

   Every grid's row actions sit in <div class="app-row-actions"> (2026-10-18).
   Chris: "can we ensure the buttons on these grids look clean and nice? I've
   seen this on several screens now and it doesn't look clean and
   professional" - beside My Registrations at a laptop width, View Order on one
   line and Cancel under it, and the offer row's Accept and Decline side by
   side, which was the look he wanted. The cells had been loose inline
   content: a link, then a form, wrapping wherever the column was squeezed.
   Over every crawled page, My Registrations, Grants, RSM approvals and Manage
   Roster stacked at 1024; six screens spaced their buttons six ways.

   One line on a laptop, never wrapped: the column takes the width of its
   buttons, and the grid scrolls sideways before a row doubles in height. A
   form is a flex item like a link. A <details> editor (Grants, EP requests)
   opens under its own button, and the row's other buttons stay at the top
   rather than centring on the open panel. What explains a button (why Approve
   is off) is an <app-icon> in the row with its words on hover - Chris: "for
   anything like this, the icon should have the text for an on hover".

   On a phone card the row may wrap - five buttons do not fit 340px - at the
   same gap the card's actions strip already used. */
.app-row-actions {
  display: inline-flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.375rem;
  white-space: nowrap;
  vertical-align: middle;
  min-width: 0;
}

.app-row-actions > form {
  margin: 0;
}

.app-row-actions:has(> details[open]) {
  align-items: flex-start;
}

@media (max-width: 767.98px) {
  .app-row-actions {
    flex-wrap: wrap;
  }
}

/* The icon toolbar - Season Fee Payments (2026-09-10), the PO queue: the same
   row with the words in tooltips. Tight padding and line-height 1 so a row of
   them is no taller than the text beside it - the stacked labelled buttons
   this replaced made every row three lines. */
.app-row-icons {
  gap: 0.25rem;
}

.app-row-icons .btn {
  padding: 0.2rem 0.5rem;
  line-height: 1;
}

.app-row-icons .btn .bi {
  font-size: 1rem;
  vertical-align: -0.125em;
}

/* ICON-ONLY BUTTONS GET THEIR WORDS BACK IN THE STACKED LAYOUT (2026-10-29,
   UX review): a phone has no hover, so a row of bare icons (a pin, arrows) was
   a guessing game. The word is the button's own aria-label, so it is printed
   from there and cannot drift. Opt in per row with app-row-icons-words; the
   house rule (busy rows are icon-only, word on hover) still holds on desktop. */
@media (max-width: 767.98px) {
  .app-row-icons-words .btn.app-btn-icon-only::after {
    content: attr(aria-label);
    margin-inline-start: 0.4rem;
    font-size: 0.875rem;
  }
}

/* ── Sticky actions column ─────────────────────────────────────────────── */

/* <app-grid sticky-actions="true"> - the Payments desk's pinned Actions column
   (2026-10-16) - is shorthand for sticky="end" on the last column since
   2026-10-17, drawn by the Frozen columns rules near the top of this file. It
   had its own td:last-child rule here, built on a parallel branch, which
   painted the body background over the row's own state and kept its shadow
   when nothing was under it. One mechanism, one look. */
