/* The activity page: the header with the figures of today and the last 24 hours, the filters, and a feed of syncs and
   AI agent changes grouped by day. The notifications list shares the day labels. */

/* ---------- Header ---------- */
.act-hero { margin-bottom: 18px; }
.act-hero .ph-stats { margin-top: 18px; }
.act-hero .ph-stats a { display: block; color: var(--stage-ink); }
.act-chart {
  display: flex; flex-direction: column; gap: 8px; width: 360px; max-width: 100%; padding: 14px 16px;
  border-radius: var(--r-l); background: var(--stage-fill); box-shadow: inset 0 0 0 1px var(--stage-rim);
}
.act-bars { display: flex; align-items: flex-end; gap: 4px; height: 76px; padding-top: 10px; }
.act-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: act-grow .6s cubic-bezier(.2, .8, .2, 1) both;
}
.act-bars i.quiet { background: var(--stage-fill-hover); }
.act-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));
}
.act-bars i:nth-child(4n+2) { animation-delay: .04s; }
.act-bars i:nth-child(4n+3) { animation-delay: .08s; }
.act-bars i:nth-child(4n) { animation-delay: .12s; }
.act-axis { display: flex; justify-content: space-between; font-family: var(--mono); font-size: var(--fs-2xs); color: var(--stage-muted); }
@keyframes act-grow { from { transform: scaleY(0); } to { transform: scaleY(1); } }

/* ---------- Filters ---------- */
.act-log { display: flex; flex-direction: column; gap: 14px; }
.act-toolbar { overflow: hidden; border: 1px solid var(--line); border-radius: var(--r-2xl); background: var(--panel); box-shadow: var(--sh-card); }
.act-toolbar .find { padding: 14px 18px; border-bottom: 0; }
.act-toolbar .find + .find { border-top: 1px solid var(--line-soft); }

/* 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; }

/* ---------- Feed ---------- */
.act-feed { display: flex; flex-direction: column; gap: 10px; }
.daysep, .daylabel {
  padding: 12px 18px 7px; font-size: var(--fs-2xs); font-weight: 600; letter-spacing: var(--tr-caps);
  text-transform: uppercase; color: var(--ink-4);
}
.act-feed .daysep { display: flex; align-items: center; gap: 12px; padding: 16px 2px 2px; }
.act-feed .daysep::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.act-feed .daysep:first-child { padding-top: 2px; }
.daysep-t {
  display: inline-flex; align-items: baseline; gap: 8px; padding: 5px 12px; border: 1px solid var(--line);
  border-radius: 999px; background: var(--panel); box-shadow: var(--sh-card);
  text-transform: none; letter-spacing: 0; font-size: var(--fs-xs); font-weight: 500; color: var(--ink-3);
}
.daysep-t b { font-weight: 650; color: var(--ink); }
.act-empty { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 12px; padding: 28px; text-align: center; }
.act-empty p { margin: 0; color: var(--ink-3); }
.act-pager { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 6px 4px; font-size: var(--fs-s); color: var(--ink-4); }

