/* ────────────────────────────────────────────────────────────────────
   Platform Analytics — fleet-wide cross-org analytics for Heron staff.
   Reuses tokens from styles.css. Adds patterns specific to analytics:
   timeline chart, sparklines, leaderboard table, anomaly cards,
   connector matrix, hour-of-day heatmap.
   ──────────────────────────────────────────────────────────────────── */

/* ── Page-level layout ───────────────────────────────────────────── */

.aq-pa-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}
.aq-pa-toolbar .aq-pa-spacer { flex: 1; }
.aq-pa-range {
  display: inline-flex;
  align-items: stretch;
  height: 28px;
  border: 1px solid var(--aq-line);
  border-radius: 7px;
  overflow: hidden;
  background: var(--aq-surface);
}
.aq-pa-range button {
  height: 100%;
  padding: 0 12px;
  background: transparent;
  border: 0;
  border-right: 1px solid var(--aq-line);
  color: var(--aq-text-dim);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  transition: background var(--aq-d-1) var(--aq-ease), color var(--aq-d-1) var(--aq-ease);
}
.aq-pa-range button:last-child { border-right: 0; }
.aq-pa-range button:hover { color: var(--aq-text); }
.aq-pa-range button.is-active {
  background: var(--aq-surface-2);
  color: var(--aq-text);
  box-shadow: var(--aq-edge-top);
}

.aq-pa-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 10px;
  border: 1px solid var(--aq-line);
  border-radius: 7px;
  background: var(--aq-surface);
  color: var(--aq-text-dim);
  font-size: 12px;
  cursor: pointer;
  transition: background var(--aq-d-1) var(--aq-ease), color var(--aq-d-1) var(--aq-ease);
}
.aq-pa-pill:hover { color: var(--aq-text); }
.aq-pa-pill svg { width: 13px; height: 13px; stroke-width: 1.5; }

/* ── Stat-card grid (5-up row of compact KPIs) ───────────────────── */

