/* record-row.css
 * Container-query driven record row component.
 *
 * Compact mode (default, container < 640px):
 *   Stacked card — tap-area link covers content, badge on right, swipe-left reveals action strip.
 *
 * Normal mode (container ≥ 640px):
 *   Horizontal grid row — each slot is a column, inline actions at end.
 *
 * DOM:
 *   .record-list-wrap                   ← container-type host, set --record-cols here
 *     .record-row.record-row--header    ← column headers (normal mode only)
 *       .record-row__inner
 *         .record-row__primary
 *         .record-row__meta-1
 *         .record-row__meta-2
 *         .record-row__badge
 *         .record-row__actions
 *     .record-row                       ← data rows
 *       .record-row__inner
 *         a.record-row__tap-area        ← link wrapping primary/meta-1/meta-2 (becomes display:contents in normal mode)
 *           .record-row__primary
 *           .record-row__meta-1
 *           .record-row__meta-2
 *         .record-row__badge
 *         .record-row__actions          ← inline buttons (normal mode only)
 *       .record-row__action-strip       ← swipe-revealed buttons (compact only, omit when no swipe needed)
 */

/* ── Container ──────────────────────────────────────────────────────────────── */

/* ── Column widths ──────────────────────────────────────────────────────────────
 * Every list builds its --record-cols from these, by what a column HOLDS, so the same kind of
 * column is the same width on every page. They used to be hand-tuned per page: at one list width
 * a date column was anywhere from 170 to 204px, Status from 49 to 198. Text columns share what is
 * left in fixed proportions; everything else is fixed, sized to its widest real content
 * (measured 2026-10-03 against the full dev data set). Fixed means "up to": minmax(0, N) takes
 * its full N whenever there is room — every desktop width — and gives way rather than pushing
 * the list past the screen when there is not (the stacked phone layout keeps the same tracks).
 *   --col-title   the row's identifier (auction/lot, invoice, ticket, customer, code)
 *   --col-text    a secondary text column (customer, details, location, package)
 *   --col-long    a long text column (description, message, partner detail)
 *   --col-date    a date, with an optional second line ("Auction 6 Oct 2026")
 *   --col-number  money or a count, right-aligned
 *   --col-status  the status pill stack
 *   --col-menu    the ⋯ menu or a chevron
 *   --col-button  one inline button (Cancel, Download PDF)
 *   --col-buttons two inline buttons (Edit · Delete)
 *   --col-icons   two icon buttons (✎ · ✕): 2 × 44px touch targets and their gap
 */
.record-list-wrap {
  --col-title: minmax(0, 1.6fr);
  --col-text: minmax(0, 1.2fr);
  --col-long: minmax(0, 2.4fr);
  --col-date: minmax(0, 132px);
  --col-number: minmax(0, 96px);
  --col-status: minmax(0, 200px);
  --col-menu: minmax(0, 40px);
  --col-button: minmax(0, 112px);
  --col-buttons: minmax(0, 160px);
  --col-icons: minmax(0, 96px);
  --record-cols: var(--col-title) var(--col-text) var(--col-date) var(--col-status) var(--col-menu);
  container-type: inline-size;
  container-name: record-list;
  width: 100%;
  /* The wrap owns the shared column tracks at ALL sizes. This cannot live inside
     an @container rule: a query container can't style itself (queries match
     ancestor containers only) — grid-less wrap ⇒ subgrid rows collapse to a
     single stacked column. Every row spans the full track list, so compact mode
     renders exactly as a block stack; only the ≥640px subgrid rules below make
     the tracks visible. */
  display: grid;
  grid-template-columns: var(--record-cols);
  /* Each direct record creates an implicit row. Size those tracks from their
     content so a full result set overflows the bounded desktop scrollport
     instead of shrinking every row to fit. */
  grid-auto-rows: max-content;
  /* This list becomes the flex panel's scrollport on desktop. With the grid
     default of stretch, a sparse result set expands its implicit row tracks
     to fill that tall panel (one report made both its header and data row
     hundreds of pixels high). Pack every result at the top at natural height. */
  align-content: start;
  column-gap: var(--space-md);
}

.record-list-wrap > .record-row {
  grid-column: 1 / -1;
}

/* The fixed columns step down with the screen so the text columns keep a usable share. Viewport
   queries, not container ones: the tokens live on the list itself, and a container cannot query
   its own width. At 1024 the full sizes left Auction/Lot and Customer 71px and 53px. Status keeps
   room for the widest pill ("Inspection in progress", 147px), dates keep both lines whole, and
   the ⋯ menu never shrinks below its button. */