/* One event: the time, an icon in the colour of its outcome, what happened and its actions. */
.ev {
  position: relative; overflow: hidden;
  display: grid; grid-template-columns: 64px 40px minmax(0, 1fr) auto; gap: 14px; align-items: center;
  padding: 16px 18px 16px 16px; border: 1px solid var(--line); border-radius: var(--r-xl, 18px);
  background: var(--panel); box-shadow: var(--sh-card);
  transition: transform .18s ease, border-color .2s ease, box-shadow .2s ease;
  animation: act-rise .35s cubic-bezier(.2, .8, .2, 1) both;
}
@media (hover: hover) and (pointer: fine) {
  .ev:hover { transform: translateY(-2px); border-color: var(--line-strong); box-shadow: var(--sh-hover); }
}
/* The whole event opens its details; links and buttons inside stay on top of it. */
.ev-cover { position: absolute; inset: 0; z-index: 0; padding: 0; border: 0; background: transparent; cursor: pointer; border-radius: inherit; }
.ev-cover:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }
.ev a:not(.ev-cover), .ev button:not(.ev-cover), .ev form, .ev .itip { position: relative; z-index: 1; }
.ev .ev-go { width: 18px; height: 18px; color: var(--ink-4); transition: transform .18s ease, color .18s ease; }
.ev:hover .ev-go { color: var(--ink-2); transform: translateX(2px); }
/* The outcome as an edge, so a day of syncs can be scanned from the left. */
.ev[data-tone]::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 3px; background: var(--edge); }
.ev[data-tone="ok"] { --edge: var(--ok); }
.ev[data-tone="warn"] { --edge: var(--warn); }
.ev[data-tone="bad"] { --edge: var(--bad); }
.ev[data-tone="info"] { --edge: var(--brand-text); }
.ev[data-tone="mute"] { --edge: var(--line-strong); }
.ev .ts { font-family: var(--mono); font-size: var(--fs-xs); color: var(--ink-3); white-space: nowrap; }
.ev .ic {
  --tone: var(--ink-3);
  display: grid; place-items: center; width: 40px; height: 40px; border-radius: var(--r-l);
  background: color-mix(in srgb, var(--tone) 13%, var(--tone-base, transparent)); color: var(--tone);
}
.ev .ic svg { width: 19px; height: 19px; }
.ev .ic.ok { --tone: var(--ok); }
.ev .ic.warn { --tone: var(--warn); }
.ev .ic.bad { --tone: var(--bad); --tone-base: var(--bad-base); }
.ev .ic.info { --tone: var(--brand-text); }
.ev .ic.mute { --tone: var(--ink-3); }
.ev-body, .ev > div:nth-child(3) { min-width: 0; }
.ev .ti2 { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; font-size: var(--fs-m); font-weight: 600; }
.ev-pair { display: inline-flex; align-items: center; gap: 6px; }
.ev-pair .brandmark { width: 78px; height: 22px; padding: 0 6px; }
.ev-pair svg { width: 13px; height: 13px; color: var(--ink-4); }
.ev .de { margin-top: 3px; font-size: var(--fs-xs); line-height: 1.5; color: var(--ink-3); }
.ev .de .mono { font-size: var(--fs-2xs); color: var(--ink-2); }
.ev-counts { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; margin-top: 8px; font-size: var(--fs-xs); color: var(--ink-3); }
.ev-counts b { font-family: var(--mono); font-weight: 600; font-variant-numeric: tabular-nums; color: var(--ink); }
.ev-counts .w b { color: var(--ok); }
.ev-counts .h b { color: var(--warn); }
.ev-counts .f b { color: var(--bad); }
.ev-meter { display: flex; width: 120px; height: 6px; overflow: hidden; border-radius: var(--r-full); background: var(--panel-3); }
.ev-meter i { display: block; height: 100%; }
.ev-meter .w { background: var(--ok); }
.ev-meter .h { background: var(--warn); }
.ev-meter .f { background: var(--bad); }
.ev-meter .s { background: color-mix(in srgb, var(--ink-4) 35%, transparent); }
.ev .meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 9px; }
.ev-reason {
  margin-top: 10px; padding: 8px 11px; border-radius: var(--r-m); font-size: var(--fs-xs); line-height: 1.5; color: var(--ink-2);
  background: color-mix(in srgb, var(--edge, var(--ink-4)) 8%, transparent); border: 1px solid color-mix(in srgb, var(--edge, var(--ink-4)) 24%, transparent);
  overflow-wrap: anywhere;
}
.ev .side { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.ev .side form { margin: 0; }
.ev .side .btn svg { width: 14px; height: 14px; }
@keyframes act-rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- One sync: its record types, in the panel and on the sync page ---------- */
.runlist { display: flex; flex-direction: column; gap: 8px; }
.runrow {
  position: relative; overflow: hidden;
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 12px;
  padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--r-l); background: var(--panel-2); color: var(--ink);
  transition: transform .18s ease, border-color .2s ease, background .2s ease;
}
.runrow:hover { color: var(--ink); transform: translateY(-1px); border-color: var(--line-strong); background: var(--panel); }
.runrow[data-tone]::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 3px; background: var(--edge); }
.runrow[data-tone="ok"] { --edge: var(--ok); }
.runrow[data-tone="warn"] { --edge: var(--warn); }
.runrow[data-tone="bad"] { --edge: var(--bad); }
.runrow[data-tone="info"] { --edge: var(--brand-text); }
.runrow[data-tone="mute"] { --edge: var(--line-strong); }
.runrow-ic { display: grid; place-items: center; width: 36px; height: 36px; border-radius: var(--r-m); }
.runrow-ic svg { width: 17px; height: 17px; }
.runrow-main { display: flex; flex-direction: column; min-width: 0; }
.runrow-main > b { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: var(--fs-s); font-weight: 600; }
.runrow-main .ev-counts { margin-top: 6px; }
.runrow-side { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.runrow-go { display: inline-flex; align-items: center; gap: 3px; font-size: var(--fs-xs); font-weight: 600; color: var(--brand-text); }
.runrow-go svg { width: 14px; height: 14px; transition: transform .18s ease; }
.runrow:hover .runrow-go svg { transform: translateX(2px); }

@media (min-width: 701px) {
  .syncpanel { width: min(720px, calc(100vw - 24px)); }
}
.sync-pair { display: inline-flex; align-items: center; gap: 6px; flex: none; color: var(--stage-muted); }
.sync-pair .brandmark { width: 92px; }
.sync-pair svg { width: 15px; height: 15px; }
.sync-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.sync-stats > div { padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--r-l); background: var(--panel); }
.sync-stats b { display: block; font-family: var(--mono); font-size: 22px; line-height: 1.15; font-weight: 600; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.sync-stats span { font-size: var(--fs-xs); color: var(--ink-4); }
.sync-stats .w b { color: var(--ok); }
.sync-stats .h b { color: var(--warn); }
.sync-stats .f b { color: var(--bad); }

@media (max-width: 700px) {
  .runrow { grid-template-columns: auto minmax(0, 1fr); }
  .runrow-side { grid-column: 1 / -1; flex-direction: row; justify-content: space-between; }
  .sync-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sync-pair { display: none; }
}

/* A change an AI agent made or proposed: the logo and name of the agent lead its meta line. */
.ev-agent { display: inline-flex; align-items: center; gap: 6px; min-width: 0; font-size: var(--fs-2xs); font-weight: 500; color: var(--ink-2); }
.ev-agent .brandmark { width: 78px; height: 22px; padding: 0 6px; }
.ev-agent-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 220px; }
a.ev-agent:hover .ev-agent-name { color: var(--brand-text-hover); text-decoration: underline; }
.ev .meta a.tag { color: inherit; }
.ev .meta a.tag:hover { color: var(--brand-text-hover); border-color: var(--brand-text); }
.ev .tag svg { width: 11px; height: 11px; }

