/* history: execution history page, the shared mini flow / workflow rows (history.js exports them) and the
   "Running natively now" list of tracked native operations. */

/* Glance band: status donut (two rows tall) beside where the work came from and the steps per product, then the weekly
   outcomes and the activity heatmap side by side. One column below 900px; the donut's row span is dropped there. */
.history-band { display: grid; grid-template-columns: minmax(0, 6fr) minmax(0, 5fr); align-items: start; gap: var(--gutter); }
.history-band > .ui-panel { display: grid; align-content: start; min-width: 0; }
.history-band > .ui-panel:first-child { grid-row: span 2; }

/* Filter chips (segmented with counts) */
.history-filter { margin-bottom: var(--s-4); }
.history-filter .ui-segmented { flex-wrap: wrap; }
.history-group-title .ui-count { margin-left: var(--s-2); }

/* Groups and rows */
.history-results { display: grid; gap: var(--s-6); }
.history-group { display: grid; gap: var(--s-3); }
.history-group-title { display: flex; align-items: center; margin: 0; color: var(--text-2); font-size: var(--fs-xs); line-height: var(--lh-xs); font-weight: 500; letter-spacing: 0.08em; text-transform: uppercase; }
.history-group.is-attention .history-group-title { color: var(--warn); }
.history-list {
  display: grid;
  margin: 0;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line-subtle);
  border-radius: var(--r-md);
  background: var(--surface);
  box-shadow: var(--shadow-panel);
  list-style: none;
}
.history-group.is-attention .history-list { border-color: color-mix(in srgb, var(--warn) 35%, transparent); }
.history-row {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--s-5);
  margin: 0;
  padding: var(--s-4) var(--s-5);
  transition: background-color var(--t-micro) var(--ease-move);
}
.history-row + .history-row { border-top: 1px solid var(--line-subtle); }
.history-row:hover { background: var(--raised); }
.history-row:has(.ui-stretch:focus-visible) { outline: 2px solid var(--focus); outline-offset: -2px; }
.history-row-main { display: grid; gap: 2px; min-width: 0; }
.history-row-title { margin: 0; overflow: hidden; font-size: var(--fs-md); line-height: var(--lh-md); font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.history-row-title a { color: var(--text); }
.history-row-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 0 var(--s-2); margin: 0; color: var(--text-2); font-size: var(--fs-sm); line-height: var(--lh-sm); }
.history-row-source::before { content: "·"; margin-right: var(--s-2); color: var(--text-3); }
.history-row-side { display: flex; align-items: center; justify-content: flex-end; gap: var(--s-4); }
.history-row-side time { min-width: 13ch; color: var(--text-3); font-size: var(--fs-sm); line-height: var(--lh-sm); text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.history-more { justify-self: start; }

/* Mini flow: one product mark per step, ringed by the step's status; connectors show order. */
.wf-mini { display: inline-flex; align-items: center; min-width: 0; max-width: 224px; }
.wf-mini-step {
  --c: var(--line-input);
  position: relative;
  display: grid;
  flex: none;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 1.5px solid var(--c);
  border-radius: var(--r-full);
  background: var(--surface);
}
.wf-mini-step + .wf-mini-step, .wf-mini-more { margin-left: 8px; }
.wf-mini-step + .wf-mini-step::before, .wf-mini-step + .wf-mini-more::before {
  content: "";
  position: absolute;
  top: 50%;
  right: calc(100% + 1.5px);
  width: 8px;
  border-top: 1.5px solid var(--line);
}
.wf-mini-more { position: relative; color: var(--text-3); font-size: var(--fs-xs); line-height: var(--lh-xs); font-weight: 500; font-variant-numeric: tabular-nums; }
.wf-mini-step .mark { border-radius: var(--r-full); }
/* Ring color = statusTone() of the step (ui/status.js), the same tone its pill uses; not-yet-run steps are dashed. */
.wf-mini-step[data-tone="ok"] { --c: var(--ok); }
.wf-mini-step[data-tone="info"] { --c: var(--info); }
.wf-mini-step[data-tone="warn"] { --c: var(--warn); }
.wf-mini-step[data-tone="danger"] { --c: var(--danger); }
.wf-mini-step[data-tone="neutral"] { --c: var(--line-input); }
.wf-mini-step:is([data-status="pending"], [data-status="queued"], [data-status="awaiting_approval"]) { border-style: dashed; }
.wf-mini-step[data-status="cancelled"] .mark { opacity: 0.55; }
/* A badge dot where a person is needed or something broke, so the state never depends on ring color alone. */
.wf-mini-step:is([data-tone="danger"], [data-status="awaiting_approval"], [data-status="paused"])::after {
  content: "";
  position: absolute;
  top: -3px;
  right: -3px;
  width: 8px;
  height: 8px;
  border: 1.5px solid var(--surface);
  border-radius: var(--r-full);
  background: var(--c);
}
.history-mark-unknown { display: block; width: 16px; height: 16px; border: 1px dashed var(--line-input); border-radius: var(--r-full); }

/* Running natively now: tracked native operations (GET /api/native/operations). */
.history-native-list { display: grid; margin: 0; padding: 0; overflow: hidden; border: 1px solid var(--line-subtle); border-radius: var(--r-md); background: var(--surface); box-shadow: var(--shadow-panel); list-style: none; }
.history-native-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: var(--s-4); margin: 0; padding: var(--s-4) var(--s-5); }
.history-native-row + .history-native-row { border-top: 1px solid var(--line-subtle); }
.history-native-main { display: grid; gap: 2px; min-width: 0; }
.history-native-title { margin: 0; font-size: var(--fs-md); line-height: var(--lh-md); font-weight: 600; }
.history-native-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 0 var(--s-3); margin: 0; color: var(--text-2); font-size: var(--fs-sm); line-height: var(--lh-sm); }
.history-native-meta code { overflow-wrap: anywhere; }
.history-native-side { display: flex; align-items: center; justify-content: flex-end; gap: var(--s-4); }
.history-native-times { display: grid; justify-items: end; color: var(--text-3); font-size: var(--fs-sm); line-height: var(--lh-sm); font-variant-numeric: tabular-nums; white-space: nowrap; }
.history-native-empty { margin: 0; }

@media (max-width: 1199px) {
  .history-row { grid-template-columns: minmax(0, 1fr) auto; row-gap: var(--s-2); }
  .history-row .wf-mini { grid-column: 1 / -1; }
}
@media (max-width: 899px) {
  .history-band { grid-template-columns: minmax(0, 1fr); }
  .history-band > .ui-panel:first-child { grid-row: auto; }
}
@media (max-width: 639px) {
  .history-row { grid-template-columns: minmax(0, 1fr); padding: var(--s-4); }
  .history-row-title { white-space: normal; }
  .history-row-side { justify-content: space-between; }
  .history-row-side time { min-width: 0; }
  .history-row-source { flex-basis: 100%; }
  .history-row-source::before { display: none; }
  .history-native-row { grid-template-columns: auto minmax(0, 1fr); padding: var(--s-4); }
  .history-native-side { grid-column: 1 / -1; justify-content: space-between; }
  .history-native-times { justify-items: start; }
}
