/* Activity on one surface: today's figures and the last 24 hours in the head, a feed of rows under a day line that
   stays on screen, and a sync, a run and an AI agent change as pages of their own. Every class starts with ac-. */

/* ---------- The head: today's figures beside the last 24 hours ---------- */
.ac-head { flex: 1 1 100%; display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px 32px; align-items: end; }
/* On a wide page the last 24 hours run the whole height of the head on its right, from its top to just above its bottom. */
.phead:has(.ac-hours) { --ac-hours-w: 440px; padding-right: calc(var(--zr, var(--pad-x)) + var(--ac-hours-w) + 32px); }
.ac-stats { display: flex; flex-wrap: wrap; gap: 26px; }
.ac-stats > * { display: grid; gap: 1px; min-width: 0; color: var(--stage-ink); }
.ac-stats b {
  font-family: var(--mono); font-size: 22px; line-height: 1.1; font-weight: 600; letter-spacing: -.02em;
  font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--stage-ink);
}
.ac-stats b.bad { color: var(--stage-bad); }
.ac-stats span { font-size: var(--fs-xs); color: var(--stage-muted); }
.ac-stats a span { text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--stage-muted) 50%, transparent); text-underline-offset: 3px; }
.ac-stats a:hover span { color: var(--stage-ink); text-decoration-color: var(--stage-flow); }

.ac-hours {
  position: absolute; top: 22px; bottom: 18px; right: var(--zr, var(--pad-x)); width: var(--ac-hours-w);
  display: flex; flex-direction: column; gap: 8px; min-width: 0; padding-left: 28px; border-left: 1px solid var(--stage-grid);
}
.ac-hours-k { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.ac-hours-legend { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-2xs); color: var(--stage-muted); }
.ac-hours-legend i { width: 6px; height: 6px; border-radius: 50%; background: var(--stage-bad); }
.ac-bars { flex: 1; display: flex; align-items: flex-end; gap: 4px; min-height: 64px; padding-top: 12px; }
.ac-bars i {
  position: relative; flex: 1; min-width: 4px; border-radius: 4px 4px 2px 2px;
  background: linear-gradient(180deg, var(--stage-flow), var(--stage-action));
  transform-origin: bottom; animation: ac-grow .6s cubic-bezier(.2, .8, .2, 1) both;
}
.ac-bars i.quiet { background: var(--stage-fill-hover); }
.ac-bars i.bad::after {
  content: ""; position: absolute; left: 50%; top: -9px; width: 6px; height: 6px; margin-left: -3px; border-radius: 50%;
  background: var(--stage-bad); box-shadow: 0 0 0 3px color-mix(in srgb, var(--stage-bad) 25%, var(--stage-bad-base));
}
.ac-bars i:nth-child(4n+2) { animation-delay: .04s; }
.ac-bars i:nth-child(4n+3) { animation-delay: .08s; }
.ac-bars i:nth-child(4n) { animation-delay: .12s; }
.ac-axis { display: flex; justify-content: space-between; font-family: var(--mono); font-size: var(--fs-2xs); color: var(--stage-muted); }
@keyframes ac-grow { from { transform: scaleY(0); } to { transform: scaleY(1); } }

/* The state of a sync on the dark head: its icon tile and its badge in the colour of the outcome. */
.phead-ic.ac-tone-ok { --rtc: var(--ok); }
.phead-ic.ac-tone-warn { --rtc: var(--warn); }
.phead-ic.ac-tone-bad { --rtc: var(--bad); }
.phead-ic.ac-tone-info { --rtc: var(--brand-text); }
.phead-ic.ac-tone-mute { --rtc: var(--ink-3); }

/* ---------- The filter bar: a clear button as high as the fields ---------- */
.toolbar .ac-clear { height: 40px; border-radius: var(--r-l); }
.toolbar .ac-clear svg { width: 15px; height: 15px; }

/* ---------- The day: a line that stays under the top bar while its events scroll by ---------- */
.ac-day {
  position: sticky; top: calc(var(--banner-h, 0px) + var(--topbar)); z-index: 4;
  display: flex; align-items: baseline; gap: 8px;
  padding-top: 9px; padding-bottom: 9px; padding-left: var(--zl, var(--pad-x)); padding-right: var(--zr, var(--pad-x));
  border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--panel-2) 94%, transparent);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  font-size: var(--fs-xs); color: var(--ink-4);
}
.ac-day b { font-size: var(--fs-s); font-weight: 650; color: var(--ink); }