.aq-pa-kpis {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0;
  border: 1px solid var(--aq-line);
  border-radius: var(--aq-r-lg);
  background: var(--aq-surface-grad), var(--aq-surface);
  margin-bottom: 24px;
  overflow: hidden;
}
.aq-pa-kpi {
  padding: 18px 20px;
  border-right: 1px solid var(--aq-line);
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
}
.aq-pa-kpi:last-child { border-right: 0; }
.aq-pa-kpi-label {
  font-size: 11px;
  color: var(--aq-text-faint);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 6px;
}
.aq-pa-kpi-label svg { width: 12px; height: 12px; stroke-width: 1.5; opacity: 0.7; }
.aq-pa-kpi-value {
  font-family: var(--aq-ff-display);
  font-size: 28px;
  font-weight: 500;
  letter-spacing: -0.02em;
  color: var(--aq-text-bright, var(--aq-text));
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.aq-pa-kpi-value-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.aq-pa-kpi-trend {
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
  font-family: var(--aq-ff-mono);
  display: inline-flex;
  align-items: center;
  gap: 2px;
}
.aq-pa-kpi-trend.is-up { color: var(--aq-success); }
.aq-pa-kpi-trend.is-down { color: var(--aq-danger); }
.aq-pa-kpi-trend.is-warn { color: var(--aq-warn); }
.aq-pa-kpi-sub {
  font-size: 11.5px;
  color: var(--aq-text-faint);
}
.aq-pa-kpi-spark {
  position: absolute;
  right: 14px;
  top: 16px;
  opacity: 0.55;
}

/* ── Two-column section ──────────────────────────────────────────── */

.aq-pa-row {
  display: grid;
  gap: 14px;
  margin-bottom: 24px;
}

/* When a row should cap at a max height (chart + scrollable list pattern),
   apply .is-capped on the row. The chart card stays a comfortable size and
   the sibling card scrolls its inner list instead of stretching. */
.aq-pa-row.is-capped { max-height: 460px; }
.aq-pa-row.is-capped > .aq-pa-card { max-height: 460px; min-height: 0; }
.aq-pa-row.is-capped .aq-pa-anom-list,
.aq-pa-row.is-capped .aq-pa-queue {
  overflow-y: auto;
  flex: 1 1 auto;
  min-height: 0;
}
.aq-pa-row.is-capped .aq-pa-anom-list::-webkit-scrollbar,
.aq-pa-row.is-capped .aq-pa-queue::-webkit-scrollbar {
  width: 6px;
}
.aq-pa-row.is-capped .aq-pa-anom-list::-webkit-scrollbar-thumb,
.aq-pa-row.is-capped .aq-pa-queue::-webkit-scrollbar-thumb {
  background: var(--aq-line);
  border-radius: 3px;
}
.aq-pa-row.is-2-1 { grid-template-columns: 2fr 1fr; }
.aq-pa-row.is-1-1 { grid-template-columns: 1fr 1fr; }
.aq-pa-row.is-3-2 { grid-template-columns: 3fr 2fr; }

.aq-pa-card {
  position: relative;
  background: var(--aq-surface-grad), var(--aq-surface);
  border: 1px solid var(--aq-line);
  border-radius: var(--aq-r-lg);
  padding: 18px 20px;
  box-shadow: var(--aq-shadow-1), var(--aq-edge-top);
  display: flex;
  flex-direction: column;
}
.aq-pa-card-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: nowrap;
  min-width: 0;
}
.aq-pa-card-title {
  font-family: var(--aq-ff-display);
  font-size: 13.5px;
  font-weight: 500;
  letter-spacing: -0.005em;
  color: var(--aq-text);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  white-space: nowrap;
}
.aq-pa-card-title svg { width: 14px; height: 14px; stroke-width: 1.5; color: var(--aq-text-dim); flex-shrink: 0; }
.aq-pa-card-sub {
  font-size: 11.5px;
  color: var(--aq-text-faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  flex: 1 1 auto;
}
.aq-pa-card-actions {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.aq-pa-card-segs {
  display: inline-flex;
  border: 1px solid var(--aq-line);
  border-radius: 6px;
  overflow: hidden;
  height: 22px;
}
.aq-pa-card-segs button {
  height: 100%;
  padding: 0 8px;
  background: transparent;
  border: 0;
  border-right: 1px solid var(--aq-line);
  color: var(--aq-text-faint);
  font: inherit;
  font-size: 11px;
  cursor: pointer;
}
.aq-pa-card-segs button:last-child { border-right: 0; }
.aq-pa-card-segs button.is-active {
  background: var(--aq-surface-2);
  color: var(--aq-text);
}

/* ── AI digest hero card (replaces the original "Digest") ────────── */

.aq-pa-digest {
  position: relative;
  background: var(--aq-surface-grad), var(--aq-surface);
  border: 1px solid var(--aq-line);
  border-radius: var(--aq-r-lg);
  padding: 20px 22px;
  margin-bottom: 24px;
  overflow: hidden;
  box-shadow: var(--aq-shadow-1), var(--aq-edge-top);
}
.aq-pa-digest::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 70% 100% at 100% 0%, var(--aq-accent-glow), transparent 65%);
  pointer-events: none;
}
.aq-pa-digest-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  position: relative;
}
.aq-pa-digest-icon {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--aq-accent-soft);
  color: var(--aq-accent);
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 600;
}
.aq-pa-digest-title {
  font-family: var(--aq-ff-display);
  font-size: 13.5px;
  font-weight: 500;
  color: var(--aq-text);
}
.aq-pa-digest-meta {
  margin-left: auto;
  font-size: 11.5px;
  color: var(--aq-text-faint);
  font-family: var(--aq-ff-mono);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.aq-pa-digest-meta .aq-pa-digest-pulse {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--aq-success);
  box-shadow: 0 0 8px var(--aq-success);
}
.aq-pa-digest-body {
  font-size: 13.5px;
  line-height: 1.65;
  color: var(--aq-text-muted);
  text-wrap: pretty;
  position: relative;
  max-width: 88ch;
}
.aq-pa-digest-body strong {
  color: var(--aq-text);
  font-weight: 500;
}
.aq-pa-digest-body em {
  font-style: normal;
  color: var(--aq-text);
  background: var(--aq-accent-soft);
  padding: 1px 5px;
  border-radius: 4px;
  border: 1px solid var(--aq-accent-line);
}
.aq-pa-digest-foot {
  margin-top: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  position: relative;
}