@media (max-width: 1279px) {
  .record-list-wrap {
    --col-date: minmax(0, 112px);
    --col-number: minmax(0, 84px);
    --col-status: minmax(0, 168px);
  }
}
@media (max-width: 1099px) {
  .record-list-wrap {
    --col-number: minmax(0, 72px);
    --col-status: minmax(0, 152px);
  }
}

/* ── Compact mode defaults ──────────────────────────────────────────────────── */

/* Rows touch: the space between them lives inside each row (the inner pane's
   padding), never as a margin outside it. A margin sat outside the hover tint, so a
   hovered row showed a 4px untinted strip under the divider above it — the band
   looked misaligned instead of filling divider to divider. */
.record-row {
  position: relative;
  overflow: hidden;
  border-bottom: 1px solid var(--color-border-light);
}

.record-row:last-child {
  border-bottom: 0;
}

.record-row--header {
  display: none;
}

/* Sliding inner pane (transform driven by swipe JS) */
.record-row__inner {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0 var(--space-md);
  min-height: 82px;
  /* +2px top and bottom: the 4px that used to be a margin between rows. */
  padding: calc(var(--space-md) + 2px) var(--space-md);
  /* Keep data rows transparent so the containing panel remains the single
     glass surface. Borders and interaction states provide row separation. */
  background: transparent;
  transform: translateX(0);
  transition: transform 0.22s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  will-change: transform;
  position: relative;
  z-index: 1;
  align-items: center;
}

/* Hover tint — matches the side-nav link hover (subtle brand-blue wash).
   Applies in both compact and normal modes; pointer devices only. */
@media (hover: hover) {
  .record-row:not(.record-row--header):not(.record-row--static):hover .record-row__inner {
    background: color-mix(in srgb, var(--color-primary) 8%, var(--field-fill-hover));
  }
}

/* Inert rows (e.g. an already-read notification) are not navigable — suppress
   the clickable affordances so they read as static, not tappable. */
.record-row--static,
.record-row--static .record-row__tap-area {
  cursor: default;
}

/* ── Rows whose content contains its own link ───────────────────────────────────
 *
 * A row normally wraps its content in `a.record-row__tap-area`. That cannot work when the content
 * holds a link of its own — the next-action chip on the admin request queue goes somewhere
 * different from the row — because nested anchors are invalid HTML: the parser closes the outer
 * one at the inner tag and re-parents everything after it. The tap area then measures zero high
 * with no children, and primary/meta/badge scatter across the grid. It looked like a CSS bug and
 * was not; only rows that actually rendered an inner link were affected, which is why cancelled
 * rows on the same list looked right.
 *
 * So those rows keep a plain div for layout and put the row link behind the content instead.
 * Anything the reader can click sits above it — see the z-index pairing below. Opt-in: the other
 * lists wrap their content and are untouched.
 */
.record-row__tap-link {
  position: absolute;
  inset: 0;
  z-index: 1;
  /* Announced by aria-label; nothing to show. */
  font-size: 0;
}

/* Above the stretched link, so their own href wins the click. */
.record-row__inner .next-action,
.record-row__inner .record-row__badge,
.record-row__inner .record-row__actions {
  position: relative;
  z-index: 2;
}

/* Content link — spans left column, wraps primary/meta-1/meta-2 */
.record-row__tap-area {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  align-self: center;
  color: inherit;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}

.record-row__tap-area:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}