/* ---------- One event: its time, its outcome, what happened, its pill and its menu ---------- */
.ac-row { --rl-cols: 64px 36px minmax(0, 1fr) 220px; --rl-cols-md: 64px 36px minmax(0, 1fr) 200px; align-items: start; }
.ac-row > .rl-do { align-self: center; }
.ac-ts { padding-top: 9px; font-family: var(--mono); font-size: var(--fs-xs); color: var(--ink-3); white-space: nowrap; font-variant-numeric: tabular-nums; }
.ac-ic {
  --tone: var(--ink-3);
  display: grid; place-items: center; flex: none; width: 36px; height: 36px; border-radius: var(--r-m);
  background: color-mix(in srgb, var(--tone) 13%, var(--tone-base, transparent)); color: var(--tone);
}
.ac-ic svg { width: 17px; height: 17px; }
.ac-ic.sm { width: 24px; height: 24px; border-radius: 7px; }
.ac-ic.sm svg { width: 13px; height: 13px; }
.ac-ic.ok { --tone: var(--ok); }
.ac-ic.warn { --tone: var(--warn); }
.ac-ic.bad { --tone: var(--bad); --tone-base: var(--bad-base); }
.ac-ic.info { --tone: var(--brand-text); }
.ac-ic.mute { --tone: var(--ink-3); }
.ac-body { min-width: 0; }
.ac-title { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; min-width: 0; }
.ac-title b { min-width: 0; font-size: var(--fs-m); font-weight: 600; line-height: 1.35; color: var(--ink); overflow-wrap: anywhere; }
.ac-row:hover .ac-title b, .ac-run:hover .ac-title b { color: var(--brand-text); }
.ac-when { display: none; margin-left: auto; font-family: var(--mono); font-size: var(--fs-xs); color: var(--ink-4); white-space: nowrap; }
.ac-de { margin-top: 3px; font-size: var(--fs-xs); line-height: 1.5; color: var(--ink-3); }
.ac-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 9px; }
.ac-meta .tag svg, .ac-meta .pill svg { width: 11px; height: 11px; }
.ac-meta a.tag { color: inherit; }
.ac-meta a.tag:hover { color: var(--brand-text-hover); border-color: var(--brand-text); }
.ac-reason {
  margin-top: 9px; padding-left: 10px; border-left: 2px solid var(--edge, var(--line-strong));
  font-size: var(--fs-xs); line-height: 1.5; color: var(--ink-2); overflow-wrap: anywhere;
}
.ac-pair { display: inline-flex; align-items: center; gap: 6px; }
.ac-pair .brandmark { width: 78px; height: 22px; padding: 0 6px; }
.ac-pair svg { width: 13px; height: 13px; color: var(--ink-4); }

/* What a sync or a run did, in counts and as one bar: written, waiting, failed and skipped. */
.ac-counts { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; margin-top: 8px; font-size: var(--fs-xs); color: var(--ink-3); }
.ac-counts b { font-family: var(--mono); font-weight: 600; font-variant-numeric: tabular-nums; color: var(--ink); }
.ac-counts .w b { color: var(--ok); }
.ac-counts .h b { color: var(--warn); }
.ac-counts .f b { color: var(--bad); }
.ac-of { color: var(--ink-4); }
.ac-meter { display: flex; width: 120px; height: 6px; overflow: hidden; border-radius: var(--r-full); background: var(--panel-3); }
.ac-meter i { display: block; height: 100%; }
.ac-meter .w { background: var(--ok); }
.ac-meter .h { background: var(--warn); }
.ac-meter .f { background: var(--bad); }
.ac-meter .s { background: color-mix(in srgb, var(--ink-4) 35%, transparent); }
.fig .ac-meter { width: 100%; margin-top: 12px; }
.fig-big.ac-bad { color: var(--bad); }

/* The AI agent of a change: its logo, or "Your CRM" for a white label install, and its own name. */
.ac-agent { display: inline-flex; align-items: center; gap: 6px; min-width: 0; font-size: var(--fs-2xs); font-weight: 500; color: var(--ink-2); }
.ac-agent .brandmark { width: 78px; height: 22px; padding: 0 6px; }
.ac-agent-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 220px; }
a.ac-agent:hover .ac-agent-name { color: var(--brand-text-hover); text-decoration: underline; }
.ac-who .ac-agent-name { font-size: var(--fs-s); }