/* ── Timeline chart ──────────────────────────────────────────────── */

.aq-pa-chart {
  position: relative;
  width: 100%;
  flex: 1 1 auto;
  min-height: 220px;
}
.aq-pa-chart-svg {
  width: 100%;
  height: 100%;
  display: block;
  overflow: visible;
}
.aq-pa-chart-y {
  font-family: var(--aq-ff-mono);
  font-size: 10px;
  fill: var(--aq-text-faint);
}
.aq-pa-chart-x {
  font-family: var(--aq-ff-mono);
  font-size: 10px;
  fill: var(--aq-text-faint);
}
.aq-pa-chart-grid {
  stroke: var(--aq-line);
  stroke-dasharray: 2 4;
  stroke-width: 1;
}
.aq-pa-chart-area {
  fill: var(--aq-accent-soft);
}
.aq-pa-chart-line {
  fill: none;
  stroke: var(--aq-accent);
  stroke-width: 1.6;
}
.aq-pa-chart-line-2 {
  fill: none;
  stroke: var(--aq-text-dim);
  stroke-width: 1.2;
  stroke-dasharray: 3 3;
  opacity: 0.6;
}
.aq-pa-chart-dot {
  fill: var(--aq-accent);
  stroke: var(--aq-bg-2);
  stroke-width: 2;
}
.aq-pa-chart-anno {
  fill: var(--aq-text);
  font-size: 10.5px;
  font-family: var(--aq-ff-mono);
}
.aq-pa-chart-anno-line {
  stroke: var(--aq-warn);
  stroke-width: 1;
  stroke-dasharray: 2 3;
}
.aq-pa-chart-legend {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-size: 11px;
  color: var(--aq-text-faint);
  white-space: nowrap;
  flex-shrink: 0;
}
.aq-pa-chart-legend span {
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
}
.aq-pa-chart-legend i {
  width: 10px; height: 2px; border-radius: 1px;
  display: inline-block;
  margin-right: 5px;
  vertical-align: middle;
}
.aq-pa-chart-legend i.is-current { background: var(--aq-accent); }
.aq-pa-chart-legend i.is-prior { background: var(--aq-text-dim); }

/* ── Leaderboard table ───────────────────────────────────────────── */

.aq-pa-leader {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.aq-pa-row-head,
.aq-pa-leader-row {
  display: grid;
  grid-template-columns: 22px minmax(0, 1.6fr) 90px 100px 130px 70px 90px 70px 50px;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--aq-line);
  font-size: 12.5px;
}
.aq-pa-row-head {
  font-size: 10.5px;
  color: var(--aq-text-faint);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: 500;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.012);
}
.aq-pa-leader-row:hover { background: var(--aq-surface-2); }
.aq-pa-leader-row:last-child { border-bottom: 0; }