.record-row__primary {
  font-size: var(--mobile-dashboard-row-title-size, var(--font-size-base));
  font-weight: var(--font-weight-bold);
  color: var(--color-text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.record-row__meta-1 {
  font-size: var(--mobile-dashboard-meta-size, var(--font-size-sm));
  color: var(--color-text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.record-row__meta-2 {
  font-size: var(--mobile-dashboard-meta-size, var(--font-size-sm));
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Badge column — right side of card */
.record-row__badge {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: var(--space-2xs);
  align-self: center;
  position: relative;
  padding-right: calc(var(--space-xs) + 16px);
}

.record-row__badge .pill {
  white-space: nowrap;
}

/* Chevron navigation indicator */
.record-row__chevron {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  color: var(--color-primary);
}

.record-row__chevron svg {
  width: 16px;
  height: 16px;
}

/* Inline actions — hidden in compact mode */
.record-row__actions {
  display: none;
}

/* ── Within-block typography tokens (both modes) ───────────────────────────── */

.rr-title {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rr-sub {
  display: block;
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-regular);
  color: var(--color-text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Responsive value variants for columns that collapse into a compact summary. */
.rr-compact-only { display: none; }

/* Empty-state copy is a full sentence (often with an inline link), not a data
   value — the default nowrap-ellipsis truncation was clipping the link itself.
   Specificity/!important needed to beat both the base .rr-sub rule above and
   the higher-specificity "table mode" override further down this file. */
.record-row .rr-sub.rr-sub--wrap {
  overflow: visible !important;
  text-overflow: clip !important;
  white-space: normal !important;
}

/* Compact (card) mode: let the primary row title use up to two lines instead of
   truncating to one, so long auction/vehicle names stay readable on mobile. */
.record-row__primary .rr-title {
  white-space: normal;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

/* Normal (table) mode keeps the title on one line for grid alignment. */
/* The viewport has the final say below 640px. The row layout is chosen by a
   container query measuring .record-list-wrap, and that measurement can land
   above 640px on a phone: these rules make each row a subgrid whose cells feed
   their own max-content back into the wrap's tracks, and the wrap sits inside
   .table-wrap (overflow-x: auto), which scrolls to accommodate it rather than
   forcing it to shrink. Once that loop closes the row is wider than the screen
   and stays there. A viewport this narrow never wants the desktop track list,
   so gate the whole branch on it and let the base rules stand. */
@media (min-width: 640px) {
@container record-list (min-width: 640px) {
  .record-row:not(.record-row--header) .record-row__primary .rr-title {
    white-space: nowrap;
    display: block;
    -webkit-line-clamp: unset;
  }
}
}


/* Swipe hint — animated chevron in top-right corner of any compact row that has a slide strip */
.record-row:not(.record-row--header):has(.record-row__action-strip)::before {
  content: "";
  position: absolute;
  top: 10px;
  right: 12px;
  z-index: 2;
  width: 7px;
  height: 7px;
  border-left: 2px solid var(--color-text-tertiary);
  border-bottom: 2px solid var(--color-text-tertiary);
  transform: rotate(45deg);
  pointer-events: none;
  opacity: 0.55;
  animation: rr-swipe-hint 2.4s ease-in-out infinite;
}

@keyframes rr-swipe-hint {
  0%, 60%, 100% { translate: 0 0; }
  30% { translate: -5px 0; }
}

/* Hide hint once the strip is revealed */
.record-row--open::before {
  display: none;
}

/* Action strip — absolute right edge, revealed by swiping left.
   Hidden at rest: the row inner is translucent, so it can no longer mask the
   strip on its own. Shown only while the row is open or actively sliding.
   visibility (not display) keeps the layout box so offsetWidth still measures. */
.record-row__action-strip {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: row;
  align-items: stretch;
  z-index: 0;
  visibility: hidden;
}

.record-row--open .record-row__action-strip,
.record-row--sliding .record-row__action-strip {
  visibility: visible;
}

.record-row__action-strip form {
  display: contents;
}

.record-row__action-strip .list-btn {
  border-radius: 0;
  min-height: var(--btn-height);
  min-width: 72px;
  padding: 0 var(--space-md);
  justify-content: center;
  transform: none !important;
  box-shadow: none;
}

.record-row__action-strip .list-btn-export {
  background: var(--color-success);
  color: white;
  border-color: transparent;
}

.record-row__action-strip .list-btn-export:hover {
  background: var(--color-success);
}

/* ── Normal mode (container ≥ 640px) ────────────────────────────────────────── */

/* Viewport-gated for the reason given at the first such block above. */
@media (min-width: 640px) {
@container record-list (min-width: 640px) {

  /* Hide swipe hint — normal mode uses inline actions instead */
  .record-row:not(.record-row--header)::before {
    display: none;
  }

  /* Minimal column header row — sticky to the top of its own scrollport.
     .record-list-wrap itself (this element's direct parent) is the bounded-
     height, overflow-y:auto pane on desktop (see app.css) — the header sticks
     within that box, not the page, so top:0 is correct here, not
     --admin-nav-h: the nav offset only matters when the whole page scrolls
     past a viewport-relative sticky element. Needs a z-index above the row
     inner's own (1), and an opaque background (already true — the neutral
     tint mixes toward --color-surface, not transparent) so rows don't show
     through as they pass underneath.
     overflow:visible overrides the base .record-row rule (this element also
     carries the .record-row class): that overflow:hidden exists to clip data
     rows' swipe-reveal action strip, which headers never have, but it also
     gives a grid item an automatic minimum size of 0 — inside the now-bounded
     .record-list-wrap this squeezed the sticky header down to ~1px instead of
     the rows scrolling underneath it. */
  .record-row--header {
    display: block;
    position: sticky;
    top: 0;
    z-index: 2;
    overflow: visible;
    border-bottom: 1px solid var(--color-border-light);
  }

  .record-row--header .record-row__inner {
    display: grid;
    grid-template-columns: var(--record-cols);
    grid-template-rows: auto;
    min-height: unset;
    padding: var(--space-md);
    /* Neutral gray, not the brand-tinted convention used on panel headers — this
       band just needs to read as "header row", not draw attention to itself. */
    background: color-mix(in srgb, var(--color-text-primary) 5%, var(--color-surface));
    transform: none !important;
    transition: none;
    will-change: auto;
    align-items: center;
    gap: 0 var(--space-md);
  }

  /* Every header cell, the amount column included. It used to be left off this list and carried
     its own smaller, lighter rule, so TOTAL read differently from every header beside it. */
  .record-row--header .record-row__primary,
  .record-row--header .record-row__meta-1,
  .record-row--header .record-row__meta-2,
  .record-row--header .record-row__amount,
  .record-row--header .record-row__badge,
  .record-row--header .record-row__actions {
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-bold);
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--color-text-secondary);
    /* A heading wider than its column goes onto a second line instead of being cut mid-letter
       ("CODE · DISCOU" on an iPad mini). A single word that still does not fit is clipped, never
       overlapped: visible overflow would spill into the next header under squeeze. */
    white-space: normal;
    line-height: 1.3;
    text-wrap: balance;
    min-width: 0;
    overflow: hidden;
    text-overflow: clip;
    padding: 0;
    align-self: center;
    font-family: var(--font-family-body);
  }

  .record-row--header .record-row__badge {
    flex-direction: row;
    align-items: center;
    justify-content: flex-end;
  }

  .record-row--header .record-row__actions { display: block; }

  .record-row--header a {
    text-decoration: none;
    color: inherit;
    display: inline-flex;
    align-items: center;
    gap: 4px;
  }

  .record-row--header a:hover { color: var(--color-text-primary); }
  /* An unsorted column's arrow is empty but still took the link's gap, which showed as a stray
     space wherever text follows it ("PAYMENT  / REFUND"). */
  .record-row--header .sort-arrow:empty { display: none; }

  /* ── Data rows ── */

  /* No blanket cursor:pointer — the tap-area <a> supplies it natively, so
     target-less rows (e.g. informational notifications) keep the default
     cursor (A-V22). */
  .record-row:not(.record-row--header) {
    min-height: 64px;
    border-bottom: 1px solid var(--color-border-light);
  }

  .record-row:not(.record-row--header):last-child { border-bottom: 0; }

  .record-row:not(.record-row--header):hover .record-row__inner {
    background: color-mix(in srgb, var(--color-primary) 8%, var(--field-fill-hover));
  }

  .record-row:not(.record-row--header) .record-row__inner {
    display: grid;
    grid-template-columns: var(--record-cols);
    grid-template-rows: auto;
    /* One shared two-line rhythm across Requests, Reports, and Invoices;
       longer content can still expand the row naturally. */
    min-height: 64px;
    padding: 10px var(--space-md);
    transform: none;
    transition: transform 0.22s cubic-bezier(0.25, 0.46, 0.45, 0.94), background 0.15s ease;
    will-change: transform;
    align-items: center;
    gap: 0 var(--space-md);
  }

  /* Tap area transparent to grid — children become direct grid items */
  .record-row:not(.record-row--header) .record-row__tap-area {
    display: contents;
  }

  /* Content blocks — flex columns for title + sub stacking */
  .record-row:not(.record-row--header) .record-row__primary,
  .record-row:not(.record-row--header) .record-row__meta-1,
  .record-row:not(.record-row--header) .record-row__meta-2 {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
    align-self: center;
    overflow: hidden;
  }

  /* Title line within a block */
  .record-row:not(.record-row--header) .rr-title {
    font-size: var(--mobile-dashboard-row-title-size, var(--font-size-sm));
    font-weight: var(--font-weight-semibold);
    color: var(--color-text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.45;
  }

  /* Sub line within a block */
  .record-row:not(.record-row--header) .rr-sub {
    font-size: var(--mobile-dashboard-meta-size, var(--font-size-sm));
    font-weight: var(--font-weight-regular);
    color: var(--color-text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.45;
  }

  /* Fix #3 — column visual hierarchy */
  /* Primary block: stronger anchor */
  .record-row:not(.record-row--header) .record-row__primary .rr-title {
    font-size: var(--mobile-dashboard-card-title-size, var(--font-size-base));
    font-weight: var(--font-weight-bold);
  }

  /* Meta-1 block: de-emphasised (ID/package — supporting info) */
  .record-row:not(.record-row--header) .record-row__meta-1 .rr-title {
    font-weight: var(--font-weight-regular);
    color: var(--color-text-secondary);
  }

  /* Fix #9 — tabular numbers for amounts/dates in meta-2 */
  .record-row:not(.record-row--header) .record-row__meta-2 .rr-sub {
    font-variant-numeric: tabular-nums;
  }

  /* Badge column */
  .record-row__chevron { display: none; }

  .record-row:not(.record-row--header) .record-row__badge {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: flex-end;
    gap: var(--space-xs);
    padding: 0;
    align-self: center;
  }

  /* Two-axis rows: multiple status pills stack vertically, matching compact mode */
  .record-row:not(.record-row--header) .record-row__badge:has(.status-pill + .status-pill) {
    flex-direction: column;
    align-items: flex-end;
    gap: var(--space-2xs);
  }

  /* Cart page: badge (compact price + ⋯) is not a grid column — price lives in meta-2 */
  .cart-record-list .record-row:not(.record-row--header) .record-row__badge {
    display: none;
  }

  /* Actions column */
  .record-row:not(.record-row--header) .record-row__actions {
    display: flex;
    align-items: center;
    gap: 4px;
    align-self: center;
    flex-shrink: 0;
  }

  /* Small contextual action button (e.g. → Japan, Report) */
  .record-row__ctx-btn.list-btn {
    font-size: var(--font-size-xs);
    padding: 3px 10px;
    height: auto;
    min-height: unset;
    line-height: 1.5;
    white-space: nowrap;
    box-shadow: none;
  }

  /* ── ⋯ button (triggers slide strip in normal mode) ── */

  .record-row__overflow-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--color-text-tertiary);
    border-radius: var(--radius-button-sm);
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.15s ease, color 0.15s ease;
  }

  .record-row__overflow-btn:hover,
  .record-row__overflow-btn[aria-expanded="true"] {
    background: var(--color-component);
    color: var(--color-text-primary);
  }

  .record-row__overflow-btn:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
  }

  /* Fix #1 — keyboard focus ring (display:contents kills outline on tap-area) */
  .record-row:not(.record-row--header):focus-within .record-row__inner {
    box-shadow: inset 0 0 0 2px var(--color-primary);
  }
}
}


/* ── Number cells in a general slot ───────────────────────────────────────────────
 * Money and counts read right-aligned on every list — the amount slot does this itself; a page
 * that puts a number in a meta slot marks that cell (header and rows) with this class so it lines
 * up the same way instead of sitting left like text. Paired with var(--col-number). */
@media (min-width: 640px) {
@container record-list (min-width: 640px) {
  .record-row__cell--number {
    text-align: right;
    font-variant-numeric: tabular-nums;
  }
  .record-row--header .record-row__cell--number a { justify-content: flex-end; }
}
}

/* ── Dedicated amount/total column ───────────────────────────────────────────────
 * Desktop table view only. Hidden by default so mobile keeps the price inline in the
 * row title (rr-amt); on desktop the price moves into its own right-aligned column
 * and the inline copy is hidden. Pages opt in by adding an amount column to
 * --record-cols and a .record-row__amount cell to the header + each row. */
.record-row__amount { display: none; }

/* Viewport-gated for the reason given at the first such block above. */
@media (min-width: 640px) {
@container record-list (min-width: 640px) {
  .record-row:not(.record-row--header) .record-row__primary .rr-amt { display: none; }

  /* Right-aligned to pair with the Status column (also right-aligned app-wide) —
     numbers and status read together as the row's "right-hand" data, while the
     identifier/date columns stay left-aligned. */
  .record-row__amount {
    display: block;
    align-self: center;
    text-align: right;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
  }

  .record-row:not(.record-row--header) .record-row__amount {
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-semibold);
    color: var(--color-text-primary);
  }

}
}


/* ── One shared track list via subgrid (normal mode) ────────────────────────────
 * Each .record-row__inner is its own grid, so content-dependent track sizing
 * (the minmax(max-content, 1fr) floors on the amount/badge columns) would resolve
 * DIFFERENTLY per row and per header — desynchronizing the columns. Subgrid moves
 * track resolution up to the list wrapper: one track list computed from the header
 * AND every row together, so columns stay in lockstep at every width while the
 * content-driven floors still hold. Browsers without subgrid (Chrome <117) keep
 * the per-row grids — same layout, minor drift only under extreme squeeze. */
/* Viewport-gated for the reason given at the first such block above. */
@media (min-width: 640px) {
@container record-list (min-width: 640px) {
  @supports (grid-template-columns: subgrid) {
    .record-list-wrap .record-row,
    .record-list-wrap .record-row--header {
      display: grid;
      grid-template-columns: subgrid;
    }

    .record-list-wrap .record-row--header .record-row__inner,
    .record-list-wrap .record-row:not(.record-row--header) .record-row__inner {
      grid-column: 1 / -1;
      grid-template-columns: subgrid;
    }
  }
}
}


@media (prefers-reduced-motion: reduce) {
  .record-row__inner,
  .record-row__overflow-btn,
  .record-row:not(.record-row--header):has(.record-row__action-strip)::before {
    transition: none !important;
    animation: none !important;
  }
}

/* ── Shared compact summary row ─────────────────────────────────────────────────
 * Global compact structure for every .record-list-wrap. It covers both the
 * canonical tap-area markup and older direct-slot rows:
 *
 *   Line 1:  identifier  · $price        (price = Requests & Invoices only)
 *   Line 2:  email / supporting label
 *   Line 3:  date / compact meta
 *   Right:   status pill, vertically centred — value/date never live here.
 *
 * Block convention the markup must follow:
 *   .record-row__primary  → identifier .rr-title (price appended inline as .rr-amt)
 *   .record-row__meta-1   → email
 *   .record-row__meta-2   → date
 *
 * Compact only — normal mode (≥640px) keeps the column grid untouched. */
@container record-list (max-width: 639.98px) {
  .rr-normal-only { display: none; }
  .rr-compact-only { display: inline; }

  .record-list-wrap .record-row:not(.record-row--header) .record-row__inner {
    min-height: 62px;
    padding-block: 10px;
  }

  .record-list-wrap .record-row:not(.record-row--header) .record-row__tap-area {
    display: flex;
    flex-direction: column;
    gap: 2px;
    width: 100%;
  }

  .record-list-wrap .record-row:not(.record-row--header) .record-row__inner:not(:has(.record-row__tap-area)) {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "primary badge"
      "meta-1 badge"
      "meta-2 badge";
    row-gap: 2px;
  }

  /* Line 1 — identifier (+ inline price via .rr-amt) */
  .record-list-wrap .record-row__primary {
    min-width: 0;
  }

  .record-list-wrap .record-row__inner:not(:has(.record-row__tap-area)) > .record-row__primary {
    grid-area: primary;
  }

  /* Line 2 left — email */
  .record-list-wrap .record-row__meta-1 {
    min-width: 0;
  }

  .record-list-wrap .record-row__inner:not(:has(.record-row__tap-area)) > .record-row__meta-1 {
    grid-area: meta-1;
  }

  /* Line 3 — date / compact meta */
  .record-list-wrap .record-row__meta-2 {
    min-width: 0;
    text-align: left;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
  }

  .record-list-wrap .record-row__inner:not(:has(.record-row__tap-area)) > .record-row__meta-2 {
    grid-area: meta-2;
  }

  .record-list-wrap .record-row__inner:not(:has(.record-row__tap-area)) > .record-row__badge {
    grid-area: badge;
  }

  .record-list-wrap .record-row__primary .rr-title {
    display: block;
    white-space: nowrap;
    -webkit-line-clamp: unset;
    line-height: 1.2;
  }

  .record-list-wrap .record-row__meta-1 .rr-title,
  .record-list-wrap .record-row__meta-2 .rr-title {
    font-size: var(--mobile-dashboard-meta-size, var(--font-size-sm));
    font-weight: var(--font-weight-regular);
    color: var(--color-text-secondary);
    line-height: 1.2;
  }

  .record-list-wrap .rr-sub--desktop-only {
    display: none;
  }
}

/* Inline price/amount appended to an identifier — both compact and normal modes. */
.record-row .rr-amt {
  font-weight: var(--font-weight-semibold);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ── Column-alignment debug overlay (QA aid, no visual effect unless enabled) ──
 * Toggle from any record-row list page via the URL: ?cols=1 on, ?cols=0 off.
 * Stays on across admin pages for the browser session (record-row.js persists it).
 * Red dashed = data-row cells, blue solid = header cells; misaligned columns show
 * as edges that don't line up vertically between blue and red boxes. */
body.debug-record-cols .record-row:not(.record-row--header) :is(
  .record-row__primary, .record-row__meta-1, .record-row__meta-2,
  .record-row__amount, .record-row__badge, .record-row__actions) {
  outline: 1px dashed rgba(220, 38, 38, 0.65);
  outline-offset: -1px;
}
body.debug-record-cols .record-row--header :is(
  .record-row__primary, .record-row__meta-1, .record-row__meta-2,
  .record-row__amount, .record-row__badge, .record-row__actions) {
  outline: 1px solid rgba(37, 99, 235, 0.7);
  outline-offset: -1px;
}
body.debug-record-cols .record-list-wrap {
  outline: 1px solid rgba(22, 163, 74, 0.5);
}

/* ──────────────────────────────────────────────────────────────────────────
   Next action — what a request needs from an admin right now.

   Its own line under the lot number rather than a fourth status pill in the
   badge stack: the pills say what a request IS, this says what to DO with it,
   and stacking them made the two read as the same kind of thing. Colour is
   carried entirely by the semantic tokens, so a Website Settings theme change
   moves it with everything else.
   ────────────────────────────────────────────────────────────────────────── */
.next-action {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  margin-top: var(--space-2xs);
  padding: 2px var(--space-sm);
  border-radius: var(--radius-sm);
  font-size: var(--font-size-sm);
  font-weight: 600;
  line-height: 1.5;
  max-width: 100%;
}

/* Something is wrong and stays wrong until a person looks. */
.next-action--blocked {
  background: var(--color-error-bg);
  color: var(--color-error);
}

/* Ordinary work waiting on an admin. */
.next-action--action {
  background: var(--color-info-bg);
  color: var(--color-info);
}

/* Moving on its own, or with the customer/partner — deliberately the quietest. */
.next-action--waiting {
  background: transparent;
  color: var(--color-text-tertiary);
  padding-left: 0;
  font-weight: 500;
}

/* In the badge the next action is one of the pills. It keeps its own tone —
   a job is not a state — but takes the pills' geometry, so the stack reads as
   one set whichever it holds: "Cancelled / Refunded" and "New / Send to
   partner" are the same shape in the same place. */
.record-row__badge .next-action {
  margin-top: 0;
  padding: var(--space-2xs) calc(var(--space-sm) + var(--space-2xs));
  /* The inline chip runs at 1.5 to sit in a paragraph of row text; in the stack
     it has to match the pills' height exactly or the set looks assembled. */
  line-height: var(--line-height-tight);
  font-weight: var(--font-weight-semibold);
  text-decoration: none;
}

/* The quiet tone drops its inset elsewhere; in the stack it has to line up. */
.record-row__badge .next-action--waiting {
  padding-left: calc(var(--space-sm) + var(--space-2xs));
}

/* ── Queue view switch + the counter for work that has no request row ── */
.request-queue-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
}

.request-queue-tabs {
  display: inline-flex;
  gap: var(--space-2xs);
  padding: var(--space-2xs);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-md);
  background: var(--color-surface);
}

.queue-tab {
  padding: var(--space-xs) var(--space-md);
  border-radius: var(--radius-sm);
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--color-text-secondary);
  text-decoration: none;
  white-space: nowrap;
}

.queue-tab:hover { color: var(--color-text-primary); }

.queue-tab.is-active {
  background: var(--color-primary);
  color: var(--color-text-inverse);
}

.queue-orphan-warning {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-sm);
  background: var(--color-warning-bg);
  color: var(--color-warning);
  font-size: var(--font-size-sm);
  font-weight: 600;
  text-decoration: none;
}

.queue-orphan-warning:hover { text-decoration: underline; }

/* Undelivered-refund batch — money owed back, so it sits with the queue switch rather than
   inside the filter card where it could be scrolled past. */
.queue-refund-batch {
  display: inline-flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-xs) var(--space-xs) var(--space-xs) var(--space-md);
  border: 1px solid color-mix(in srgb, var(--color-error) 30%, var(--color-border));
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--color-error-bg) 70%, var(--color-surface));
}