/* One change inside a batch: its own name, outcome and undo above the values it moved. */
.ai-change.with-head { padding: 12px 0 4px; border-top: 1px solid var(--line-soft); }
.ai-change.with-head:first-of-type { margin-top: 4px; }
.ai-change-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.ai-change-head form { margin: 0 0 0 auto; }
.ai-change-title { flex: 1; min-width: 0; font-size: var(--fs-s); font-weight: 600; color: var(--ink); overflow-wrap: anywhere; }
.ai-change .detail-note { margin-top: 8px; }
.ai-fields .detail-key { min-width: 130px; }
.ai-fields .detail-value { display: inline-flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 6px; }
.ai-fields .detail-value svg { width: 13px; height: 13px; flex: none; color: var(--ink-4); }
.ai-before { color: var(--ink-4); font-weight: 400; text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--ink-4) 60%, transparent); }

/* ---------- Notifications list ---------- */
.nrow {
  display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; gap: 12px; align-items: flex-start;
  padding: 14px 18px; border-bottom: 1px solid var(--line-soft); transition: background .12s ease;
}
.nrow:last-child { border-bottom: 0; }
.nrow:hover { background: var(--panel-2); }
.nrow.unread { background: var(--brand-soft); }
.nrow .nt { font-size: var(--fs-m); font-weight: 600; }
.nrow .nb { margin-top: 2px; font-size: var(--fs-s); line-height: 1.55; color: var(--ink-3); white-space: pre-line; }
.nrow .nm { font-size: var(--fs-2xs); color: var(--ink-4); white-space: nowrap; font-variant-numeric: tabular-nums; }
.nrow.unread .nt::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 8px; border-radius: 50%; background: var(--brand-text); vertical-align: 2px; }
.nlist { overflow: hidden; border-radius: var(--r-2xl); }
/* Each kind of notification has its own colour: on its tab, as an edge on its row and as a chip by its time. */
.nlist .nrow { box-shadow: inset 3px 0 0 var(--tone); }
.nlist .nrow .nm { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.ncat {
  display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 999px;
  background: color-mix(in srgb, var(--tone) 12%, var(--tone-base, transparent)); color: var(--tone);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--tone) 28%, var(--tone-base, transparent));
  font-size: var(--fs-2xs); font-weight: 600;
}
.ncat svg { width: 12px; height: 12px; }
.ntabs a svg { width: 15px; height: 15px; color: var(--tone); }
.ntabs .tab-count { background: color-mix(in srgb, var(--tone) 14%, var(--tone-base, transparent)); color: var(--tone); }
.ntabs .tab-count.quiet { background: var(--panel-3); color: var(--ink-4); }
.ntabs .tab-count.solid, .deck-tabs.subnav.ntabs a.on .tab-count { background: var(--tone); color: var(--panel); }
.deck-tabs.subnav.ntabs a.on {
  background: color-mix(in srgb, var(--tone) 14%, var(--tone-base, var(--panel)));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--tone) 45%, var(--tone-base, transparent));
}
.nday + .nday { border-top: 1px solid var(--line); }
.nday-label { padding: 14px 18px 6px; font-size: var(--fs-s); font-weight: 500; color: var(--ink-3); }

@media (prefers-reduced-motion: reduce) {
  .ev, .act-bars i { animation: none; }
}

@media (max-width: 1180px) {
  .act-chart { width: 100%; }
}

@media (max-width: 700px) {
  .ev { grid-template-columns: 40px minmax(0, 1fr); padding: 14px; }
  .ev .ts { grid-column: 1 / -1; }
  .ev .side { grid-column: 1 / -1; flex-direction: row; flex-wrap: wrap; align-items: center; justify-content: space-between; }
  .ev-meter { width: 100%; }
  .nrow { grid-template-columns: 30px minmax(0, 1fr); }
  .nrow .nm { grid-column: 2; margin-top: 2px; }
  .nlist .nrow .nm { flex-direction: row; align-items: center; }
  .ai-fields li { flex-wrap: wrap; }
  .ai-fields .detail-value { justify-content: flex-start; text-align: left; }
}