.aq-pa-rank {
  font-family: var(--aq-ff-mono);
  font-size: 11px;
  color: var(--aq-text-faint);
  text-align: right;
}
.aq-pa-leader-name {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.aq-pa-leader-name-stack {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.aq-pa-leader-name-main {
  font-size: 12.5px;
  color: var(--aq-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.aq-pa-leader-name-sub {
  font-size: 10.5px;
  color: var(--aq-text-faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.aq-pa-num {
  font-family: var(--aq-ff-mono);
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  color: var(--aq-text);
  text-align: right;
}
.aq-pa-num-sub {
  color: var(--aq-text-faint);
}

/* Inline screen-online bar */
.aq-pa-bar {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.aq-pa-bar-label {
  display: flex;
  justify-content: space-between;
  font-family: var(--aq-ff-mono);
  font-size: 11px;
  color: var(--aq-text-dim);
}
.aq-pa-bar-label .is-down { color: var(--aq-danger); }
.aq-pa-bar-label .is-warn { color: var(--aq-warn); }
.aq-pa-bar-label .is-ok { color: var(--aq-success); }
.aq-pa-bar-track {
  height: 4px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.06);
  overflow: hidden;
}
.aq-pa-bar-fill {
  height: 100%;
  border-radius: 2px;
  background: var(--aq-success);
}
.aq-pa-bar-fill.is-warn { background: var(--aq-warn); }
.aq-pa-bar-fill.is-down { background: var(--aq-danger); }

/* Inline sparkline cell */
.aq-pa-spark {
  width: 70px;
  height: 24px;
  display: block;
}
.aq-pa-spark path { fill: none; stroke: var(--aq-text-dim); stroke-width: 1.4; }
.aq-pa-spark .is-area { fill: rgba(255, 255, 255, 0.04); stroke: none; }
.aq-pa-spark.is-up path { stroke: var(--aq-success); }
.aq-pa-spark.is-down path { stroke: var(--aq-danger); }

/* Status pill (pending count, alerts) */
.aq-pa-pill-stat {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 20px;
  padding: 0 7px;
  border-radius: 99px;
  background: var(--aq-surface-2);
  font-family: var(--aq-ff-mono);
  font-size: 11px;
  color: var(--aq-text-dim);
  border: 1px solid var(--aq-line);
}
.aq-pa-pill-stat.is-warn {
  color: var(--aq-warn);
  background: color-mix(in srgb, var(--aq-warn) 10%, transparent);
  border-color: color-mix(in srgb, var(--aq-warn) 28%, transparent);
}
.aq-pa-pill-stat.is-danger {
  color: var(--aq-danger);
  background: color-mix(in srgb, var(--aq-danger) 10%, transparent);
  border-color: color-mix(in srgb, var(--aq-danger) 28%, transparent);
}
.aq-pa-pill-stat.is-ok {
  color: var(--aq-success);
  background: color-mix(in srgb, var(--aq-success) 10%, transparent);
  border-color: color-mix(in srgb, var(--aq-success) 28%, transparent);
}
.aq-pa-pill-stat.is-zero { color: var(--aq-text-faint); }

/* Sort chip in row-head */
.aq-pa-sort {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  cursor: pointer;
  color: var(--aq-text-dim);
}
.aq-pa-sort.is-active { color: var(--aq-text); }
.aq-pa-sort svg { width: 10px; height: 10px; stroke-width: 2; opacity: 0.6; }

/* ── Anomaly feed ────────────────────────────────────────────────── */

.aq-pa-anom-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.aq-pa-anom-row {
  display: grid;
  grid-template-columns: 28px 1fr auto auto;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--aq-line);
  align-items: center;
}
.aq-pa-anom-row:last-child { border-bottom: 0; }
.aq-pa-anom-icon {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  display: grid;
  place-items: center;
  font-size: 11px;
}
.aq-pa-anom-icon svg { width: 13px; height: 13px; stroke-width: 1.75; }
.aq-pa-anom-row.is-warn .aq-pa-anom-icon {
  background: color-mix(in srgb, var(--aq-warn) 16%, transparent);
  color: var(--aq-warn);
}
.aq-pa-anom-row.is-danger .aq-pa-anom-icon {
  background: color-mix(in srgb, var(--aq-danger) 16%, transparent);
  color: var(--aq-danger);
}
.aq-pa-anom-row.is-info .aq-pa-anom-icon {
  background: var(--aq-accent-soft);
  color: var(--aq-accent);
}
.aq-pa-anom-body { min-width: 0; }
.aq-pa-anom-title {
  font-size: 12.5px;
  color: var(--aq-text);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.aq-pa-anom-title strong {
  color: var(--aq-text);
  font-weight: 500;
}
.aq-pa-anom-z {
  font-family: var(--aq-ff-mono);
  font-size: 10.5px;
  color: var(--aq-text-faint);
  background: var(--aq-surface-2);
  border: 1px solid var(--aq-line);
  border-radius: 4px;
  padding: 1px 5px;
}
.aq-pa-anom-sub {
  font-size: 11.5px;
  color: var(--aq-text-faint);
  margin-top: 3px;
  font-family: var(--aq-ff-mono);
}
.aq-pa-anom-time {
  font-size: 11px;
  color: var(--aq-text-faint);
  font-family: var(--aq-ff-mono);
  white-space: nowrap;
}
.aq-pa-anom-action {
  font-size: 11.5px;
  color: var(--aq-text-dim);
  display: inline-flex;
  align-items: center;
  gap: 3px;
  cursor: pointer;
}
.aq-pa-anom-action:hover { color: var(--aq-text); }
.aq-pa-anom-action svg { width: 11px; height: 11px; stroke-width: 1.5; }

/* ── Connector matrix ────────────────────────────────────────────── */

.aq-pa-conn-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
.aq-pa-conn {
  display: grid;
  grid-template-columns: 30px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 11px 12px;
  border: 1px solid var(--aq-line);
  border-radius: var(--aq-r-md, 8px);
  background: rgba(255, 255, 255, 0.012);
}
.aq-pa-conn-logo {
  width: 30px; height: 30px;
  border-radius: 6px;
  background: var(--aq-surface-2);
  display: grid;
  place-items: center;
  font-family: var(--aq-ff-display);
  font-weight: 600;
  font-size: 13px;
  color: var(--aq-text);
}
.aq-pa-conn-name {
  font-size: 12.5px;
  color: var(--aq-text);
  line-height: 1.2;
}
.aq-pa-conn-meta {
  font-size: 10.5px;
  color: var(--aq-text-faint);
  font-family: var(--aq-ff-mono);
  margin-top: 3px;
}
.aq-pa-conn-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-family: var(--aq-ff-mono);
  color: var(--aq-text-dim);
}
.aq-pa-conn-status .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--aq-text-faint);
}
.aq-pa-conn-status.is-ok .dot { background: var(--aq-success); box-shadow: 0 0 8px var(--aq-success); }
.aq-pa-conn-status.is-warn .dot { background: var(--aq-warn); box-shadow: 0 0 8px var(--aq-warn); }
.aq-pa-conn-status.is-down .dot { background: var(--aq-danger); box-shadow: 0 0 8px var(--aq-danger); }
.aq-pa-conn-status.is-ok { color: var(--aq-success); }
.aq-pa-conn-status.is-warn { color: var(--aq-warn); }
.aq-pa-conn-status.is-down { color: var(--aq-danger); }

/* ── Heatmap ─────────────────────────────────────────────────────── */

.aq-pa-heat {
  display: grid;
  grid-template-columns: 32px 1fr;
  gap: 8px;
}
.aq-pa-heat-y {
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  font-family: var(--aq-ff-mono);
  font-size: 10px;
  color: var(--aq-text-faint);
  padding: 6px 0;
  text-align: right;
}
.aq-pa-heat-grid {
  display: grid;
  grid-template-columns: repeat(24, 1fr);
  grid-template-rows: repeat(7, 1fr);
  gap: 2px;
}
.aq-pa-heat-cell {
  aspect-ratio: 1.4 / 1;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.025);
  position: relative;
}
.aq-pa-heat-cell[data-heat="1"] { background: color-mix(in srgb, var(--aq-accent) 10%, transparent); }
.aq-pa-heat-cell[data-heat="2"] { background: color-mix(in srgb, var(--aq-accent) 25%, transparent); }
.aq-pa-heat-cell[data-heat="3"] { background: color-mix(in srgb, var(--aq-accent) 45%, transparent); }
.aq-pa-heat-cell[data-heat="4"] { background: color-mix(in srgb, var(--aq-accent) 70%, transparent); }
.aq-pa-heat-cell[data-heat="5"] { background: var(--aq-accent); }
.aq-pa-heat-x {
  display: grid;
  grid-template-columns: repeat(24, 1fr);
  font-family: var(--aq-ff-mono);
  font-size: 9.5px;
  color: var(--aq-text-faint);
  text-align: center;
  margin-top: 6px;
  padding-left: 40px;
}
.aq-pa-heat-x span:nth-child(odd) { visibility: hidden; }
.aq-pa-heat-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  font-size: 11px;
  color: var(--aq-text-faint);
  padding-left: 40px;
}
.aq-pa-heat-scale {
  display: inline-flex;
  gap: 2px;
}
.aq-pa-heat-scale .aq-pa-heat-cell {
  width: 12px;
  aspect-ratio: 1 / 1;
}

/* ── Approval queue mini-cards ───────────────────────────────────── */

.aq-pa-queue {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.aq-pa-queue-row {
  display: grid;
  grid-template-columns: 24px 1fr auto auto;
  gap: 12px;
  align-items: center;
  padding: 11px 0;
  border-bottom: 1px solid var(--aq-line);
}
.aq-pa-queue-row:last-child { border-bottom: 0; }
.aq-pa-queue-name {
  font-size: 12.5px;
  color: var(--aq-text);
  line-height: 1.2;
  display: flex;
  align-items: center;
  gap: 8px;
}
.aq-pa-queue-sub {
  font-size: 11px;
  color: var(--aq-text-faint);
  margin-top: 2px;
  font-family: var(--aq-ff-mono);
}
.aq-pa-queue-pill {
  font-family: var(--aq-ff-mono);
  font-size: 11px;
  color: var(--aq-warn);
  background: color-mix(in srgb, var(--aq-warn) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--aq-warn) 28%, transparent);
  border-radius: 99px;
  padding: 2px 8px;
}

/* ── Funnel ─────────────────────────────────────────────────────── */

.aq-pa-funnel {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
  margin-top: 4px;
}
.aq-pa-funnel-step {
  padding: 14px 16px;
  border-right: 1px solid var(--aq-line);
  position: relative;
}
.aq-pa-funnel-step:last-child { border-right: 0; }
.aq-pa-funnel-label {
  font-size: 11px;
  color: var(--aq-text-faint);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: 500;
  margin-bottom: 8px;
}
.aq-pa-funnel-value {
  font-family: var(--aq-ff-display);
  font-size: 22px;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--aq-text);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.aq-pa-funnel-pct {
  font-size: 11.5px;
  color: var(--aq-text-faint);
  margin-top: 6px;
  font-family: var(--aq-ff-mono);
}
.aq-pa-funnel-bar {
  height: 3px;
  border-radius: 2px;
  background: var(--aq-accent);
  margin-top: 10px;
  opacity: 0.7;
}

/* ── Tighter top padding for the analytics screen.
   In the prototype this used .aq-pa as ancestor; in the real app the
   page sets its own padding via .aq-content. */
.pa-content .aq-content-inner {
  padding-top: 0;
}

/* ──────────────────────────────────────────────────────────────────────
   Variant A — operator-dashboard layout (live AnalyticsScreen)
   ──────────────────────────────────────────────────────────────────────
   Dense KPI strip + 2-col tables + live event log. Uses Layer-A tokens
   (var(--aq-*)) so the chrome auto-tunes to the active theme. */

.x-analytics-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 24px 0 18px;
}
.x-analytics-head h1 {
  font-family: var(--aq-ff-display);
  font-size: 24px; font-weight: 600; letter-spacing: -0.02em;
  margin: 0;
}
.x-analytics-meta {
  color: var(--aq-text-dim);
  font-size: 11.5px;
  font-family: var(--aq-ff-mono);
}
.x-analytics-livebar {
  display: flex; gap: 14px; align-items: center;
  font-size: 11.5px;
}
.x-analytics-livebar-on {
  color: var(--aq-success);
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--aq-ff-mono);
}
.x-analytics-livedot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--aq-success);
  display: inline-block;
  animation: x-analytics-pulse 1.6s infinite;
}
@keyframes x-analytics-pulse {
  0%   { box-shadow: 0 0 0 0 oklch(0.78 0.13 160 / 0.55); }
  70%  { box-shadow: 0 0 0 8px oklch(0.78 0.13 160 / 0); }
  100% { box-shadow: 0 0 0 0 oklch(0.78 0.13 160 / 0); }
}