.queue-refund-batch__text {
  display: flex;
  flex-direction: column;
  line-height: 1.35;
}

.queue-refund-batch__text strong {
  font-size: var(--font-size-sm);
  color: var(--color-error);
}

.queue-refund-batch__text span {
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
}

/* ──────────────────────────────────────────────────────────────────────────
   Phase strip — the request lifecycle, as something you can see and click.

   Reads left to right in the order a request actually travels, so the shape of
   the queue is legible before anything is opened: where the work is piled up,
   and what has already finished. Number first, label under it — the count is
   what you scan, the label is what confirms it.
   ────────────────────────────────────────────────────────────────────────── */
.request-phase-strip {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2xs);
  align-items: stretch;
}

.phase-chip {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 78px;
  padding: var(--space-xs) var(--space-sm);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  text-decoration: none;
  line-height: 1.25;
}

.phase-chip:hover { border-color: var(--color-border); }

.phase-chip__n {
  font-size: var(--font-size-md);
  font-weight: 700;
  color: var(--color-text-primary);
  font-variant-numeric: tabular-nums;
}

.phase-chip__label {
  font-size: var(--font-size-sm);
  color: var(--color-text-tertiary);
  white-space: nowrap;
}

/* Nothing there is information too — kept readable, just not competing. */
.phase-chip.is-empty .phase-chip__n { color: var(--color-text-tertiary); }

