/* ============================================================
 *  /history, the day timeline.
 *
 *  Two filter rows of segmented controls (source + view toggles,
 *  then displays + the clear-history control), and one card of
 *  groups: "Today", "Yesterday", dated days (or one group per
 *  dashboard under "By dashboard"). Each group is a rail of rows:
 *  a status dot on a 2px line, then time, thumbnail, tags, status,
 *  duration and actions on one grid line. Failed rows go red on the
 *  dot and sit on a tinted band.
 *
 *  Tags and segmented controls come from chips.css (.tg / .seg);
 *  everything here is layout. Tokens only, so dark mode follows.
 * ============================================================ */

/* Filters ------------------------------------------------------ */
.dx-hist-filters {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0 0 18px;
}
.dx-hist-filter-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.dx-hist-filter-divider {
  flex: none;
  width: 1px;
  height: 26px;
  background: var(--t-border-strong);
}
.dx-hist-clear {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 0 auto;
  font-size: 13px;
}
.dx-hist-clear-age {
  height: 30px;
  padding: 0 8px;
  border-radius: var(--t-radius-sm, 7px);
  border: 1px solid var(--t-border);
  background: var(--t-surface);
  color: var(--t-fg);
  font-size: 12.5px;
}
.dx-hist-clear-btn { color: var(--t-danger); }
/* With rows ticked the button deletes the selection, so the cutoff select
   and its label step aside until the selection clears. */
.dx-hist-clear.is-selection label,
.dx-hist-clear.is-selection .dx-hist-clear-age { display: none; }

/* Card + groups ------------------------------------------------ */
.dx-hist-card {
  padding: 8px 22px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.dx-hist-card > .dx-empty { padding: 40px 22px 32px; }
.dx-hist-group-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 6px 0 4px;
}
.dx-hist-group-title {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.2;
  color: var(--t-fg);
}
.dx-hist-group-sub {
  font-family: var(--t-font-mono);
  font-size: 11.5px;
  color: var(--t-muted);
  white-space: nowrap;
}

/* The rail: one 2px line per group, behind every row's dot. */
.dx-hist-rows {
  --dx-hist-rail: 21px;
  position: relative;
  list-style: none;
  margin: 0;
  padding: 0;
}
.dx-hist-rows::before {
  content: "";
  position: absolute;
  left: var(--dx-hist-rail);
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--t-border);
  z-index: 1;
}

/* Rows --------------------------------------------------------- */
.dx-hist-row {
  position: relative;
  display: grid;
  grid-template-columns: 24px 16px 70px 64px minmax(0, 1fr) auto 52px auto;
  align-items: center;
  gap: 14px;
  padding: 10px 10px;
  border-bottom: 1px solid color-mix(in oklab, var(--t-border) 70%, transparent);
}
.dx-hist-row:last-child { border-bottom: 0; }
.dx-hist-row--failed {
  background: var(--t-pill-danger-bg);
  border-radius: 8px;
}
.dx-hist-dot {
  position: relative;
  z-index: 2;
  justify-self: center;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--t-accent);
  box-shadow: 0 0 0 3px var(--t-surface);
}
.dx-hist-dot.is-bad { background: var(--t-danger); }

/* Follow-ups: the page sent again once a widget's pending work landed.
   They sit under the send they finish as small dots on the same rail,
   then one line says when the finished page reached the panel. */
.dx-hist-row { --dx-hist-pad: 10px; }
.dx-hist-fu {
  grid-column: 1 / -1;
  list-style: none;
  margin: 2px 0 0;
  padding: 0 0 0 calc(var(--dx-hist-rail) - var(--dx-hist-pad) + 22px);
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12.5px;
  color: var(--t-fg-soft);
}
.dx-hist-fu-row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 20px;
}
.dx-hist-fu-row::before {
  content: "";
  position: absolute;
  left: calc(-22px - 3px);
  top: 50%;
  width: 8px;
  height: 8px;
  margin-top: -4px;
  border-radius: 50%;
  background: var(--t-fg-soft);
  box-shadow: 0 0 0 3px var(--t-surface);
  z-index: 2;
}
.dx-hist-fu-row.is-ok::before { background: var(--t-accent); }
.dx-hist-fu-row.is-bad::before { background: var(--t-danger); }
.dx-hist-fu-row .dx-hist-time { width: auto; font-size: 12.5px; }
.dx-hist-fu-row .dx-hist-dur { width: auto; font-size: 12px; }
.dx-hist-fu-row .tg { font-size: 11.5px; padding: 2px 6px; }
.dx-hist-fu-sum { color: var(--t-fg-soft); }
.dx-hist-fu-sum strong { color: var(--t-fg); font-weight: 600; font-variant-numeric: tabular-nums; }
.dx-hist-row--failed .dx-hist-dot { box-shadow: 0 0 0 3px var(--t-pill-danger-bg); }
.dx-hist-select {
  width: 16px;
  height: 16px;
  margin: 0;
  cursor: pointer;
  accent-color: var(--t-accent);
}
.dx-hist-time {
  font-family: var(--t-font-mono);
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  color: var(--t-fg);
  text-decoration: none;
  white-space: nowrap;
}
a.dx-hist-time[href]:hover { color: var(--t-accent); }

/* 64x48 thumbnail of the rendered frame; failures without a render get
   a mono "no frame" placeholder with a faint red edge. */
.dx-hist-thumb {
  display: grid;
  place-items: center;
  width: 64px;
  height: 48px;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--t-border);
  background: var(--t-inset);
  text-decoration: none;
}
.dx-hist-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.dx-hist-thumb--empty {
  font-family: var(--t-font-mono);
  font-size: 10px;
  color: var(--t-muted);
}
.dx-hist-thumb--empty.is-bad { border-color: var(--t-pill-danger-border); }