/* Filter strip */
.x-analytics-filters {
  display: flex; gap: 8px; align-items: center;
  /* No box — chips sit directly on the page surface. */
  padding: 4px 0;
  margin-bottom: 16px;
  font-size: 11.5px;
  flex-wrap: wrap;
}
.x-analytics-filters-label {
  color: var(--aq-text-faint);
  font-size: 10.5px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 1.2px;
}
.x-analytics-chip {
  padding: 4px 10px;
  /* Borderless — state carried by fill, not an outline. */
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--aq-text-dim);
  cursor: pointer;
  user-select: none;
  font-family: var(--aq-ff-sans);
  transition: background 120ms ease, color 120ms ease;
}
.x-analytics-chip:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--aq-text);
}
.x-analytics-chip.is-active {
  background: rgba(255, 255, 255, 0.10);
  color: var(--aq-text);
}
/* Time-range segmented track — one subtle container instead of four
   individually-outlined pills. */
.x-analytics-rangeseg {
  display: inline-flex; gap: 2px; padding: 2px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 8px;
}

/* KPI grid */
.x-analytics-kpis {
  display: grid;
  /* No internal dividers — cell padding gives the separation, so the
     strip reads as one clean band inside its outer border. */
  gap: 0;
  border: 1px solid var(--aq-line);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 18px;
}
.x-analytics-kpi {
  padding: 14px 16px;
  background: var(--aq-surface);
  display: flex; flex-direction: column; gap: 6px;
  min-height: 96px;
}
.x-analytics-kpi-label {
  font-size: 10px; font-weight: 600;
  color: var(--aq-text-faint);
  text-transform: uppercase; letter-spacing: 1.2px;
}
.x-analytics-kpi-value {
  font-family: var(--aq-ff-mono);
  font-size: 26px; font-weight: 500;
  letter-spacing: -0.02em; line-height: 1.05;
  color: var(--aq-text);
}
.x-analytics-kpi-delta {
  display: inline-flex; align-items: center; gap: 4px;
  font-family: var(--aq-ff-mono);
  font-size: 10.5px;
}
.x-analytics-kpi-delta--up   { color: var(--aq-success); }
.x-analytics-kpi-delta--dn   { color: var(--aq-danger); }
.x-analytics-kpi-delta--flat { color: var(--aq-text-faint); }