.phase-chip.is-active {
  border-color: var(--color-primary);
  background: color-mix(in srgb, var(--color-primary) 8%, var(--color-surface));
}

.phase-chip.is-active .phase-chip__n,
.phase-chip.is-active .phase-chip__label { color: var(--color-primary); }

.queue-tab__n {
  font-variant-numeric: tabular-nums;
  opacity: .75;
}

/* The one tab that means work is waiting, so it carries the weight. */
.queue-tab--attention.is-active {
  background: var(--color-error);
  color: var(--color-text-inverse);
}

@media (max-width: 720px) {
  /* nowrap matters as much as the direction here. The bar wraps by default,
     and a wrapping flex container sizes each line to its own content instead of
     to the container — so stacked, the line grew to the widest item's content
     (the strip: seven chips at a 78px floor, 563px) and every sibling stretched
     out to match it, carrying the page into a sideways scroll on a 390px
     screen. Single-line, the cross size is the bar's own width, which is what
     lets the strip stay put and scroll inside itself as intended. */
  .request-queue-bar { flex-direction: column; flex-wrap: nowrap; align-items: stretch; }

  /* And they have to be allowed to shrink to it. */
  .request-queue-bar > * { min-width: 0; }

  .request-phase-strip { overflow-x: auto; flex-wrap: nowrap; padding-bottom: var(--space-2xs); }
}