.dx-hist-mid {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 8px;
  min-width: 0;
}
.dx-hist-tags {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: none;
}
.dx-hist-break { display: none; }
.dx-hist-target {
  flex: 0 1 auto;
  min-width: 0;
  max-width: 100%;
  font-size: 14px;
  color: var(--t-fg);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.dx-hist-err {
  flex: 1 1 0;
  min-width: 140px;
  font-size: 12px;
  color: var(--t-pill-danger-fg);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* Button rows: pressed button, resolved action and resulting page. */
.dx-hist-detail {
  flex-basis: 100%;
  font-family: var(--t-font-mono);
  font-size: 11.5px;
  color: var(--t-muted);
  min-width: 0;
}
.dx-hist-statuses {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.dx-hist-dur {
  font-family: var(--t-font-mono);
  font-size: 12px;
  color: var(--t-fg-soft);
  text-align: right;
  white-space: nowrap;
}
.dx-hist-actions {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.dx-hist-actions .form { margin: 0; }

/* Overflow menu (delete lives here). Same shape as the Lineups cards. */
.dx-hist-more { position: relative; display: inline-flex; }
.dx-hist-more > summary {
  list-style: none;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 7px;
  color: color-mix(in oklab, var(--t-fg) 55%, transparent);
  cursor: pointer;
}
.dx-hist-more > summary::-webkit-details-marker { display: none; }
.dx-hist-more > summary:hover,
.dx-hist-more[open] > summary {
  background: color-mix(in oklab, var(--t-fg) 6%, var(--t-surface));
  color: var(--t-fg);
}
.dx-hist-more-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  z-index: 30;
  min-width: 140px;
  display: flex;
  flex-direction: column;
  padding: 6px;
  background: var(--t-surface);
  border: 1px solid color-mix(in oklab, var(--t-border) 90%, transparent);
  border-radius: 10px;
  box-shadow: 0 8px 24px color-mix(in oklab, var(--t-fg) 12%, transparent);
}
.dx-hist-more-menu .form { margin: 0; }
.dx-hist-more-item {
  display: block;
  background: none;
  border: 0;
  box-shadow: none;
  text-align: left;
  width: 100%;
  padding: 7px 10px;
  border-radius: 7px;
  font: inherit;
  font-size: 13px;
  color: var(--t-fg);
  text-decoration: none;
  cursor: pointer;
}
.dx-hist-more-item:hover { background: color-mix(in oklab, var(--t-fg) 6%, var(--t-surface)); }
.dx-hist-more-item.is-danger { color: var(--t-danger); }

/* Bulk bar ----------------------------------------------------- */
#dx-hist-bulk-bar {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  z-index: 500;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 14px;
  border: 1px solid var(--t-border);
  border-radius: 12px;
  background: var(--t-surface);
  box-shadow: 0 12px 34px rgba(0, 0, 0, .24);
}
#dx-hist-bulk-bar[hidden] { display: none; }
#dx-hist-bulk-bar .dx-bulk-count { font-size: 13px; font-weight: 600; white-space: nowrap; }
#dx-hist-bulk-bar .dx-bulk-actions { display: flex; align-items: center; gap: 8px; }
#dx-hist-bulk-bar .form { margin: 0; }

/* Phones ------------------------------------------------------- */
@media (max-width: 640px) {
  /* Filter groups scroll sideways inside their own row; the page never does. */
  .dx-hist-filter-row {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    padding-bottom: 2px;
  }
  .dx-hist-filter-row > .seg { flex: none; flex-wrap: nowrap; }
  .dx-hist-clear { margin-left: 0; flex: none; }

  .dx-hist-card { padding: 6px 12px 10px; }
  .dx-hist-rows { --dx-hist-rail: 12px; }

  /* Two lines: dot + tick + time + tags, then thumb + dashboard +
     status + duration + actions. The mid wrapper dissolves so its
     children join the row's flex flow. */
  .dx-hist-row {
    --dx-hist-pad: 6px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 8px;
    padding: 10px 6px 10px 28px;
  }
  .dx-hist-fu { order: 99; flex-basis: 100%; padding-left: calc(var(--dx-hist-rail) - 28px + 22px); }
  .dx-hist-fu-row > .dx-hist-time, .dx-hist-fu-row > .dx-hist-dur, .dx-hist-fu-row > .tg { order: 0; }
  .dx-hist-dot { position: absolute; left: 8px; top: 19px; }
  .dx-hist-mid { display: contents; }
  .dx-hist-select { order: 1; }
  .dx-hist-time { order: 2; }
  .dx-hist-tags { order: 3; flex-wrap: wrap; }
  .dx-hist-break { order: 4; display: block; flex-basis: 100%; height: 0; }
  .dx-hist-thumb { order: 5; width: 48px; height: 36px; }
  .dx-hist-target { order: 6; flex: 1 1 0; min-width: 60px; font-size: 13.5px; }
  .dx-hist-statuses { order: 7; }
  .dx-hist-dur { order: 8; }
  .dx-hist-actions { order: 9; }
  .dx-hist-err { order: 10; flex-basis: 100%; min-width: 0; }
  .dx-hist-detail { order: 11; }
}

/* A send that waited for the page's paintings before it went out. */
.dx-hist-waited { margin: 2px 0 0; font-size: 12px; color: var(--t-fg-soft); display: flex; gap: 5px; align-items: center; }
.dx-hist-waited i { color: var(--t-muted); }