/* Two-column tables row */
.x-analytics-row2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 18px;
}
@media (max-width: 1100px) {
  .x-analytics-row2 { grid-template-columns: 1fr; }
}
.x-analytics-panel {
  background: var(--aq-surface);
  border: 1px solid var(--aq-line);
  border-radius: 8px;
  overflow: hidden;
}
.x-analytics-panel-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 14px 8px;
}
.x-analytics-panel-title {
  font-size: 11px; font-weight: 600;
  color: var(--aq-text);
  text-transform: uppercase; letter-spacing: 1.2px;
}
.x-analytics-panel-actions {
  display: flex; gap: 12px;
  font-size: 10.5px;
  color: var(--aq-text-dim);
}
.x-analytics-panel-actions a {
  color: var(--aq-text-dim);
  text-decoration: none;
  cursor: pointer;
}
.x-analytics-panel-actions a:hover { color: var(--aq-text); }

/* Tables */
.x-analytics-table {
  width: 100%; border-collapse: collapse;
  font-size: 12px;
}
.x-analytics-table th, .x-analytics-table td {
  padding: 7px 14px;
  text-align: left;
  border-bottom: 1px solid var(--aq-line);
}
.x-analytics-table th {
  font-size: 10px; font-weight: 600;
  color: var(--aq-text-faint);
  text-transform: uppercase; letter-spacing: 1px;
  /* No band, no divider — column labels sit in muted text on the card
     surface; row separators below still carry the structure. */
  background: transparent;
  border-bottom: 0;
}
.x-analytics-table tbody tr:last-child td { border-bottom: 0; }
.x-analytics-table tbody tr:hover { background: var(--aq-surface-2); cursor: pointer; }
.x-analytics-table-num {
  font-family: var(--aq-ff-mono);
  font-variant-numeric: tabular-nums;
}