/* ── Compact row: placement, stated ──────────────────────────────────────────
   Below 640px a row is two cells — the content stack, then the badge — and
   until now that came out of auto-placement rather than being written down.
   Auto-placement hands a track to whatever else turns up in the grid, so one
   extra participant reorders the whole row: a request carrying a next-action
   chip rendered its email alone on the left with the title, chip and dates
   stacked to the right and the pill pushed onto a line of its own, while every
   row without a chip beside it was fine.

   These four rules remove the ways that can happen. The tap area is a flex
   column (never transparent to the grid, which would place its children
   individually), the stretched link is out of flow (never a cell of its own),
   and the two real cells name their positions, so anything unexpected lands
   outside them instead of displacing them. Keyed to the viewport rather than
   the container, so it holds even when the container measures wrong — which is
   the failure the block above guards against.
   ────────────────────────────────────────────────────────────────────────── */
@media (max-width: 639.98px) {
  .record-list-wrap .record-row:not(.record-row--header) .record-row__inner {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .record-list-wrap .record-row:not(.record-row--header) .record-row__tap-area {
    display: flex;
    flex-direction: column;
    min-width: 0;
    grid-column: 1;
    grid-row: 1;
  }

  .record-list-wrap .record-row:not(.record-row--header) .record-row__badge {
    grid-column: 2;
    grid-row: 1;
  }

  .record-list-wrap .record-row__tap-link {
    position: absolute;
  }
}

/* ── Attention dot (Helpers/AttentionDot.cs) ────────────────────────────────────
 * Marks the rows the sidebar number counts: the sidebar says 3, the list shows 3
 * dots. Sits at the start of the row's first title, in the blue of the sidebar's
 * count pills (red would read as an error), and stays until the row is dealt with. */
.attention-dot {
  display: inline-block;
  flex: none;
  width: 8px;
  height: 8px;
  margin-right: 7px;
  border-radius: var(--radius-full);
  background: var(--color-info);
  vertical-align: 0.08em;
}

@media (forced-colors: active) {
  .attention-dot {
    forced-color-adjust: none;
    background: Highlight;
  }
}