/* ---------- A sync's record types: one row per type and the way it travelled ---------- */
.ac-run-cols { --rl-cols: 36px minmax(0, 1fr) 280px 170px; --rl-cols-md: 36px minmax(0, 1fr) 170px; }
.ac-run .ac-counts { margin-top: 0; }
.ac-run .ac-meter { width: 100%; flex-basis: 100%; }
.ac-run .rl-do { flex-direction: column; align-items: flex-end; gap: 6px; }
.ac-go { display: inline-flex; align-items: center; gap: 3px; font-size: var(--fs-xs); font-weight: 600; color: var(--brand-text); white-space: nowrap; }
.ac-go svg { width: 14px; height: 14px; transition: transform .18s ease; }
.ac-run:hover .ac-go svg { transform: translateX(2px); }

/* ---------- The records of a run, and the fields of an AI agent change ---------- */
.ac-sev { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding-top: 14px; padding-left: var(--zl, var(--pad-x)); padding-right: var(--zr, var(--pad-x)); }
.ac-sev .pill svg { width: 12px; height: 12px; }
.ac-hint { margin-left: auto; font-size: var(--fs-xs); color: var(--ink-4); }
.ac-id { font-family: var(--mono); font-size: var(--fs-xs); color: var(--ink-2); overflow-wrap: anywhere; }
.ac-ids summary { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; font-weight: 600; color: var(--ink); list-style: none; }
.ac-ids summary::-webkit-details-marker { display: none; }
.ac-ids summary svg { width: 14px; height: 14px; color: var(--brand-text); transition: transform .18s ease; }
.ac-ids[open] summary svg { transform: rotate(90deg); }
.ac-id-line { display: flex; align-items: center; gap: 6px; margin-top: 6px; }
.ac-table .pill { white-space: nowrap; }
.ac-table :is(th, td).ac-eye { width: 44px; text-align: right; }
.ac-table :is(th, td).ac-arrow { width: 28px; padding-left: 0; padding-right: 0; text-align: center; color: var(--ink-4); }
.ac-table td.ac-arrow svg { width: 14px; height: 14px; }
.ac-rec-more { margin-left: auto; }
.ac-before { color: var(--ink-4); text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--ink-4) 60%, transparent); }
.ac-after { font-weight: 600; color: var(--ink); }
.ac-empty { color: var(--ink-4); }
/* A table that fits never scrolls sideways, so a menu inside it may reach past its edge. */
.table-wrap.ac-open { overflow: visible; }

/* An open menu rises above the day line and the rows after it. */
.ac-row details.more[open], .ac-rec-more details.more[open] { z-index: 40; }

/* ---------- Narrower pages ---------- */
@container page (max-width: 1180px) {
  .ac-run .ac-run-counts { grid-column: 2 / -1; grid-row: 2; }
}

@container page (max-width: 820px) {
  .phead:has(.ac-hours) { padding-right: var(--zr, var(--pad-x)); }
  .ac-hours { position: static; width: auto; padding-left: 0; padding-top: 16px; border-left: 0; border-top: 1px solid var(--stage-grid); }
  .ac-bars { flex: none; height: 72px; }
  .ac-hint { margin-left: 0; flex-basis: 100%; }
}

@container page (max-width: 640px) {
  .ac-stats { gap: 18px; }
  .ac-row { --rl-cols: 36px minmax(0, 1fr); --rl-cols-md: 36px minmax(0, 1fr); gap: 10px 12px; }
  .ac-ts { display: none; }
  .ac-when { display: inline; }
  .ac-row > .rl-do { grid-column: 2; justify-content: flex-start; flex-wrap: wrap; }
  .ac-row .ac-meter { width: 100%; }
  .ac-run-cols { --rl-cols: 36px minmax(0, 1fr); --rl-cols-md: 36px minmax(0, 1fr); }
  .ac-run { gap: 10px 12px; }
  .rl-head.ac-run-cols { display: none; }
  .ac-run .ac-run-counts { grid-column: 2; grid-row: auto; }
  .ac-run .rl-do { grid-column: 2; flex-direction: row; align-items: center; justify-content: space-between; }
}

@media (prefers-reduced-motion: reduce) {
  .ac-bars i { animation: none; }
  .ac-go svg, .ac-ids summary svg { transition: none; }
}

/* ---------- Elsewhere ---------- */
/* The older labelled filter row, still used by the admin's backups list. */
.activityfilter { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; padding: 14px 18px; }
.activityfilter .af-field {
  display: flex; flex-direction: column; gap: 5px;
  font-size: var(--fs-2xs); font-weight: 600; letter-spacing: var(--tr-caps); text-transform: uppercase; color: var(--ink-4);
}
.activityfilter .af-field .input { width: 170px; font-weight: 400; letter-spacing: normal; text-transform: none; }
.activityfilter .af-field select.input { width: 220px; }