/* Live event log rows */
.x-analytics-log-row {
  display: grid;
  grid-template-columns: 80px 130px 100px 1fr 110px;
  gap: 12px;
  padding: 7px 14px;
  border-bottom: 1px solid var(--aq-line);
  font-family: var(--aq-ff-mono);
  font-size: 11.5px;
  align-items: center;
}
.x-analytics-log-row:last-child { border-bottom: 0; }
.x-analytics-log-t      { color: var(--aq-text-faint); }
.x-analytics-log-ev     { color: var(--aq-text-dim); }
.x-analytics-ev-scan    { color: oklch(0.66 0.16 270); }
.x-analytics-ev-sale    { color: var(--aq-success); }
.x-analytics-ev-alert   { color: var(--aq-warn); }
.x-analytics-log-scope  { color: var(--aq-text-faint); }
.x-analytics-log-who    { color: var(--aq-text); }
.x-analytics-log-val    { color: var(--aq-text); text-align: right; }

/* ─── Custom-dashboard panel grid (Phase M) ─────────────────────
   12-col grid on desktop. Each panel sets its own grid-column span
   inline (4/6/8/12). On mobile we collapse to a single column so
   panels stack instead of getting squished into 30px slivers. */
.x-dashboard-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 14px;
}
@media (max-width: 768px) {
  .x-dashboard-grid {
    grid-template-columns: 1fr;
  }
  /* Force every panel to full width regardless of its desktop size. */
  .x-dashboard-grid > * {
    grid-column: 1 / -1 !important;
  }
}

/* ─── Mobile responsive (Phase N) ────────────────────────────────
   Below 768px we collapse to a single column and tighten spacing
   so the dashboard remains usable on a phone (operators do check
   mid-tour). Tables become horizontally scrollable inside their
   own scroll container so column widths don't squish into chaos. */
@media (max-width: 768px) {
  .x-analytics-head {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 12px;
  }
  .x-analytics-head h1 { font-size: 18px; }

  /* Filter strip — wrap nicely + tighter padding. */
  .x-analytics-filters {
    padding: 8px 10px;
    gap: 6px;
  }
  .x-analytics-filters-label {
    width: 100%;
    margin-bottom: 4px;
  }
  .x-analytics-chip {
    padding: 5px 9px;
    font-size: 11px;
  }

  /* KPI tiles → vertical stack. The inline gridTemplateColumns from
     analytics.jsx wins via specificity, so use !important to override
     for this breakpoint only. */
  .x-analytics-kpis {
    grid-template-columns: 1fr 1fr !important;
  }
  .x-analytics-kpi {
    padding: 10px 12px;
    min-height: 80px;
  }
  .x-analytics-kpi-value { font-size: 20px; }

  /* Two-col → one. */
  .x-analytics-row2 { grid-template-columns: 1fr; gap: 12px; }

  /* Panel padding tightens; tables horizontal-scroll. */
  .x-analytics-panel-head {
    flex-wrap: wrap;
    padding: 10px 12px;
    gap: 6px;
  }
  .x-analytics-panel-actions { font-size: 10.5px; }
  .x-analytics-panel { overflow-x: auto; }
  .x-analytics-table { min-width: 480px; }
  .x-analytics-table th, .x-analytics-table td {
    padding: 8px 10px;
    font-size: 12px;
  }
}

/* Even tighter for narrow phones (<420px): stack KPI tiles fully. */
@media (max-width: 420px) {
  .x-analytics-kpis { grid-template-columns: 1fr !important; }
  .aq-content-inner { padding-left: 12px !important; padding-right: 12px !important; }
}
