feat(web): replace UI with greenfield Stitch sensing-engine hero

Rebuild the web frontend around the Stitch hero design: new app shell header with responsive navigation and a single / page preserving the Stitch main/footer copy. Remove the legacy Onyx pages, components, composables and CSS. Add bundled Tailwind 3.4.17 and @nuxt/icon with a locally bundled Material Symbols collection; no icon CDN at runtime. Include design notes for claims to reconcile before the pitch and verification screenshots.
This commit is contained in:
Noel Sabia committed 2026-11-14 17:06:35 +01:00
1 parent 9b61d6859e
commit 836e71c5f4
33 files changed
+1377 -4326

No files matched your search

-152
View File
@@ -1,152 +0,0 @@
<script setup lang="ts">
import { iconCircleInformation, iconShieldUser, iconTriangleWarning } from '@sit-onyx/icons'
import type { MetaResponse } from '#shared/types'
import { formatDate, formatDateTime, formatPercent } from '~/utils/format'
useHead({ title: 'About the data and limits — PulseCast' })
const { data: meta } = await useFetch<MetaResponse>('/api/meta')
const config = useRuntimeConfig()
const usingMock = computed(() => ['1', 'true'].includes(String(config.public.useMock).toLowerCase()))
</script>
<template>
<div class="page page-stack">
<header class="page-header">
<div>
<p class="eyebrow">About · method, data and limits</p>
<OnyxHeadline is="h1">A decision aid, not a city-wide truth.</OnyxHeadline>
<p class="lede">
PulseCast turns a footfall forecast into a next-week staffing plan. The forecast is a model output; the
staffing rule is a transparent heuristic. Both are shown, editable, and bounded.
</p>
</div>
<OnyxBadge color="warning">Hackathon prototype</OnyxBadge>
</header>
<div class="summary-grid">
<MetricCard
label="Sensors"
:value="String(meta?.coverage.sensors ?? 8)"
hint="Fixed points in a 580 m inner-city cluster."
:icon="iconCircleInformation"
/>
<MetricCard
label="Model WAPE"
:value="meta ? formatPercent(meta.metrics.wape, 1) : '—'"
:badge="meta ? `baseline ${formatPercent(meta.metrics.baseline_wape, 1)}` : undefined"
badge-color="success"
hint="Time-based holdout, not a random split."
/>
<MetricCard
label="R²"
:value="meta ? meta.metrics.r2.toFixed(3) : '—'"
:hint="meta ? `MAE ${meta.metrics.mae} devices/hour` : undefined"
/>
<MetricCard
label="Cadence"
:value="meta ? `${meta.coverage.cadence_min} min` : '—'"
:hint="meta ? `${formatDate(meta.coverage.from)} → ${formatDate(meta.coverage.to)}` : undefined"
/>
</div>
<div class="split-grid">
<div class="card-stack">
<OnyxCard>
<div class="card-header">
<OnyxHeadline is="h2">How the plan is made</OnyxHeadline>
<OnyxBadge color="info" density="compact">transparent heuristic</OnyxBadge>
</div>
<ol class="small" style="margin: 0; padding-left: 1.2rem; display: grid; gap: var(--onyx-density-sm)">
<li>Forecast estimated devices per hour for the next 7 days.</li>
<li>Divide by visitors per staff-hour, multiply by a safety factor, round up, apply minimum staff.</li>
<li>Cover 10:00–20:00 with consecutive shift blocks; a block gets the peak requirement inside it.</li>
<li>Score coverage, cost, over/understaffed hours and compare with a flat schedule.</li>
<li>Show the weather, holiday and assumption drivers; let the manager edit and regenerate.</li>
</ol>
<div class="callout" style="margin-top: var(--onyx-density-md)">
<p class="small" style="margin: 0">
There is no POS, sales, queue, payroll or labour-cost feed. Cost is an assumption. The coverage score
is high by construction because shift blocks cover their local peak; overstaffed hours are the honest
trade-off.
</p>
</div>
</OnyxCard>
<OnyxCard>
<div class="card-header">
<OnyxHeadline is="h2">Model and data coverage</OnyxHeadline>
</div>
<OnyxTable striped :table-attrs="{ style: 'min-width: 34rem' }">
<template #head>
<tr><th scope="col">Field</th><th scope="col">Value</th></tr>
</template>
<tr><th scope="row" style="text-align: left; font-weight: 600">Data version</th><td class="mono">{{ meta?.data_version ?? '—' }}</td></tr>
<tr><th scope="row" style="text-align: left; font-weight: 600">Model version</th><td class="mono">{{ meta?.model_version ?? '—' }}</td></tr>
<tr><th scope="row" style="text-align: left; font-weight: 600">Context version</th><td class="mono">{{ meta?.context_version ?? '—' }}</td></tr>
<tr><th scope="row" style="text-align: left; font-weight: 600">Coverage</th><td>{{ meta ? `${formatDate(meta.coverage.from)} → ${formatDate(meta.coverage.to)}` : '—' }}</td></tr>
<tr><th scope="row" style="text-align: left; font-weight: 600">Validation</th><td>{{ meta ? `WAPE ${formatPercent(meta.metrics.wape, 1)} · baseline ${formatPercent(meta.metrics.baseline_wape, 1)} · R² ${meta.metrics.r2}` : '—' }}</td></tr>
<tr><th scope="row" style="text-align: left; font-weight: 600">Weather source</th><td>Open-Meteo archive + forecast via /api/context</td></tr>
<tr><th scope="row" style="text-align: left; font-weight: 600">Holidays</th><td>Baden-Württemberg 2025–2026 public holidays</td></tr>
</OnyxTable>
<p class="small muted table-note">Meta comes from Go <code>/api/meta</code> through the Nitro proxy.</p>
</OnyxCard>
<TrainModelCard />
</div>
<aside class="card-stack">
<OnyxCard>
<div class="card-header">
<OnyxHeadline is="h2">Limits</OnyxHeadline>
<OnyxIcon :icon="iconTriangleWarning" size="24px" color="warning" />
</div>
<ul class="why-list">
<li v-for="limit in meta?.limits ?? []" :key="limit">
<OnyxIcon :icon="iconTriangleWarning" size="16px" color="warning" />
<span>{{ limit }}</span>
</li>
</ul>
<p class="small muted table-note">
Eight sensors in one pedestrian cluster cannot rank commercial zones across Heilbronn. There is no
city-wide heatmap claim here.
</p>
</OnyxCard>
<OnyxCard>
<div class="card-header">
<OnyxHeadline is="h2">Privacy</OnyxHeadline>
<OnyxIcon :icon="iconShieldUser" size="24px" color="primary" />
</div>
<ul class="small" style="margin: 0; padding-left: 1.1rem; display: grid; gap: var(--onyx-density-xs)">
<li>No PII, MAC addresses or geolocation permission.</li>
<li>Audience sessions use a random ID only.</li>
<li>Public read-only screens; control actions are authenticated separately.</li>
<li>Raw challenge CSV and secrets stay out of this repository.</li>
</ul>
</OnyxCard>
<OnyxCard>
<div class="card-header">
<OnyxHeadline is="h3">Data source</OnyxHeadline>
<OnyxBadge :color="usingMock ? 'warning' : 'success'" density="compact">
{{ usingMock ? 'Mock mode' : 'Go API' }}
</OnyxBadge>
</div>
<p v-if="usingMock" class="small muted" style="margin-top: 0">
Explicit dev fallback: <code>NUXT_PUBLIC_USE_MOCK=1</code>. Mock JSON renders the app without the Go
service; the plan heuristic is the shared implementation in <code>shared/staffing.ts</code>.
</p>
<p v-else class="small muted" style="margin-top: 0">
The browser only talks to this Nuxt origin. Nitro proxies /api/* to the Go API at
<code>NUXT_API_INTERNAL_BASE</code>; forecast, context and meta are served from there.
</p>
<p class="small muted" style="margin: 0">
Last context update: {{ meta ? formatDateTime(meta.context_version) : '—' }}
</p>
</OnyxCard>
</aside>
</div>
</div>
</template>
-269
View File
@@ -1,269 +0,0 @@
<script setup lang="ts">
import {
iconArrowRight,
iconCircleCheck,
iconCircleX,
iconPresentionBoard,
iconSync,
iconTriangleWarning,
} from '@sit-onyx/icons'
import { scenarioLabel } from '#shared/live'
import type { ScenarioPreset, ScenarioState } from '#shared/types'
import { apiErrorMessage, apiErrorStatus } from '~/utils/api-error'
import { formatDateTime } from '~/utils/format'
useHead({ title: 'Presenter control — PulseCast' })
const { data: initialScenario } = await useFetch<ScenarioState>('/api/scenario')
const { data: presets, error: presetsError } = await useFetch<ScenarioPreset[]>('/api/scenarios')
const live = useLiveScenario(initialScenario.value)
const submitted = ref<ScenarioState | null>(null)
const busy = ref('')
const message = ref('')
const errorMessage = ref('')
const current = computed(() => {
const liveState = live.scenario
const local = submitted.value
if (!liveState) return local ?? initialScenario.value ?? null
if (!local) return liveState
// A remote presenter can move the stage on; always show the newer version.
return liveState.version >= local.version ? liveState : local
})
const activeId = computed(() => current.value?.scenario.scenario ?? '')
const presetList = computed(() => presets.value ?? [])
function applyBody(preset: ScenarioPreset) {
return {
scenario: preset.id,
weather: preset.weather ?? {},
event: preset.event,
}
}
async function apply(preset: ScenarioPreset) {
if (busy.value) return
busy.value = preset.id
message.value = ''
errorMessage.value = ''
try {
const response = await $fetch<ScenarioState>('/api/scenario', {
method: 'POST',
body: applyBody(preset),
})
submitted.value = response
message.value = `${preset.label} is now live · version ${response.version}.`
} catch (error) {
errorMessage.value =
apiErrorMessage(error, 'The scenario change failed. Check the Go API and control credentials.') +
(apiErrorStatus(error) === 401 ? ' Reload this page to sign in again.' : '')
} finally {
busy.value = ''
}
}
</script>
<template>
<div class="page page-stack control-page">
<header class="page-header">
<div>
<p class="eyebrow">Presenter control · not linked in public navigation</p>
<OnyxHeadline is="h1">Change the scenario once. Every screen follows.</OnyxHeadline>
<p class="lede">
Each button POSTs to this Nuxt origin. Nitro attaches the Go control credentials server-side; the browser
never sees them. <NuxtLink to="/stage">Stage</NuxtLink> and <NuxtLink to="/live">Live</NuxtLink> update through
SSE, with a 5-second polling fallback.
</p>
</div>
<div class="hero-actions">
<LiveStatusBadge :status="live.status" :last-event-at="live.lastEventAt" />
<OnyxBadge v-if="current" color="neutral" density="compact">v{{ current.version }}</OnyxBadge>
</div>
</header>
<div v-if="errorMessage" class="callout callout--warning" role="alert">
<OnyxIcon :icon="iconCircleX" size="16px" color="danger" />
<span>{{ errorMessage }}</span>
</div>
<div v-if="message" class="callout" role="status">
<OnyxIcon :icon="iconCircleCheck" size="16px" color="success" />
<span>{{ message }}</span>
</div>
<div class="split-grid">
<div class="card-stack">
<OnyxCard>
<div class="card-header">
<div>
<OnyxHeadline is="h2">Scenario presets</OnyxHeadline>
<p class="small muted" style="margin: 0">
The enum is fixed by CONTRACT.md. Weather and event values match the demo narrative.
</p>
</div>
<OnyxBadge color="info" density="compact">server proxy</OnyxBadge>
</div>
<div v-if="presetList.length" class="scenario-grid">
<button
v-for="preset in presetList"
:key="preset.id"
type="button"
class="scenario-button"
:class="{ 'scenario-button--active': preset.id === activeId }"
:disabled="Boolean(busy)"
:aria-pressed="preset.id === activeId"
@click="apply(preset)"
>
<span class="scenario-button__head">
<strong>{{ preset.label }}</strong>
<OnyxBadge v-if="preset.id === activeId" color="success" density="compact">on stage</OnyxBadge>
<OnyxBadge v-else color="neutral" density="compact">{{ preset.short }}</OnyxBadge>
</span>
<span class="small muted">{{ preset.description }}</span>
<span v-if="busy === preset.id" class="scenario-button__busy">
<OnyxIcon :icon="iconSync" size="16px" color="primary" class="spin" />
Broadcasting…
</span>
<span v-else class="scenario-button__action">
Apply
<OnyxIcon :icon="iconArrowRight" size="16px" color="primary" />
</span>
</button>
</div>
<div v-else class="callout callout--warning">
<OnyxIcon :icon="iconTriangleWarning" size="16px" color="warning" />
Scenario presets could not be loaded.
<span v-if="presetsError" class="muted">{{ presetsError.statusMessage }}</span>
</div>
</OnyxCard>
<OnyxCard>
<div class="card-header">
<OnyxHeadline is="h2">Open the audience views</OnyxHeadline>
<OnyxIcon :icon="iconPresentionBoard" size="24px" color="primary" />
</div>
<div class="hero-actions">
<OnyxButton label="Open /stage" link="/stage" color="primary" />
<OnyxButton label="Open /live" link="/live" mode="outline" />
<OnyxButton label="Open /plan" link="/plan" mode="outline" />
</div>
<p class="small muted table-note">
Put <code>/stage</code> on the projector and let the audience scan the QR code. <code>/live</code> needs no
login and keeps the last known plan if the stream drops.
</p>
</OnyxCard>
</div>
<aside class="card-stack">
<OnyxCard>
<div class="card-header">
<OnyxHeadline is="h2">Current scenario</OnyxHeadline>
<LiveStatusBadge :status="live.status" :last-event-at="live.lastEventAt" compact />
</div>
<p class="control-current">{{ current ? scenarioLabel(current.scenario.scenario) : 'Unavailable' }}</p>
<dl class="metric-list">
<div><dt>Version</dt><dd>{{ current?.version ?? '—' }}</dd></div>
<div><dt>Broadcast at</dt><dd>{{ current ? formatDateTime(current.at) : '—' }}</dd></div>
<div><dt>Last SSE event</dt><dd>{{ live.lastEventAt ? formatDateTime(live.lastEventAt) : '—' }}</dd></div>
<div><dt>Transport</dt><dd>{{ live.statusLabel }}</dd></div>
</dl>
<p v-if="live.error" class="small muted table-note">{{ live.error }}</p>
</OnyxCard>
<OnyxCard>
<div class="card-header">
<OnyxHeadline is="h3">What the presenter says</OnyxHeadline>
</div>
<ul class="why-list">
<li><span><strong>Base week</strong> — normal weather, no event uplift.</span></li>
<li><span><strong>Sunny Saturday + market</strong> — the Saturday plan should add staff.</span></li>
<li><span><strong>Rainy Saturday</strong> — the Saturday plan should shed staff.</span></li>
<li><span><strong>Wednesday event</strong> — the weekday evening block should rise.</span></li>
</ul>
<p class="small muted table-note">
If the numbers do not move on stage, check the <code>cached</code> badge: Go may be serving its last good
forecast because the ML service is down.
</p>
</OnyxCard>
</aside>
</div>
</div>
</template>
<style scoped>
.control-current {
margin: 0 0 var(--onyx-density-md);
color: var(--onyx-color-text-icons-primary-intense);
font-size: clamp(1.6rem, 3vw, 2.4rem);
font-weight: 700;
line-height: 1.1;
}
.scenario-button {
display: flex;
flex-direction: column;
gap: var(--onyx-density-xs);
width: 100%;
padding: var(--onyx-density-md);
border: 1px solid var(--onyx-color-base-neutral-300);
border-radius: var(--onyx-radius-component-container-soft);
background: var(--onyx-color-base-neutral-100);
color: inherit;
font: inherit;
text-align: left;
cursor: pointer;
}
.scenario-button:hover:not(:disabled),
.scenario-button:focus-visible {
border-color: var(--onyx-color-base-primary-500);
outline: 2px solid var(--onyx-color-base-primary-300);
outline-offset: 1px;
}
.scenario-button:disabled {
cursor: progress;
opacity: 0.65;
}
.scenario-button--active {
border-color: var(--onyx-color-base-primary-600);
background: var(--onyx-color-base-primary-100);
}
.scenario-button__head,
.scenario-button__action,
.scenario-button__busy {
display: flex;
flex-wrap: wrap;
align-items: center;
justify-content: space-between;
gap: var(--onyx-density-xs);
}
.scenario-button__action,
.scenario-button__busy {
justify-content: flex-start;
margin-top: var(--onyx-density-xs);
color: var(--onyx-color-text-icons-neutral-medium);
font-size: 0.8125rem;
}
.spin {
animation: spin 0.9s linear infinite;
}
@keyframes spin {
to {
transform: rotate(360deg);
}
}
@media (prefers-reduced-motion: reduce) {
.spin {
animation: none;
}
}
</style>
-320
View File
@@ -1,320 +0,0 @@
<script setup lang="ts">
import { iconCalendar, iconChart, iconTriangleWarning } from '@sit-onyx/icons'
import { dailyWeather } from '#shared/insights'
import { berlinParts, planWeekStart, STANDARD_VISITORS_PER_STAFF_HOUR } from '#shared/staffing'
import type { ContextResponse, ForecastResponse, MetaResponse, Point, Scenario, ScenarioPreset, ScenarioState, Sensor } from '#shared/types'
import { formatDate, formatNumber, formatPercent, formatShortDate, formatWeekday, formatWeekdayShort, weekLabel } from '~/utils/format'
useHead({ title: 'Forecast — PulseCast' })
const config = useRuntimeConfig()
const demoNow = String(config.public.demoNow)
const weekStart = planWeekStart(demoNow)
const weekEnd = new Date(new Date(`${weekStart}T12:00:00Z`).getTime() + 6 * 86400000)
.toISOString()
.slice(0, 10)
const sensorId = ref('hn-stadtgalerie-01')
const scenario = ref<Scenario>('base')
const { data: sensors } = await useFetch<Sensor[]>('/api/sensors')
const { data: context } = await useFetch<ContextResponse>('/api/context')
const { data: meta } = await useFetch<MetaResponse>('/api/meta')
const { data: presets } = await useFetch<ScenarioPreset[]>('/api/scenarios')
const { data: liveScenarioState } = await useFetch<ScenarioState>('/api/scenario')
const live = useLiveScenario(liveScenarioState.value)
scenario.value = live.scenarioId
sensorId.value =
sensors.value?.find((sensor) => sensor.id === 'hn-stadtgalerie-01')?.id ??
sensors.value?.[0]?.id ??
sensorId.value
const {
data: forecast,
error: forecastError,
refresh: refreshForecast,
} = await useFetch<ForecastResponse>('/api/forecast', {
query: computed(() => ({ sensor: sensorId.value, horizon: '7d', scenario: scenario.value })),
})
watch(
() => live.revision,
() => {
if (live.scenarioId !== scenario.value) scenario.value = live.scenarioId
else void refreshForecast()
},
)
const activeSensor = computed(() => sensors.value?.find((sensor) => sensor.id === sensorId.value))
const sensorOptions = computed(() =>
(sensors.value ?? []).map((sensor) => ({ value: sensor.id, label: sensor.name })),
)
const scenarioOptions = computed(() =>
(presets.value ?? []).map((preset) => ({ value: preset.id, label: preset.label })),
)
interface DayForecast {
date: string
points: Point[]
mean: number
peak: number
peakHour: number
weather?: ReturnType<typeof dailyWeather>[string]
requiredAtPeak: number
}
const days = computed<DayForecast[]>(() => {
const grouped: Record<string, Point[]> = {}
for (const point of forecast.value?.points ?? []) {
const { date } = berlinParts(point.t)
;(grouped[date] ??= []).push(point)
}
const weather = dailyWeather(context.value?.weather.forecast ?? [])
return Object.keys(grouped)
.sort()
.map((date) => {
const points = grouped[date]!
const peakPoint = points.reduce((best, point) => (point.v > best.v ? point : best))
const mean = points.reduce((sum, point) => sum + point.v, 0) / points.length
return {
date,
points,
mean: Math.round(mean),
peak: peakPoint.v,
peakHour: berlinParts(peakPoint.t).hour,
weather: weather[date],
requiredAtPeak: Math.max(
1,
Math.ceil((peakPoint.v / STANDARD_VISITORS_PER_STAFF_HOUR.standard) * 1.15),
),
}
})
})
const weekPeak = computed(() =>
days.value.length ? days.value.reduce((best, day) => (day.peak > best.peak ? day : best)) : undefined,
)
const dayMax = computed(() => Math.max(...days.value.map((day) => day.peak), 1))
// The API 7-day window starts at the current hour, so it spans up to eight
// calendar days. Label the real window instead of the Monday plan week.
const forecastStart = computed(() => days.value[0]?.date ?? weekStart)
const forecastEnd = computed(() => days.value.at(-1)?.date ?? weekEnd)
const forecastWindow = computed(() => weekLabel(forecastStart.value, forecastEnd.value))
const weekWeather = computed(() =>
Object.values(dailyWeather(context.value?.weather.forecast ?? []))
.filter((day) => day.date >= forecastStart.value && day.date <= forecastEnd.value)
.sort((a, b) => a.date.localeCompare(b.date)),
)
const total = computed(() => days.value.reduce((sum, day) => sum + day.mean, 0))
</script>
<template>
<div class="page page-stack">
<header class="page-header">
<div>
<p class="eyebrow">Forecast · {{ forecastWindow }}</p>
<OnyxHeadline is="h1">Next week peaks on {{ weekPeak ? formatWeekday(weekPeak.date) : '—' }}.</OnyxHeadline>
<p class="lede">
A 168-hour forecast for <strong>{{ activeSensor?.name ?? 'the selected store' }}</strong>, aggregated by
day. The decision, shift blocks and hourly coverage are on <NuxtLink to="/plan">Plan</NuxtLink>.
</p>
</div>
<div class="forecast-header-controls">
<LiveStatusBadge :status="live.status" :last-event-at="live.lastEventAt" />
<div style="min-width: 14rem">
<OnyxSelect
v-model="sensorId"
label="Sensor"
list-label="Inner-city sensors"
:options="sensorOptions"
density="compact"
/>
</div>
</div>
</header>
<div v-if="forecastError" class="callout callout--warning" role="alert">
<OnyxIcon :icon="iconTriangleWarning" size="16px" color="warning" />
The forecast could not be loaded. <span class="muted">{{ forecastError.statusMessage }}</span>
<OnyxButton label="Retry" mode="plain" density="compact" @click="refreshForecast()" />
</div>
<div v-else-if="forecast && !days.length" class="callout callout--warning" role="status">
<OnyxIcon :icon="iconTriangleWarning" size="16px" color="warning" />
No forecast points are available for this store yet. Try another sensor.
</div>
<OnyxCard>
<div class="card-header">
<div>
<OnyxHeadline is="h2">Daily shape</OnyxHeadline>
<p class="small muted" style="margin: 0">
Peak estimated devices per hour. Weather is context, not a causal claim.
</p>
</div>
<div style="min-width: 15rem">
<OnyxSelect
v-model="scenario"
label="Scenario"
list-label="Demo scenarios"
:options="scenarioOptions"
density="compact"
/>
</div>
</div>
<div class="forecast-bars" role="img" aria-label="Daily peak forecast">
<div v-for="day in days" :key="day.date" class="forecast-bar">
<span class="small muted">{{ formatNumber(day.peak) }}</span>
<div class="forecast-bar__track">
<div class="forecast-bar__fill" :style="{ height: `${Math.max(4, (day.peak / dayMax) * 100)}%` }" />
</div>
<strong>{{ formatWeekdayShort(day.date) }}</strong>
<span class="small muted">{{ formatShortDate(day.date) }}</span>
</div>
</div>
<OnyxTable striped with-page-scrolling :table-attrs="{ style: 'min-width: 46rem' }" style="margin-top: var(--onyx-density-lg)">
<template #head>
<tr>
<th scope="col">Day</th>
<th scope="col">Mean</th>
<th scope="col">Peak</th>
<th scope="col">Peak hour</th>
<th scope="col">80% band at peak</th>
<th scope="col">Weather</th>
<th scope="col">Staff at peak</th>
</tr>
</template>
<tr v-for="day in days" :key="day.date">
<th scope="row" style="text-align: left; font-weight: 600">
{{ formatWeekday(day.date) }}
<span class="muted" style="font-weight: 400">{{ formatShortDate(day.date) }}</span>
<OnyxBadge v-if="day.date === weekPeak?.date" color="warning" density="compact" style="margin-left: 0.35rem">peak</OnyxBadge>
</th>
<td>{{ formatNumber(day.mean) }}</td>
<td>{{ formatNumber(day.peak) }}</td>
<td>{{ String(day.peakHour).padStart(2, '0') }}:00</td>
<td>{{ formatNumber(day.points.find((point) => point.v === day.peak)?.lo ?? 0) }}–{{ formatNumber(day.points.find((point) => point.v === day.peak)?.hi ?? 0) }}</td>
<td>
<template v-if="day.weather">
{{ Math.round(day.weather.tempMin) }}–{{ Math.round(day.weather.tempMax) }} °C · {{ day.weather.precipMm.toFixed(1) }} mm
</template>
<span v-else class="muted">outside weather window</span>
</td>
<td><OnyxBadge color="neutral" density="compact">{{ day.requiredAtPeak }}</OnyxBadge></td>
</tr>
</OnyxTable>
<p class="small muted table-note">
Scroll the table sideways on a phone for the uncertainty band and staffing columns. Weekly mean
{{ formatNumber(total) }} estimated devices/hour across open+closed hours. Staff at peak uses 25
visitors/staff-hour × 1.15; the plan can use a different standard.
</p>
</OnyxCard>
<div class="split-grid">
<OnyxCard>
<div class="card-header">
<OnyxHeadline is="h2">Weather strip</OnyxHeadline>
<OnyxBadge color="neutral" density="compact">Open-Meteo context</OnyxBadge>
</div>
<WeatherStrip :days="weekWeather" />
<p v-if="!weekWeather.length" class="small muted table-note">
The weather window does not cover the plan week.
</p>
<p class="small muted table-note">
Weather is the main accuracy driver in the model. Holidays are context and a smaller feature.
</p>
</OnyxCard>
<OnyxCard>
<div class="card-header">
<OnyxHeadline is="h2">Read it honestly</OnyxHeadline>
<OnyxIcon :icon="iconChart" size="24px" color="primary" />
</div>
<ul class="why-list">
<li>
<OnyxIcon :icon="iconCalendar" size="16px" color="primary" />
<span>168 hourly points from the API 7-day horizon, not a live stream.</span>
</li>
<li>
<OnyxIcon :icon="iconChart" size="16px" color="primary" />
<span>
Mean WAPE {{ meta ? formatPercent(meta.metrics.wape, 1) : '—' }} vs
{{ meta ? formatPercent(meta.metrics.baseline_wape, 1) : '—' }} seasonal naive in the API meta;
per-hour uncertainty is real.
</span>
</li>
<li>
<OnyxIcon :icon="iconCalendar" size="16px" color="primary" />
<span>
Forecast covers {{ formatDate(forecastStart) }} → {{ formatDate(forecastEnd) }} in Europe/Berlin.
</span>
</li>
</ul>
<OnyxButton label="Turn this into a plan" link="/plan" color="primary" style="margin-top: var(--onyx-density-md)" />
</OnyxCard>
</div>
</div>
</template>
<style scoped>
.forecast-bars {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(4.5rem, 1fr));
gap: var(--onyx-density-xs);
align-items: end;
min-height: 13rem;
}
.forecast-bar {
display: flex;
min-width: 0;
flex-direction: column;
align-items: center;
gap: 0.2rem;
text-align: center;
}
.forecast-bar strong {
font-size: 0.8125rem;
}
.forecast-bar__track {
display: flex;
width: 100%;
height: 8rem;
align-items: flex-end;
border-radius: 3px;
background: var(--onyx-color-base-neutral-200);
}
.forecast-bar__fill {
width: 100%;
border-radius: 3px 3px 0 0;
background: var(--onyx-color-base-primary-500);
}
.forecast-header-controls {
display: flex;
flex-wrap: wrap;
align-items: flex-end;
gap: var(--onyx-density-sm);
}
@media (max-width: 576px) {
.forecast-bars {
grid-template-columns: repeat(4, minmax(0, 1fr));
gap: var(--onyx-density-2xs);
}
.forecast-bar strong {
font-size: 0.7rem;
}
.forecast-bar .small {
font-size: 0.65rem;
}
}
</style>
+247 -258
View File
@@ -1,268 +1,257 @@
<script setup lang="ts">
import {
iconCalendar,
iconCloud,
iconLocationPin,
iconSunny,
iconTriangleWarning,
} from '@sit-onyx/icons'
import { weatherKind } from '#shared/insights'
import { berlinParts } from '#shared/staffing'
import type { ContextResponse, MetaResponse, Sensor, SeriesResponse } from '#shared/types'
import {
formatDate,
formatDateTime,
formatNumber,
formatPercent,
formatShortDate,
formatTime,
} from '~/utils/format'
useHead({ title: 'Now in Heilbronn — PulseCast' })
const config = useRuntimeConfig()
const demoNow = String(config.public.demoNow)
const { data: sensors } = await useFetch<Sensor[]>('/api/sensors')
const { data: context } = await useFetch<ContextResponse>('/api/context')
const { data: meta } = await useFetch<MetaResponse>('/api/meta')
const sensorId = ref(
sensors.value?.find((sensor) => sensor.id === 'hn-stadtgalerie-01')?.id ??
sensors.value?.[0]?.id ??
'hn-stadtgalerie-01',
)
const { data: series } = await useFetch<SeriesResponse>('/api/series', {
query: computed(() => ({ sensor: sensorId.value, step: '1h' })),
})
const activeSensor = computed(() => sensors.value?.find((sensor) => sensor.id === sensorId.value))
const sensorOptions = computed(() =>
(sensors.value ?? []).map((sensor) => ({ value: sensor.id, label: sensor.name })),
)
const lastPoint = computed(() => series.value?.points.at(-1))
const previousPoint = computed(() => series.value?.points.at(-25))
const deltaPct = computed(() => {
if (!lastPoint.value || !previousPoint.value || previousPoint.value.v === 0) return 0
return ((lastPoint.value.v - previousPoint.value.v) / previousPoint.value.v) * 100
})
const last24 = computed(() => series.value?.points.slice(-24) ?? [])
const barMax = computed(() => Math.max(...last24.value.map((point) => point.v), 1))
const nowWeather = computed(() => context.value?.weather.now)
const weatherIcon = computed(() =>
nowWeather.value && weatherKind(nowWeather.value) === 'sunny' ? iconSunny : iconCloud,
)
const weatherLabel = computed(() => {
if (!nowWeather.value) return '—'
const kind = weatherKind(nowWeather.value)
return kind === 'sunny' ? 'Sunny' : kind === 'partly-cloudy' ? 'Partly cloudy' : kind === 'rain' ? 'Rain' : 'Cloudy'
})
const today = berlinParts(demoNow).date
const todayHoliday = computed(() => context.value?.holidays.find((holiday) => holiday.date === today))
const lastHoliday = computed(() =>
context.value?.holidays.filter((holiday) => holiday.date < today).at(-1),
)
const nextHoliday = computed(() =>
context.value?.holidays.find((holiday) => holiday.date > today),
)
const latestPulse = computed(() => {
if (!sensors.value?.length) return 0
return Math.round(sensors.value.reduce((sum, sensor) => sum + sensor.mean, 0) / sensors.value.length)
})
</script>
<template>
<div class="page page-stack">
<header class="page-header">
<div>
<p class="eyebrow">Now · replay clock {{ formatDateTime(demoNow) }}</p>
<OnyxHeadline is="h1">The pulse is in the pedestrian core.</OnyxHeadline>
<p class="lede">
Eight fixed sensors around Stadtgalerie and Kaiserstraße. This is estimated device density, not people,
and not a city-wide heatmap. The decision lives on <NuxtLink to="/plan">Plan</NuxtLink>.
</p>
</div>
<div class="hero-actions">
<OnyxBadge color="warning">Replay, not live</OnyxBadge>
<OnyxBadge color="neutral" density="compact">{{ sensors?.length ?? 8 }} sensors</OnyxBadge>
</div>
</header>
<div class="split-grid">
<div class="card-stack">
<OnyxCard>
<div class="card-header">
<div>
<OnyxHeadline is="h2">Latest replay reading</OnyxHeadline>
<p class="small muted" style="margin: 0">Last available hour in the API series.</p>
</div>
<div style="min-width: 12rem">
<OnyxSelect
v-model="sensorId"
label="Sensor"
list-label="Inner-city sensors"
:options="sensorOptions"
density="compact"
/>
</div>
</div>
<div class="reading-row">
<p class="reading-value">{{ lastPoint ? formatNumber(lastPoint.v) : '—' }}</p>
<div>
<p style="margin: 0; font-weight: 600">estimated devices / hour</p>
<p class="small muted" style="margin: 0">
{{ activeSensor?.name }} · {{ activeSensor?.id }}
<main class="w-full pt-16 bg-[#081723] min-h-[calc(100vh-160px)]">
<div class="flex flex-col w-full">
<!-- Above-The-Fold Master Container (1200px max width aligned) -->
<section class="w-full bg-[#081723] pt-space-2xl pb-space-xl">
<div class="max-w-[1200px] mx-auto px-margin-desktop flex flex-col gap-space-2xl">
<!-- HERO TWO-COLUMN GRID (50% / 50%) -->
<div class="grid grid-cols-1 lg:grid-cols-12 gap-space-xl items-center">
<!-- LEFT COLUMN: Value Proposition & CTAs -->
<div class="lg:col-span-6 flex flex-col justify-center gap-space-lg">
<!-- Eyebrow Pill Badge -->
<div class="inline-flex items-center gap-2 self-start px-3 py-1 rounded-full bg-[#0e2233] border border-[#1e3a52] shadow-sm">
<span class="w-1.5 h-1.5 rounded-full bg-[#00C3CD]"></span>
<span class="font-label-sm text-label-sm text-[#94A3B8] uppercase tracking-wider font-semibold">
Schwarz IT · Sensing &amp; Prediction Platform
</span>
</div>
<!-- Headline -->
<h1 class="text-[36px] leading-[40px] sm:text-[52px] sm:leading-[58px] tracking-[-0.03em] font-semibold text-[#FFFFFF]">
You bring the data.<br />
<span class="text-[#00C3CD]">We bring the engine.</span>
</h1>
<!-- Subline -->
<p class="font-body-lg text-body-lg text-[#94A3B8] max-w-[500px] leading-relaxed">
Privacy-preserving sensor counts in, decisions out. Turn raw edge signals into verified operational foresight without compromising individual identity.
</p>
<OnyxBadge :color="deltaPct >= 0 ? 'success' : 'warning'" density="compact">
{{ deltaPct >= 0 ? '+' : '' }}{{ formatPercent(deltaPct, 0) }} vs 24 h earlier
</OnyxBadge>
<!-- CTAs Row -->
<div class="flex flex-wrap items-center gap-space-md pt-space-xs">
<a class="inline-flex items-center justify-center gap-2 px-6 h-12 rounded-xl bg-[#00C3CD] text-[#081723] font-label-md text-label-md font-semibold hover:bg-[#00d8e4] transition-all shadow-[0_2px_12px_rgba(0,195,205,0.25)] active:scale-[0.99] group" href="#playground">
<span>Try the engine</span>
<Icon name="material-symbols:arrow-forward" class="text-[18px] group-hover:translate-x-0.5 transition-transform text-[#081723]" />
</a>
<a class="inline-flex items-center justify-center gap-2 px-6 h-12 rounded-xl bg-[#0e2233] text-[#FFFFFF] border border-[#1e3a52] font-label-md text-label-md hover:bg-[#132b40] transition-all shadow-sm" href="#use-cases">
<Icon name="material-symbols:visibility-outline" class="text-[18px] text-[#00C3CD]" />
<span>See live use cases</span>
</a>
</div>
<!-- Trust Micro-Copy -->
<div class="flex items-center gap-2 pt-space-xs font-body-sm text-body-sm text-[#94A3B8]">
<Icon name="material-symbols:verified-user" class="text-[17px] text-[#00C3CD]" />
<span>Zero personally identifiable information (PII) processed. GDPR Art. 25 Privacy by Design.</span>
</div>
</div>
<!-- RIGHT COLUMN: Pipeline Architecture Diagram Card -->
<div class="lg:col-span-6 w-full">
<div class="w-full bg-[#0e2233] border border-[#1e3a52] rounded-xl shadow-xl p-space-lg flex flex-col gap-space-md relative overflow-hidden">
<!-- Card Header Badge -->
<div class="flex flex-wrap items-center justify-between gap-2 pb-space-xs border-b border-[#1e3a52]/60">
<div class="flex items-center gap-2">
<span class="w-2 h-2 rounded-full bg-[#00C3CD] animate-pulse"></span>
<span class="font-label-sm text-label-sm uppercase tracking-wider text-[#FFFFFF] font-semibold">Real-Time Core Pipeline</span>
</div>
<span class="font-label-sm text-label-sm bg-[#132b40] border border-[#1e3a52] px-2 py-0.5 rounded text-[#94A3B8] font-mono font-medium">v2.4-deterministic</span>
</div>
<!-- Pipeline Diagram Stage -->
<div class="bg-[#081723]/60 border border-[#1e3a52] rounded-xl p-space-md flex flex-col gap-space-md relative">
<!-- 3-Node Horizontal Pipeline Layout -->
<div class="flex flex-col md:flex-row items-center justify-between gap-2 md:gap-1 w-full">
<!-- NODE 1: Ingest -->
<div class="w-full md:w-[30%] bg-[#0e2233] border border-[#1e3a52] rounded-xl p-space-sm flex flex-col items-center text-center shadow-sm">
<div class="w-10 h-10 rounded-lg bg-[#132b40] border border-[#1e3a52] flex items-center justify-center text-[#00C3CD] mb-1">
<Icon name="material-symbols:sensors" class="text-[20px]" />
</div>
<span class="font-headline-sm text-[13px] leading-tight text-[#FFFFFF] font-semibold">Anonymous Counts</span>
<span class="font-body-sm text-[11px] text-[#94A3B8] mt-1">LiDAR, FLUX, In/Out Edge Turnstile</span>
<div class="mt-2 w-full bg-[#132b40] border border-[#1e3a52]/80 px-1 py-0.5 rounded text-[10px] text-[#94A3B8] font-mono">
Σ counts/min
</div>
</div>
<!-- CONNECTOR 1 -->
<div class="w-full md:w-auto flex flex-col items-center justify-center py-1 md:py-0 md:flex-1 md:px-1 relative">
<div class="w-full h-[2px] bg-[#1e3a52] relative overflow-hidden flex items-center">
<div class="w-1/2 h-[2px] bg-[#00C3CD] animate-flow"></div>
</div>
<span class="text-[9px] text-[#00C3CD] font-mono tracking-tighter mt-1 uppercase">100% PII-Free</span>
</div>
<!-- NODE 2: SENSING ENGINE (Centerpiece) -->
<div class="w-full md:w-[38%] bg-[#132b40] border-2 border-[#00C3CD] text-[#FFFFFF] rounded-xl p-space-md flex flex-col items-center text-center shadow-lg relative overflow-hidden group">
<div class="absolute -right-6 -bottom-6 w-20 h-20 rounded-full bg-[#00C3CD]/15 blur-xl pointer-events-none"></div>
<div class="w-9 h-9 rounded-full bg-[#00C3CD]/20 border border-[#00C3CD]/40 flex items-center justify-center text-[#00C3CD] mb-1">
<Icon name="material-symbols:hub-outline" class="text-[19px]" />
</div>
<span class="font-headline-sm text-[14px] leading-tight text-[#FFFFFF] font-semibold tracking-tight">SENSING ENGINE</span>
<span class="font-label-sm text-[10px] text-[#00C3CD] uppercase tracking-wider font-semibold">Fuse + Predict</span>
</div>
<!-- CONNECTOR 2 -->
<div class="w-full md:w-auto flex flex-col items-center justify-center py-1 md:py-0 md:flex-1 md:px-1 relative">
<div class="w-full h-[2px] bg-[#1e3a52] relative overflow-hidden flex items-center">
<div class="w-1/2 h-[2px] bg-[#00C3CD] animate-flow"></div>
</div>
<span class="text-[9px] text-[#00C3CD] font-mono tracking-tighter mt-1 uppercase">Inference</span>
</div>
<!-- NODE 3: Decisions -->
<div class="w-full md:w-[30%] bg-[#0e2233] border border-[#1e3a52] rounded-xl p-space-sm flex flex-col items-center text-center shadow-sm">
<div class="w-10 h-10 rounded-lg bg-[#132b40] border border-[#1e3a52] flex items-center justify-center text-[#00C3CD] mb-1">
<Icon name="material-symbols:bolt-outline" class="text-[20px]" />
</div>
<span class="font-headline-sm text-[13px] leading-tight text-[#FFFFFF] font-semibold">Decisions</span>
<span class="font-body-sm text-[11px] text-[#94A3B8] mt-1">Staff shift, dynamic routing, bin dispatch</span>
<div class="mt-2 w-full bg-[#132b40] border border-[#1e3a52]/80 px-1 py-0.5 rounded text-[10px] text-[#00C3CD] font-mono font-semibold">
Action Output
</div>
</div>
</div>
<!-- Real-world Context Fusion Ribbon -->
<div class="flex flex-col gap-1.5 pt-1">
<div class="flex items-center justify-between text-[#94A3B8] px-1">
<span class="font-label-sm text-[11px] tracking-wider uppercase font-semibold text-[#94A3B8]">Contextual Signals Fused in Real-Time</span>
<span class="text-[10px] font-mono text-[#00C3CD]">4 Global Feeds Active</span>
</div>
<div class="grid grid-cols-2 md:grid-cols-4 gap-1.5">
<div class="flex items-center gap-1.5 px-2 py-1.5 rounded-lg bg-[#0e2233] border border-[#1e3a52] shadow-sm">
<span class="text-[13px]">☀️</span>
<div class="flex flex-col min-w-0">
<span class="font-label-sm text-[11px] text-[#FFFFFF] truncate font-semibold">Sun Position</span>
<span class="text-[9px] text-[#94A3B8] truncate">Solar Azimuth</span>
</div>
</div>
<div class="flex items-center gap-1.5 px-2 py-1.5 rounded-lg bg-[#0e2233] border border-[#1e3a52] shadow-sm">
<span class="text-[13px]">🌦️</span>
<div class="flex flex-col min-w-0">
<span class="font-label-sm text-[11px] text-[#FFFFFF] truncate font-semibold">DWD Weather</span>
<span class="text-[9px] text-[#94A3B8] truncate">Hyperlocal Rain/Temp</span>
</div>
</div>
<div class="flex items-center gap-1.5 px-2 py-1.5 rounded-lg bg-[#0e2233] border border-[#1e3a52] shadow-sm">
<span class="text-[13px]">📅</span>
<div class="flex flex-col min-w-0">
<span class="font-label-sm text-[11px] text-[#FFFFFF] truncate font-semibold">Calendar Sync</span>
<span class="text-[9px] text-[#94A3B8] truncate">Retail, Holidays, Paydays</span>
</div>
</div>
<div class="flex items-center gap-1.5 px-2 py-1.5 rounded-lg bg-[#0e2233] border border-[#1e3a52] shadow-sm">
<span class="text-[13px]">🗺️</span>
<div class="flex flex-col min-w-0">
<span class="font-label-sm text-[11px] text-[#FFFFFF] truncate font-semibold">Geo-Mesh Map</span>
<span class="text-[9px] text-[#94A3B8] truncate">Store &amp; Depot Spatial</span>
</div>
</div>
</div>
</div>
</div>
<!-- Mini Telemetry Footer Bar -->
<div class="flex items-center justify-between text-[#94A3B8] px-space-xs font-mono text-[11px]">
<div class="flex items-center gap-1.5">
<Icon name="material-symbols:speed" class="text-[14px] text-[#00C3CD]" />
<span>Pipeline Latency: <strong class="text-[#FFFFFF]">&lt; 42ms</strong></span>
</div>
<div class="flex items-center gap-1.5">
<Icon name="material-symbols:sync" class="text-[14px] text-[#00C3CD]" />
<span>Edge aggregation: <strong class="text-[#FFFFFF]">60s epoch</strong></span>
</div>
</div>
</div>
</div>
</div>
<div class="bar-chart" role="img" :aria-label="`Last 24 hours for ${activeSensor?.name}`">
<div
v-for="(point, index) in last24"
:key="point.t"
class="bar-chart__bar"
:class="{ 'bar-chart__bar--now': index === last24.length - 1 }"
:style="{ height: `${Math.max(4, (point.v / barMax) * 100)}%` }"
:title="`${formatTime(point.t)} · ${point.v}`"
/>
</div>
<div class="legend" style="justify-content: space-between; margin-top: var(--onyx-density-2xs)">
<span class="small muted">{{ last24[0] ? formatTime(last24[0].t) : '—' }}</span>
<span class="small muted">{{ lastPoint ? formatDateTime(lastPoint.t) : '—' }}</span>
</div>
<p class="small muted table-note">
The CSV is static. The replay clock is {{ formatDateTime(demoNow) }}; the last measured point is
{{ lastPoint ? formatDateTime(lastPoint.t) : '—' }}. No live sensor feed is claimed.
</p>
</OnyxCard>
<OnyxCard>
<div class="card-header">
<div>
<OnyxHeadline is="h2">Sensor cluster</OnyxHeadline>
<p class="small muted" style="margin: 0">
Select a sensor to update the reading. Bounds are relative; the basemap is the next map slice.
</p>
<!-- COMPLIANCE & ACCURACY STRIP (Full 1200px span) -->
<div class="w-full bg-[#0e2233] border border-[#1e3a52] rounded-xl shadow-sm p-space-lg flex flex-col lg:flex-row items-center justify-between gap-space-lg">
<!-- 4 Verified Core Value Pillars -->
<div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-space-md w-full lg:w-auto flex-1">
<!-- Pillar 1 -->
<div class="flex items-start gap-2.5">
<div class="w-6 h-6 rounded-full bg-[#132b40] border border-[#1e3a52] flex items-center justify-center shrink-0 shadow-sm mt-0.5">
<Icon name="material-symbols:check-circle" class="text-[15px] text-[#00C3CD]" />
</div>
<div class="flex flex-col">
<span class="font-label-md text-label-md text-[#FFFFFF] font-semibold">Privacy-Preserving Sensors</span>
<span class="font-body-sm text-body-sm text-[#94A3B8] leading-tight">No identities, only counts.</span>
</div>
</div>
<!-- Pillar 2 -->
<div class="flex items-start gap-2.5">
<div class="w-6 h-6 rounded-full bg-[#132b40] border border-[#1e3a52] flex items-center justify-center shrink-0 shadow-sm mt-0.5">
<Icon name="material-symbols:check-circle" class="text-[15px] text-[#00C3CD]" />
</div>
<div class="flex flex-col">
<span class="font-label-md text-label-md text-[#FFFFFF] font-semibold">Real-World Context</span>
<span class="font-body-sm text-body-sm text-[#94A3B8] leading-tight">Weather, sun, calendar, map.</span>
</div>
</div>
<!-- Pillar 3 -->
<div class="flex items-start gap-2.5">
<div class="w-6 h-6 rounded-full bg-[#132b40] border border-[#1e3a52] flex items-center justify-center shrink-0 shadow-sm mt-0.5">
<Icon name="material-symbols:check-circle" class="text-[15px] text-[#00C3CD]" />
</div>
<div class="flex flex-col">
<span class="font-label-md text-label-md text-[#FFFFFF] font-semibold">Intuitive Visual Story</span>
<span class="font-body-sm text-body-sm text-[#94A3B8] leading-tight">One answer per screen.</span>
</div>
</div>
<!-- Pillar 4 -->
<div class="flex items-start gap-2.5">
<div class="w-6 h-6 rounded-full bg-[#132b40] border border-[#1e3a52] flex items-center justify-center shrink-0 shadow-sm mt-0.5">
<Icon name="material-symbols:check-circle" class="text-[15px] text-[#00C3CD]" />
</div>
<div class="flex flex-col">
<span class="font-label-md text-label-md text-[#FFFFFF] font-semibold">Predictive Engine</span>
<span class="font-body-sm text-body-sm text-[#94A3B8] leading-tight">Hindsight becomes foresight.</span>
</div>
</div>
</div>
<OnyxBadge color="info" density="compact">580 m cluster</OnyxBadge>
</div>
<SensorClusterMap :sensors="sensors ?? []" :active-id="sensorId" @select="sensorId = $event" />
</OnyxCard>
</div>
<aside class="card-stack">
<OnyxCard>
<div class="card-header">
<OnyxHeadline is="h2">Heilbronn weather</OnyxHeadline>
<OnyxBadge color="neutral" density="compact">Open-Meteo context</OnyxBadge>
</div>
<div class="reading-row">
<OnyxIcon :icon="weatherIcon" size="48px" color="primary" />
<div>
<p style="margin: 0; font-size: 2rem; font-weight: 700; line-height: 1">
{{ nowWeather ? `${nowWeather.temp_c} °C` : '—' }}
</p>
<p class="small muted" style="margin: 0">{{ weatherLabel }}</p>
<!-- ACCURACY BADGE (Far right telemetry badge) -->
<div class="shrink-0 flex items-center gap-3 bg-[#132b40] border border-[#1e3a52] px-space-md py-2.5 rounded-lg shadow-sm w-full lg:w-auto justify-between lg:justify-start">
<div class="flex items-center gap-2">
<div class="w-7 h-7 rounded-md bg-[#0e2233] border border-[#1e3a52] flex items-center justify-center text-[#00C3CD]">
<Icon name="material-symbols:verified-outline" class="text-[18px]" />
</div>
<div class="flex flex-col">
<span class="font-label-sm text-[10px] text-[#94A3B8] uppercase tracking-wider font-semibold">Model Accuracy</span>
<div class="flex items-center gap-1.5 font-mono text-[13px] font-semibold text-[#FFFFFF]">
<span>Backtest MAE 4.2</span>
<span class="text-[#1e3a52]">·</span>
<span class="text-[#00C3CD]">MAPE 3.8%</span>
</div>
</div>
</div>
<div class="hidden sm:flex items-center text-[11px] font-mono bg-[#0e2233] border border-[#1e3a52] px-2 py-1 rounded text-[#94A3B8]">
730 days backtested
</div>
</div>
</div>
<dl class="metric-list" style="margin-top: var(--onyx-density-md)">
<div><dt>Precipitation</dt><dd>{{ nowWeather?.precip_mm ?? '—' }} mm</dd></div>
<div><dt>Cloud cover</dt><dd>{{ nowWeather?.cloud_pct ?? '—' }}%</dd></div>
<div><dt>Wind</dt><dd>{{ nowWeather?.wind_kmh ?? '—' }} km/h</dd></div>
<div><dt>Humidity</dt><dd>{{ nowWeather?.humidity_pct ?? '—' }}%</dd></div>
</dl>
<p class="small muted table-note">
Updated {{ context ? formatDateTime(context.updated_at) : '—' }} · context
{{ context?.cached ? 'cached' : 'live' }}
</p>
</OnyxCard>
<OnyxCard>
<div class="card-header">
<OnyxHeadline is="h2">Holiday context</OnyxHeadline>
<OnyxIcon :icon="iconCalendar" size="24px" color="primary" />
</div>
<OnyxBadge v-if="todayHoliday" color="warning">{{ todayHoliday.name }} today</OnyxBadge>
<OnyxBadge v-else color="success">No public holiday today</OnyxBadge>
<p class="small muted" style="margin: var(--onyx-density-sm) 0 0">
<template v-if="nextHoliday">
Next: <strong>{{ nextHoliday.name }}</strong> on {{ formatDate(nextHoliday.date) }}.
</template>
<template v-else>No upcoming holiday in the holiday calendar.</template>
</p>
<p v-if="lastHoliday" class="small muted" style="margin: var(--onyx-density-xs) 0 0">
Last: {{ lastHoliday.name }} on {{ formatShortDate(lastHoliday.date) }}.
</p>
<p class="small muted table-note">
Baden-Württemberg public holidays; used as model context, not as a causal claim.
</p>
</OnyxCard>
<OnyxCard>
<div class="card-header">
<OnyxHeadline is="h3">What to do next</OnyxHeadline>
<OnyxIcon :icon="iconLocationPin" size="24px" color="primary" />
</div>
<p class="small" style="margin-top: 0">
The average sensor is at <strong>{{ latestPulse }}</strong> estimated devices/hour. That is context,
not a staffing decision. Open the plan to turn next week’s forecast into shifts.
</p>
<OnyxButton label="Open the staffing plan" link="/plan" color="primary" />
</OnyxCard>
</aside>
</div>
<OnyxCard>
<div class="card-header">
<div>
<OnyxHeadline is="h2">Eight sensors</OnyxHeadline>
<p class="small muted" style="margin: 0">Measured points, stable order by ID. Battery may be null in the API.</p>
</div>
<OnyxBadge color="neutral" density="compact">measured points only</OnyxBadge>
</div>
<OnyxTable striped with-page-scrolling :table-attrs="{ style: 'min-width: 36rem' }">
<template #head>
<tr>
<th scope="col">Sensor</th>
<th scope="col">Mean</th>
<th scope="col">P95</th>
<th scope="col">Battery</th>
<th scope="col">Source ID</th>
</tr>
</template>
<tr v-for="sensor in sensors" :key="sensor.id">
<th scope="row" style="text-align: left; font-weight: 600">
{{ sensor.name }}
<OnyxBadge v-if="sensor.id === sensorId" color="primary" density="compact" style="margin-left: 0.35rem">selected</OnyxBadge>
</th>
<td>{{ sensor.mean }}</td>
<td>{{ sensor.p95 }}</td>
<td>
<OnyxBadge :color="sensor.battery === null ? 'neutral' : sensor.battery >= 60 ? 'success' : 'warning'" density="compact">
{{ sensor.battery === null ? 'n/a' : `${sensor.battery}%` }}
</OnyxBadge>
</td>
<td class="mono">{{ sensor.id }}</td>
</tr>
</OnyxTable>
<p v-if="meta" class="small muted table-note">
Coverage {{ formatDate(meta.coverage.from) }} → {{ formatDate(meta.coverage.to) }} ·
{{ meta.coverage.cadence_min }}-min cadence · data {{ meta.data_version }} · model {{ meta.model_version }}
</p>
</OnyxCard>
<div v-if="!sensors?.length" class="callout callout--warning">
<OnyxIcon :icon="iconTriangleWarning" size="16px" color="warning" />
Sensor data is missing. Check that the Go API is running and that NUXT_API_INTERNAL_BASE points to it.
</section>
</div>
</div>
</main>
<footer class="w-full bg-[#081723] border-t border-[#1e3a52] py-space-xl">
<div class="max-w-[1200px] mx-auto px-margin-desktop flex flex-col md:flex-row items-center justify-between gap-space-lg font-body-sm text-body-sm text-[#94A3B8]">
<div class="flex flex-wrap items-center gap-space-md">
<span>© 2024 Schwarz IT KG. All rights reserved.</span>
<span class="text-[#1e3a52]">|</span>
<span class="flex items-center gap-1 text-[#00C3CD] font-label-sm text-label-sm">
<Icon name="material-symbols:verified-user-outline" class="text-[16px]" />GDPR / ISO 27701 compliant</span>
</div>
<div class="flex flex-wrap items-center gap-space-md">
<div class="flex items-center gap-1.5">
<span class="w-2 h-2 rounded-full bg-[#00C3CD] animate-pulse"></span>
<span class="font-label-sm text-label-sm text-[#FFFFFF]">System Status: All Engines Operational</span>
</div>
<span class="text-[#1e3a52]">|</span>
<span class="bg-[#0e2233] px-2 py-0.5 rounded font-label-sm text-label-sm font-semibold text-[#94A3B8] border border-[#1e3a52]">v2.4-prod</span>
</div>
</div>
</footer>
</template>
<style>
@keyframes pulseDataFlow {
0% { transform: translateX(0); opacity: 0.15; }
50% { opacity: 0.95; }
100% { transform: translateX(64px); opacity: 0.15; }
}
.animate-flow {
animation: pulseDataFlow 2.4s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}
</style>
-324
View File
@@ -1,324 +0,0 @@
<script setup lang="ts">
import {
iconArrowRight,
iconCircleInformation,
iconMobileSignal,
iconSync,
iconTriangleWarning,
iconUserGroup,
} from '@sit-onyx/icons'
import { scenarioLabel } from '#shared/live'
import type { ScenarioState, Sensor, Shift, StaffingResponse } from '#shared/types'
import { formatDateTime, formatEuro, formatNumber, formatPercent, formatShortDate, formatWeekday } from '~/utils/format'
useHead({ title: 'Live recommendation — PulseCast' })
const { data: sensors } = await useFetch<Sensor[]>('/api/sensors')
const { data: initialScenario } = await useFetch<ScenarioState>('/api/scenario')
const sensorId = ref(
sensors.value?.find((sensor) => sensor.id === 'hn-stadtgalerie-01')?.id ??
sensors.value?.[0]?.id ??
'hn-stadtgalerie-01',
)
const live = useLiveScenario(initialScenario.value)
const {
data: planData,
status: planStatus,
error: planError,
refresh: refreshPlan,
} = await useFetch<StaffingResponse>('/api/staffing', {
query: computed(() => ({
sensor: sensorId.value,
scenario: live.scenarioId,
standard: 'standard',
})),
})
let lastScenarioId = live.scenarioId
watch(
() => live.revision,
() => {
if (live.scenarioId === lastScenarioId) void refreshPlan()
lastScenarioId = live.scenarioId
},
)
const plan = computed(() => planData.value ?? null)
const activeSensor = computed(() => sensors.value?.find((sensor) => sensor.id === sensorId.value))
function maxOf<T>(items: T[], score: (item: T) => number): T | undefined {
let best: T | undefined
for (const item of items) if (!best || score(item) > score(best)) best = item
return best
}
const peakShift = computed<Shift | undefined>(() =>
plan.value ? maxOf(plan.value.shifts, (shift) => shift.staff) : undefined,
)
const peakStaff = computed(() => peakShift.value?.staff ?? 0)
const totalStaffHours = computed(() =>
plan.value ? plan.value.hours.reduce((sum, hour) => sum + hour.scheduled_staff, 0) : 0,
)
const currentReason = computed(() => plan.value?.why[0] ?? '')
const lastUpdate = computed(() => {
if (live.scenarioAt) return live.scenarioAt
return plan.value?.context_version ?? ''
})
</script>
<template>
<div class="page page-stack live-page">
<header class="live-header">
<div>
<p class="eyebrow">Live · no login</p>
<OnyxHeadline is="h1">The plan on your phone.</OnyxHeadline>
<p class="lede">
{{ activeSensor?.name ?? 'Stadtgalerie' }} · {{ scenarioLabel(live.scenarioId) }}. Updates arrive over SSE;
if the stream drops, this page polls every 5 seconds.
</p>
</div>
<div class="live-header__status">
<LiveStatusBadge :status="live.status" :last-event-at="live.lastEventAt" />
<OnyxBadge color="neutral" density="compact">v{{ live.version || '—' }}</OnyxBadge>
</div>
</header>
<div v-if="planError" class="callout callout--warning" role="alert">
<OnyxIcon :icon="iconTriangleWarning" size="18px" color="warning" />
<div>
<strong>The live plan is unavailable.</strong>
<span class="muted">&nbsp;{{ planError.statusMessage ?? 'The API did not answer.' }}</span>
</div>
<OnyxButton label="Retry" mode="outline" density="compact" :icon="iconSync" @click="refreshPlan()" />
</div>
<div v-else-if="planStatus === 'pending' && !plan" class="callout">
<OnyxIcon :icon="iconSync" size="18px" color="primary" />
<span>Loading the current recommendation…</span>
</div>
<div v-else-if="plan && !plan.shifts.length" class="callout callout--warning" role="status">
<OnyxIcon :icon="iconTriangleWarning" size="18px" color="warning" />
<span>No shift blocks are available yet. The presenter may still be preparing the plan.</span>
</div>
<section class="live-hero" aria-labelledby="live-decision">
<p class="live-hero__kicker"><OnyxIcon :icon="iconUserGroup" size="18px" color="primary" /> Current recommendation</p>
<p id="live-decision" class="live-hero__value">
<template v-if="plan">{{ peakStaff }} staff</template>
<template v-else>No plan yet</template>
</p>
<p class="live-hero__shift">
<template v-if="peakShift">
<strong>{{ formatWeekday(peakShift.date) }} {{ formatShortDate(peakShift.date) }}</strong><br />
{{ peakShift.start }}–{{ peakShift.end }} · peak shift
</template>
<template v-else>Waiting for the peak shift</template>
</p>
<p v-if="currentReason" class="live-hero__why">
<OnyxIcon :icon="iconCircleInformation" size="16px" color="primary" />
<span>{{ currentReason }}</span>
</p>
<OnyxButton
label="Open the full plan"
:link="`/plan?scenario=${live.scenarioId}`"
color="primary"
:icon="iconArrowRight"
icon-position="right"
/>
</section>
<section class="live-metrics" aria-label="Plan at a glance">
<div class="live-metric">
<p class="live-metric__label">Staff-hours</p>
<p class="live-metric__value">{{ plan ? formatNumber(totalStaffHours) : '—' }}</p>
</div>
<div class="live-metric">
<p class="live-metric__label">Labour cost</p>
<p class="live-metric__value">{{ plan ? formatEuro(plan.summary.cost_eur) : '—' }}</p>
</div>
<div class="live-metric">
<p class="live-metric__label">Coverage</p>
<p class="live-metric__value">{{ plan ? formatPercent(plan.summary.coverage_pct, 1) : '—' }}</p>
</div>
<div class="live-metric">
<p class="live-metric__label">Understaffed</p>
<p class="live-metric__value">{{ plan ? `${plan.summary.understaffed_hours} h` : '—' }}</p>
</div>
</section>
<section class="live-status-card">
<div class="live-status-card__row">
<span class="live-status-card__label">Scenario</span>
<strong>{{ scenarioLabel(live.scenarioId) }}</strong>
</div>
<div class="live-status-card__row">
<span class="live-status-card__label">Version</span>
<span>{{ live.version || '—' }}</span>
</div>
<div class="live-status-card__row">
<span class="live-status-card__label">Last update</span>
<span>{{ lastUpdate ? formatDateTime(lastUpdate) : '—' }}</span>
</div>
<div class="live-status-card__row">
<span class="live-status-card__label">Transport</span>
<span>{{ live.statusLabel }}<template v-if="live.status === 'polling'"> · 5 s</template></span>
</div>
<p v-if="live.error" class="small muted table-note">{{ live.error }}</p>
</section>
<footer class="live-footer">
<p>
<strong>Decision support, not an optimizer.</strong> The plan uses
{{ plan?.assumptions.visitors_per_staff_hour ?? 25 }} visitors per staff-hour,
×{{ plan?.assumptions.safety_factor ?? 1.15 }} safety, {{ plan?.assumptions.shift_length_h ?? 4 }} h shift
blocks and €{{ plan?.assumptions.labor_cost_eur_h ?? 16 }}/h.
</p>
<p class="muted">
Estimated devices, not people · {{ sensors?.length ?? 8 }} sensors in a 580 m cluster · no POS, sales or
payroll data.
</p>
</footer>
</div>
</template>
<style scoped>
.live-page {
max-width: 44rem;
gap: clamp(0.85rem, 2vw, 1.25rem);
}
.live-header {
display: flex;
flex-wrap: wrap;
align-items: flex-start;
justify-content: space-between;
gap: var(--onyx-density-sm);
}
.live-header h1 {
margin: 0;
}
.live-header__status {
display: flex;
flex-wrap: wrap;
gap: var(--onyx-density-xs);
align-items: center;
}
.live-hero {
padding: clamp(1.1rem, 3vw, 1.75rem);
border: 1px solid var(--onyx-color-base-primary-300);
border-radius: var(--onyx-radius-component-container-soft);
background:
radial-gradient(circle at 100% 0%, var(--onyx-color-base-primary-200), transparent 48%),
linear-gradient(135deg, var(--onyx-color-base-primary-100), var(--onyx-color-base-neutral-100) 72%);
}
.live-hero__kicker {
display: flex;
align-items: center;
gap: 0.35rem;
margin: 0;
color: var(--onyx-color-text-icons-neutral-medium);
font-size: 0.8rem;
font-weight: 600;
letter-spacing: 0.04em;
text-transform: uppercase;
}
.live-hero__value {
margin: var(--onyx-density-xs) 0 0;
font-size: clamp(3rem, 16vw, 5.5rem);
font-weight: 800;
letter-spacing: -0.04em;
line-height: 0.95;
color: var(--onyx-color-text-icons-primary-intense);
}
.live-hero__shift {
margin: var(--onyx-density-sm) 0 0;
font-size: clamp(1rem, 3.5vw, 1.25rem);
line-height: 1.4;
}
.live-hero__why {
display: flex;
gap: var(--onyx-density-xs);
align-items: flex-start;
margin: var(--onyx-density-md) 0;
color: var(--onyx-color-text-icons-neutral-medium);
font-size: 0.9rem;
line-height: 1.45;
}
.live-metrics {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: var(--onyx-density-sm);
}
.live-metric {
min-width: 0;
padding: var(--onyx-density-md);
border: 1px solid var(--onyx-color-base-neutral-300);
border-radius: var(--onyx-radius-component-container-soft);
background: var(--onyx-color-base-neutral-100);
}
.live-metric__label {
margin: 0;
color: var(--onyx-color-text-icons-neutral-medium);
font-size: 0.78rem;
font-weight: 600;
}
.live-metric__value {
margin: var(--onyx-density-xs) 0 0;
font-size: clamp(1.35rem, 6vw, 1.9rem);
font-weight: 700;
line-height: 1.1;
}
.live-status-card {
display: grid;
gap: var(--onyx-density-xs);
padding: var(--onyx-density-md);
border: 1px solid var(--onyx-color-base-neutral-300);
border-radius: var(--onyx-radius-component-container-soft);
background: var(--onyx-color-base-neutral-100);
}
.live-status-card__row {
display: flex;
align-items: baseline;
justify-content: space-between;
gap: var(--onyx-density-sm);
}
.live-status-card__label {
color: var(--onyx-color-text-icons-neutral-medium);
font-size: 0.8rem;
}
.live-footer {
padding-top: var(--onyx-density-sm);
border-top: 1px solid var(--onyx-color-base-neutral-300);
color: var(--onyx-color-text-icons-neutral-medium);
font-size: 0.75rem;
line-height: 1.5;
}
.live-footer p {
margin: 0 0 var(--onyx-density-xs);
}
@media (min-width: 577px) {
.live-metrics {
grid-template-columns: repeat(4, minmax(0, 1fr));
}
}
</style>
-800
View File
@@ -1,800 +0,0 @@
<script setup lang="ts">
import {
iconCalendar,
iconCheck,
iconCircleInformation,
iconDownload,
iconSync,
iconTriangleWarning,
iconUserGroup,
} from '@sit-onyx/icons'
import { dailyWeather } from '#shared/insights'
import {
addDays,
berlinParts,
buildStaffing,
DEFAULT_ASSUMPTIONS,
isInWeek,
planWeekStart,
STANDARD_VISITORS_PER_STAFF_HOUR,
} from '#shared/staffing'
import { SCENARIOS } from '#shared/types'
import type {
ContextResponse,
MetaResponse,
Scenario,
ScenarioPreset,
ScenarioState,
Sensor,
Shift,
StaffingHour,
StaffingResponse,
Standard,
} from '#shared/types'
import {
formatDate,
formatDateTime,
formatEuro,
formatNumber,
formatPercent,
formatShortDate,
formatTime,
formatWeekday,
weekLabel,
} from '~/utils/format'
useHead({ title: 'Plan next week — PulseCast' })
const config = useRuntimeConfig()
const route = useRoute()
const demoNow = String(config.public.demoNow)
const usingMock = computed(
() =>
config.public.useMock === true ||
config.public.useMock === '1' ||
config.public.useMock === 'true',
)
function initialScenario(): Scenario {
const value = route.query.scenario
return typeof value === 'string' && SCENARIOS.includes(value as Scenario) ? (value as Scenario) : 'base'
}
/** Keep Stadtgalerie as the demo default, but follow the API when it differs. */
function preferredSensor(list: Sensor[] | null | undefined): string {
return list?.find((sensor) => sensor.id === 'hn-stadtgalerie-01')?.id ?? list?.[0]?.id ?? 'hn-stadtgalerie-01'
}
const { data: sensors } = await useFetch<Sensor[]>('/api/sensors')
const { data: context } = await useFetch<ContextResponse>('/api/context')
const { data: meta } = await useFetch<MetaResponse>('/api/meta')
const { data: presets } = await useFetch<ScenarioPreset[]>('/api/scenarios')
const { data: liveScenarioState } = await useFetch<ScenarioState>('/api/scenario')
const live = useLiveScenario(liveScenarioState.value)
const sensorId = ref(preferredSensor(sensors.value))
const scenario = ref<Scenario>(initialScenario())
// The stage scenario wins unless the URL explicitly asks for another one.
if (!route.query.scenario) scenario.value = live.scenarioId
const standard = ref<Standard>('standard')
const approved = ref(false)
const generating = ref(false)
const generatedAt = ref('')
const openAssumptions = ref<PropertyKey[]>([])
const assumptions = reactive({
safety_factor: DEFAULT_ASSUMPTIONS.safety_factor,
min_staff: DEFAULT_ASSUMPTIONS.min_staff,
shift_length_h: DEFAULT_ASSUMPTIONS.shift_length_h,
labor_cost_eur_h: DEFAULT_ASSUMPTIONS.labor_cost_eur_h,
})
const EMPTY_PLAN: StaffingResponse = {
sensor: '',
scenario: 'base',
standard: 'standard',
assumptions: DEFAULT_ASSUMPTIONS,
hours: [],
shifts: [],
summary: {
coverage_pct: 0,
cost_eur: 0,
flat_schedule_cost_eur: 0,
overstaffed_hours: 0,
understaffed_hours: 0,
},
why: [],
cached: false,
data_version: '',
model_version: '',
context_version: '',
}
// The hero plan comes from the Go API. Local assumption edits only render a
// preview from the API's own forecast hours; they never replace the API plan.
const {
data: apiPlanData,
status,
error,
refresh,
} = await useFetch<StaffingResponse>('/api/staffing', {
query: computed(() => ({
sensor: sensorId.value,
scenario: scenario.value,
standard: standard.value,
})),
})
watch(
() => route.query.scenario,
(value) => {
if (typeof value === 'string' && SCENARIOS.includes(value as Scenario)) {
scenario.value = value as Scenario
}
},
)
// A scenario event changes the plan. If the enum is unchanged (same scenario,
// new override/version), the query string does not move, so refresh it here.
watch(
() => live.revision,
() => {
if (live.scenarioId !== scenario.value) scenario.value = live.scenarioId
else void refresh()
},
)
const apiPlan = computed(() => apiPlanData.value ?? EMPTY_PLAN)
const activeSensor = computed(() => sensors.value?.find((sensor) => sensor.id === sensorId.value))
const activeScenario = computed(() => presets.value?.find((preset) => preset.id === scenario.value))
const visitorsPerStaffHour = computed(() => STANDARD_VISITORS_PER_STAFF_HOUR[standard.value])
const weekStart = computed(() => {
const first = apiPlan.value.hours[0]
return first ? berlinParts(first.t).date : planWeekStart(demoNow)
})
const weekEnd = computed(() => addDays(weekStart.value, 6))
const scenarioOptions = computed(() =>
(presets.value ?? []).map((preset) => ({ value: preset.id, label: preset.label })),
)
const sensorOptions = computed(() =>
(sensors.value ?? []).map((sensor) => ({ value: sensor.id, label: sensor.name })),
)
const standardOptions = [
{ value: 'relaxed', label: 'Relaxed 35' },
{ value: 'standard', label: 'Standard 25' },
{ value: 'premium', label: 'Premium 18' },
]
const standardLabel = computed(
() =>
({
relaxed: 'relaxed · 35 visitors per staff-hour',
standard: 'standard · 25 visitors per staff-hour',
premium: 'premium · 18 visitors per staff-hour',
})[standard.value],
)
const shiftLengthOptions = [
{ value: 2, label: '2 hours' },
{ value: 3, label: '3 hours' },
{ value: 4, label: '4 hours' },
{ value: 5, label: '5 hours' },
]
/** The /api/staffing contract has no assumption query params. Non-query edits
* are therefore an explicitly labeled local preview, never a silent swap. */
const previewActive = computed(() => {
const api = apiPlan.value.assumptions
return (
assumptions.safety_factor !== api.safety_factor ||
assumptions.min_staff !== api.min_staff ||
assumptions.shift_length_h !== api.shift_length_h ||
assumptions.labor_cost_eur_h !== api.labor_cost_eur_h
)
})
const previewBuild = computed(() =>
buildStaffing({
sensor: sensorId.value,
scenario: scenario.value,
standard: standard.value,
points: apiPlan.value.hours.map((hour) => ({ t: hour.t, v: hour.footfall })),
weekStart: weekStart.value,
assumptions: {
visitors_per_staff_hour: visitorsPerStaffHour.value,
safety_factor: assumptions.safety_factor,
min_staff: assumptions.min_staff,
shift_length_h: assumptions.shift_length_h,
labor_cost_eur_h: assumptions.labor_cost_eur_h,
store_hours: apiPlan.value.assumptions.store_hours,
},
data_version: apiPlan.value.data_version,
model_version: apiPlan.value.model_version,
context_version: apiPlan.value.context_version,
}),
)
const plan = computed(() => (previewActive.value ? previewBuild.value.response : apiPlan.value))
const hoursByDate = computed<Record<string, StaffingHour[]>>(() => {
if (previewActive.value) return previewBuild.value.byDate
const grouped: Record<string, StaffingHour[]> = {}
for (const hour of apiPlan.value.hours) {
const date = berlinParts(hour.t).date
;(grouped[date] ??= []).push(hour)
}
return grouped
})
const shiftsByDate = computed<Record<string, Shift[]>>(() => {
if (previewActive.value) return previewBuild.value.shiftsByDate
const grouped: Record<string, Shift[]> = {}
for (const shift of apiPlan.value.shifts) {
;(grouped[shift.date] ??= []).push(shift)
}
return grouped
})
const why = computed(() => apiPlan.value.why)
const weekWeather = computed(() => {
if (!context.value) return []
return Object.values(dailyWeather(context.value.weather.forecast))
.filter((day) => isInWeek(day.date, weekStart.value))
.sort((a, b) => a.date.localeCompare(b.date))
})
function maxOf<T>(items: T[], score: (item: T) => number): T | undefined {
let best: T | undefined
for (const item of items) {
if (!best || score(item) > score(best)) best = item
}
return best
}
const peakHour = computed(() => maxOf(plan.value.hours, (hour) => hour.footfall))
const peakShift = computed(() => maxOf(plan.value.shifts, (shift) => shift.staff))
const totalStaffHours = computed(() =>
plan.value.hours.reduce((sum, hour) => sum + hour.scheduled_staff, 0),
)
const savingEur = computed(() =>
Math.max(0, plan.value.summary.flat_schedule_cost_eur - plan.value.summary.cost_eur),
)
const savingPct = computed(() => {
const flat = plan.value.summary.flat_schedule_cost_eur
return flat > 0 ? (savingEur.value / flat) * 100 : 0
})
interface DaySummary {
date: string
shifts: Shift[]
staffHours: number
peakStaff: number
cost: number
}
const daySummaries = computed<DaySummary[]>(() =>
Object.keys(hoursByDate.value)
.sort()
.map((date) => {
const hours = hoursByDate.value[date] ?? []
const shifts = shiftsByDate.value[date] ?? []
const staffHours = hours.reduce((sum, hour) => sum + hour.scheduled_staff, 0)
return {
date,
shifts,
staffHours,
peakStaff: maxOf(hours, (hour) => hour.scheduled_staff)?.scheduled_staff ?? 0,
cost: staffHours * plan.value.assumptions.labor_cost_eur_h,
}
}),
)
const dayDates = computed(() => daySummaries.value.map((day) => day.date))
const selectedDay = ref('')
watch(
() => dayDates.value.join(','),
() => {
if (dayDates.value.includes(selectedDay.value)) return
const preferred = addDays(weekStart.value, 5)
selectedDay.value = dayDates.value.includes(preferred) ? preferred : (dayDates.value[0] ?? '')
},
{ immediate: true },
)
const dayOptions = computed(() =>
daySummaries.value.map((day) => ({
value: day.date,
label: `${formatWeekday(day.date)} ${formatShortDate(day.date)} · ${day.peakStaff} peak`,
})),
)
const selectedHours = computed<StaffingHour[]>(() => hoursByDate.value[selectedDay.value] ?? [])
const selectedCovered = computed(
() => selectedHours.value.filter((hour) => hour.scheduled_staff >= hour.required_staff).length,
)
const selectedOver = computed(
() => selectedHours.value.filter((hour) => hour.coverage === 'over').length,
)
function coverageColor(hour: StaffingHour) {
if (hour.coverage === 'under') return 'danger' as const
if (hour.coverage === 'over') return 'warning' as const
return 'success' as const
}
function coverageLabel(hour: StaffingHour) {
if (hour.coverage === 'under') return `${hour.required_staff - hour.scheduled_staff} short`
if (hour.coverage === 'over') return `+${hour.scheduled_staff - hour.required_staff} over`
return 'Covered'
}
async function generate() {
generating.value = true
try {
await refresh()
if (!error.value && import.meta.client) generatedAt.value = formatTime(new Date().toISOString())
} finally {
generating.value = false
}
}
function resetAssumptions() {
assumptions.safety_factor = DEFAULT_ASSUMPTIONS.safety_factor
assumptions.min_staff = DEFAULT_ASSUMPTIONS.min_staff
assumptions.shift_length_h = DEFAULT_ASSUMPTIONS.shift_length_h
assumptions.labor_cost_eur_h = DEFAULT_ASSUMPTIONS.labor_cost_eur_h
standard.value = 'standard'
}
function useApiPlan() {
const api = apiPlan.value.assumptions
assumptions.safety_factor = api.safety_factor
assumptions.min_staff = api.min_staff
assumptions.shift_length_h = api.shift_length_h
assumptions.labor_cost_eur_h = api.labor_cost_eur_h
}
function exportPlan() {
if (!import.meta.client) return
const rows = [
['date', 'shift_start', 'shift_end', 'staff', 'staff_hours'],
...plan.value.shifts.map((shift) => [
shift.date,
shift.start,
shift.end,
String(shift.staff),
String((Number(shift.end.slice(0, 2)) - Number(shift.start.slice(0, 2))) * shift.staff),
]),
]
const csv = rows.map((row) => row.join(',')).join('\n')
const url = URL.createObjectURL(new Blob([csv], { type: 'text/csv;charset=utf-8' }))
const link = document.createElement('a')
link.href = url
link.download = `pulsecast-plan-${weekStart.value}.csv`
link.click()
URL.revokeObjectURL(url)
}
</script>
<template>
<div class="page page-stack">
<section class="hero" aria-labelledby="plan-headline">
<div class="hero-grid">
<div class="hero-copy">
<p class="eyebrow">Plan · {{ weekLabel(weekStart, weekEnd) }}</p>
<OnyxHeadline id="plan-headline" is="h1">
<template v-if="peakShift">
{{ formatWeekday(peakShift.date) }} peak: {{ peakShift.staff }} staff, {{ peakShift.start }}–{{ peakShift.end }}.
</template>
<template v-else>Build next week’s shift plan.</template>
</OnyxHeadline>
<p class="lede">
Forecast for <strong>{{ activeSensor?.name ?? apiPlan.sensor ?? 'the selected store' }}</strong> needs
<strong>{{ peakHour?.required_staff ?? '—' }} staff at the busiest hour</strong>. The rest of the week
runs on {{ totalStaffHours }} staff-hours at {{ formatEuro(plan.summary.cost_eur) }}.
</p>
<div class="hero-actions">
<OnyxButton
:label="approved ? 'Plan approved' : 'Approve plan'"
:icon="approved ? iconCheck : iconCalendar"
color="primary"
@click="approved = !approved"
/>
<OnyxButton label="Export CSV" :icon="iconDownload" mode="outline" @click="exportPlan" />
<LiveStatusBadge :status="live.status" :last-event-at="live.lastEventAt" />
<OnyxBadge v-if="approved" color="success">Approved · demo</OnyxBadge>
<span v-else class="small muted">Draft for manager review</span>
</div>
<p class="small muted" style="margin: 0">
<template v-if="usingMock">Mock mode · NUXT_PUBLIC_USE_MOCK=1 · no Go API call.</template>
<template v-else-if="previewActive">
Local preview · the Go API plan is unchanged.
</template>
<template v-else>
Go /api/staffing · scenario v{{ live.version }} · broadcast
{{ live.scenarioAt ? formatDateTime(live.scenarioAt) : '—' }} · no POS, sales or labour-cost feed.
</template>
</p>
</div>
<div class="hero-decision">
<p class="stat-label">Peak staffing decision</p>
<p class="hero-decision__value">{{ peakShift?.staff ?? '—' }} staff</p>
<p class="hero-decision__label">
<template v-if="peakShift">
{{ formatWeekday(peakShift.date) }} {{ formatShortDate(peakShift.date) }}, {{ peakShift.start }}–{{ peakShift.end }}<br />
</template>
<template v-if="peakHour">
{{ formatWeekday(berlinParts(peakHour.t).date) }} {{ String(berlinParts(peakHour.t).hour).padStart(2, '0') }}:00
peak: {{ peakHour.footfall }} est. visitors/hour
</template>
</p>
<OnyxSeparator style="margin-block: var(--onyx-density-sm)" />
<div class="reading-row">
<OnyxBadge color="success" density="compact">{{ formatPercent(plan.summary.coverage_pct, 1) }} covered</OnyxBadge>
<OnyxBadge color="warning" density="compact">{{ plan.summary.overstaffed_hours }} h over</OnyxBadge>
<OnyxBadge color="success" density="compact">{{ plan.summary.understaffed_hours }} h under</OnyxBadge>
<OnyxBadge v-if="apiPlan.cached" color="warning" density="compact">cached forecast</OnyxBadge>
</div>
</div>
</div>
</section>
<div v-if="status === 'error'" class="callout callout--warning">
<OnyxIcon :icon="iconTriangleWarning" size="16px" color="warning" />
The staffing API could not be loaded. Check that the Go API is running and that NUXT_API_INTERNAL_BASE points
to it. <span v-if="error" class="muted">{{ error.statusMessage }}</span>
</div>
<div v-else-if="status === 'success' && !apiPlan.hours.length" class="callout callout--warning">
<OnyxIcon :icon="iconTriangleWarning" size="16px" color="warning" />
No open hours are available for this store and scenario yet. Pick another sensor or check the data window.
</div>
<section class="summary-grid" aria-label="Plan summary">
<MetricCard
label="Coverage"
:value="formatPercent(plan.summary.coverage_pct, 1)"
badge="All hours covered"
badge-color="success"
:icon="iconCheck"
hint="Shift blocks cover the block peak, so low hours are intentionally overstaffed."
/>
<MetricCard
label="Labour cost"
:value="formatEuro(plan.summary.cost_eur)"
:icon="iconUserGroup"
:hint="`${totalStaffHours} staff-hours × €${plan.assumptions.labor_cost_eur_h}/h assumption`"
/>
<MetricCard
label="vs flat schedule"
:value="`−${formatEuro(savingEur)}`"
:badge="`${formatPercent(savingPct, 0)} lower`"
badge-color="success"
:hint="`Flat schedule would cost ${formatEuro(plan.summary.flat_schedule_cost_eur)}.`"
/>
<MetricCard
label="Plan risk"
:value="`${plan.summary.overstaffed_hours} h over`"
:badge="`${plan.summary.understaffed_hours} h under`"
badge-color="success"
:hint="`${selectedOver} of ${selectedHours.length} selected-day hours are above requirement.`"
/>
</section>
<OnyxCard>
<div class="card-header">
<div>
<OnyxHeadline is="h2">Plan inputs</OnyxHeadline>
<p class="small muted" style="margin: 0">
Store, service standard and scenario are sent to Go /api/staffing. Local assumption edits render a
preview from the API forecast.
</p>
</div>
<OnyxBadge :color="usingMock ? 'warning' : previewActive ? 'warning' : 'success'" density="compact">
{{ usingMock ? 'Mock mode' : previewActive ? 'Local preview' : 'Go API' }}
</OnyxBadge>
</div>
<div class="form-grid">
<div style="display: grid; gap: var(--onyx-density-md); grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr))">
<OnyxSelect
v-model="sensorId"
label="Store / sensor"
list-label="Inner-city sensors"
:options="sensorOptions"
:message="activeSensor ? `${activeSensor.id} · ${activeSensor.mean} mean / ${activeSensor.p95} p95` : undefined"
/>
<OnyxSelect
v-model="scenario"
label="Scenario"
list-label="Demo scenarios"
:options="scenarioOptions"
:message="activeScenario?.description"
/>
<div>
<p class="stat-label" style="margin-bottom: var(--onyx-density-xs)">Service standard</p>
<OnyxSegmentedControl
v-model="standard"
aria-label="Service standard"
:options="standardOptions"
name="service-standard"
/>
<p class="small muted" style="margin: var(--onyx-density-xs) 0 0">{{ standardLabel }}</p>
</div>
<div style="display: flex; align-items: flex-end; gap: var(--onyx-density-sm); flex-wrap: wrap">
<OnyxButton
label="Generate plan"
:icon="iconSync"
color="primary"
:loading="generating || status === 'pending'"
@click="generate"
/>
<span v-if="generatedAt" class="small muted">Updated {{ generatedAt }}</span>
</div>
</div>
<OnyxAccordion v-model="openAssumptions" type="card">
<OnyxAccordionItem id="assumptions" value="assumptions">
<template #header>
<span>
Assumptions
<span class="muted small">
· {{ visitorsPerStaffHour }} visitors/staff-h · ×{{ assumptions.safety_factor.toFixed(2) }} ·
min {{ assumptions.min_staff }}
</span>
</span>
</template>
<div class="assumption-grid">
<OnyxSlider
v-model="assumptions.safety_factor"
label="Safety factor"
:min="1"
:max="1.5"
:step="0.05"
control="input"
:message="`Higher values add buffer staff. Current ×${assumptions.safety_factor.toFixed(2)}.`"
/>
<OnyxStepper
v-model="assumptions.min_staff"
label="Minimum staff"
:min="1"
:max="10"
:step-size="1"
message="Floor applied to every open hour."
/>
<OnyxSelect
v-model="assumptions.shift_length_h"
label="Shift block length"
list-label="Shift lengths"
:options="shiftLengthOptions"
message="Blocks are scheduled independently; coverage is checked per hour."
/>
<OnyxStepper
v-model="assumptions.labor_cost_eur_h"
label="Labour cost (€/hour)"
:min="8"
:max="60"
:step-size="1"
message="Assumption only. No payroll or POS data exists."
/>
<p class="small muted" style="grid-column: 1 / -1; margin: 0">
These four values are not query inputs of Go /api/staffing. Changing them shows a local preview;
“Use API plan” restores the server values.
</p>
<div class="form-actions" style="grid-column: 1 / -1">
<OnyxButton label="Reset assumptions" mode="outline" @click="resetAssumptions" />
<OnyxButton v-if="previewActive" label="Use API plan" mode="outline" @click="useApiPlan" />
<span class="small muted">Store hours 10:00–20:00, Europe/Berlin · {{ apiPlan.model_version || 'API' }}</span>
</div>
</div>
</OnyxAccordionItem>
</OnyxAccordion>
</div>
</OnyxCard>
<div class="split-grid">
<div class="card-stack">
<OnyxCard>
<div class="card-header">
<div>
<OnyxHeadline is="h2">Recommended shifts</OnyxHeadline>
<p class="small muted" style="margin: 0">2–5 h blocks per day; staff count covers the block peak.</p>
</div>
<div class="legend">
<span class="legend__item"><span class="legend__swatch legend__swatch--over" /> over requirement</span>
<span class="legend__item"><span class="legend__swatch" /> scheduled staff</span>
</div>
</div>
<OnyxTable class="desktop-table" striped>
<template #head>
<tr>
<th scope="col">Day</th>
<th scope="col">Shift blocks (start–end · staff)</th>
<th scope="col">Staff-hours</th>
<th scope="col">Peak</th>
<th scope="col">Labour</th>
<th scope="col"><span class="onyx-visually-hidden">Inspect</span></th>
</tr>
</template>
<tr v-for="day in daySummaries" :key="day.date" :class="{ 'peak-row': day.date === peakShift?.date }">
<th scope="row" style="text-align: left; font-weight: 600">
{{ formatWeekday(day.date) }}
<span class="muted" style="font-weight: 400"> {{ formatShortDate(day.date) }}</span>
<OnyxBadge v-if="day.date === peakShift?.date" color="warning" density="compact" style="margin-left: 0.35rem">peak</OnyxBadge>
</th>
<td>
<div class="shift-tags">
<OnyxTag
v-for="shift in day.shifts"
:key="`${shift.date}-${shift.start}`"
:label="`${shift.start}–${shift.end} · ${shift.staff}`"
density="compact"
color="neutral"
/>
</div>
</td>
<td>{{ formatNumber(day.staffHours) }}</td>
<td>{{ day.peakStaff }}</td>
<td>{{ formatEuro(day.cost) }}</td>
<td>
<OnyxButton
label="Hours"
mode="plain"
density="compact"
@click="selectedDay = day.date"
/>
</td>
</tr>
</OnyxTable>
<div class="day-card-list">
<OnyxCard v-for="day in daySummaries" :key="day.date" density="compact">
<div class="day-card__header">
<p class="day-card__date">
{{ formatWeekday(day.date) }} <span class="muted">{{ formatShortDate(day.date) }}</span>
</p>
<OnyxBadge :color="day.date === peakShift?.date ? 'warning' : 'neutral'" density="compact">
{{ day.peakStaff }} peak
</OnyxBadge>
</div>
<div class="shift-tags" style="margin-top: var(--onyx-density-xs)">
<OnyxTag
v-for="shift in day.shifts"
:key="`${shift.date}-${shift.start}`"
:label="`${shift.start}–${shift.end} · ${shift.staff}`"
density="compact"
/>
</div>
<div class="day-card__metrics">
<span>{{ formatNumber(day.staffHours) }} staff-hours</span>
<span>{{ formatEuro(day.cost) }}</span>
</div>
<OnyxButton label="View hourly detail" mode="plain" density="compact" @click="selectedDay = day.date" />
</OnyxCard>
</div>
<p class="small muted table-note">
Total {{ totalStaffHours }} staff-hours · {{ formatEuro(plan.summary.cost_eur) }} at
€{{ plan.assumptions.labor_cost_eur_h }}/h · exported CSV has one row per shift block.
</p>
</OnyxCard>
<OnyxCard>
<div class="card-header">
<div>
<OnyxHeadline is="h2">Hourly coverage</OnyxHeadline>
<p class="small muted" style="margin: 0">
{{ selectedCovered }}/{{ selectedHours.length }} open hours covered · {{ selectedOver }} over requirement
</p>
</div>
<div style="min-width: 13rem">
<OnyxSelect
v-model="selectedDay"
label="Inspect day"
list-label="Plan days"
:options="dayOptions"
density="compact"
/>
</div>
</div>
<OnyxTable striped with-page-scrolling :table-attrs="{ style: 'min-width: 34rem' }">
<template #head>
<tr>
<th scope="col">Hour</th>
<th scope="col">Forecast footfall</th>
<th scope="col">Required</th>
<th scope="col">Scheduled</th>
<th scope="col">Coverage</th>
</tr>
</template>
<tr v-for="hour in selectedHours" :key="hour.t">
<th scope="row" style="text-align: left; font-weight: 600">{{ String(berlinParts(hour.t).hour).padStart(2, '0') }}:00</th>
<td>{{ formatNumber(hour.footfall) }}</td>
<td>{{ hour.required_staff }}</td>
<td>{{ hour.scheduled_staff }}</td>
<td>
<OnyxBadge :color="coverageColor(hour)" density="compact">{{ coverageLabel(hour) }}</OnyxBadge>
</td>
</tr>
</OnyxTable>
<p class="small muted table-note">
Scheduled staff is constant inside a block. Coverage is <em>at or above</em> the service standard by
construction; the trade-off is visible as overstaffed hours. Store hours 10:00–20:00 local.
</p>
</OnyxCard>
</div>
<aside class="card-stack">
<OnyxCard>
<div class="card-header">
<OnyxHeadline is="h2">Why this plan</OnyxHeadline>
<OnyxBadge color="info" density="compact">{{ usingMock ? 'Mock mode' : 'Go API' }}</OnyxBadge>
</div>
<ul class="why-list">
<li v-for="reason in why" :key="reason">
<OnyxIcon :icon="iconCircleInformation" size="16px" color="primary" />
<span>{{ reason }}</span>
</li>
</ul>
<OnyxSeparator style="margin-block: var(--onyx-density-md)" />
<p class="stat-label" style="margin-bottom: var(--onyx-density-xs)">Weather during the plan week</p>
<WeatherStrip :days="weekWeather" />
<p v-if="!weekWeather.length" class="small muted table-note">
The weather forecast from /api/context does not cover this plan window yet.
</p>
<p class="small muted table-note">
{{ activeScenario?.description ?? 'Base scenario uses the API forecast weather.' }}
</p>
<p v-if="previewActive" class="small muted table-note">
This card explains the API plan; the assumption preview above is local.
</p>
</OnyxCard>
<OnyxCard>
<div class="card-header">
<OnyxHeadline is="h3">Assumptions in this plan</OnyxHeadline>
</div>
<dl class="metric-list">
<div><dt>Service standard</dt><dd>{{ standard }}</dd></div>
<div><dt>Visitors / staff-hour</dt><dd>{{ plan.assumptions.visitors_per_staff_hour }}</dd></div>
<div><dt>Safety factor</dt><dd>×{{ plan.assumptions.safety_factor }}</dd></div>
<div><dt>Minimum staff</dt><dd>{{ plan.assumptions.min_staff }}</dd></div>
<div><dt>Shift block</dt><dd>{{ plan.assumptions.shift_length_h }} h</dd></div>
<div><dt>Labour cost</dt><dd>{{ formatEuro(plan.assumptions.labor_cost_eur_h) }}/h</dd></div>
<div><dt>Store hours</dt><dd>{{ plan.assumptions.store_hours.open }}–{{ plan.assumptions.store_hours.close }}</dd></div>
<div><dt>Model / data</dt><dd>{{ plan.model_version || meta?.model_version || '—' }}</dd></div>
</dl>
<p class="small muted table-note" style="margin-top: var(--onyx-density-md)">
No POS, sales, queue or labour-cost data exists. This is decision support with explicit assumptions,
not a payroll calculation or a precise ROI.
</p>
<OnyxButton
label="Edit assumptions"
mode="plain"
density="compact"
@click="openAssumptions = ['assumptions']"
/>
</OnyxCard>
<OnyxCard>
<div class="card-header">
<OnyxHeadline is="h3">Data and limits</OnyxHeadline>
</div>
<p class="small muted" style="margin-top: 0">
{{ meta?.coverage.sensors ?? 8 }} sensors · {{ meta?.coverage.cadence_min ?? 15 }}-min cadence ·
coverage {{ meta ? `${formatDate(meta.coverage.from)} → ${formatDate(meta.coverage.to)}` : '—' }}
</p>
<ul class="small muted" style="margin: var(--onyx-density-xs) 0 0; padding-left: 1.1rem">
<li v-for="limit in meta?.limits ?? []" :key="limit">{{ limit }}</li>
</ul>
</OnyxCard>
</aside>
</div>
</div>
</template>
<style scoped>
.peak-row {
background: var(--onyx-color-base-warning-100);
}
</style>
-270
View File
@@ -1,270 +0,0 @@
<script setup lang="ts">
import { iconArrowRight, iconCircleInformation, iconFlash } from '@sit-onyx/icons'
import { addDays, berlinParts, planWeekStart } from '#shared/staffing'
import type {
ContextResponse,
Scenario,
ScenarioPreset,
Sensor,
StaffingResponse,
} from '#shared/types'
import { formatEuro, formatShortDate, formatWeekday, formatWeekdayShort, weekLabel } from '~/utils/format'
useHead({ title: 'Simulate a scenario — PulseCast' })
const config = useRuntimeConfig()
const demoNow = String(config.public.demoNow)
const { data: sensors } = await useFetch<Sensor[]>('/api/sensors')
const { data: context } = await useFetch<ContextResponse>('/api/context')
const { data: presets } = await useFetch<ScenarioPreset[]>('/api/scenarios')
const sensorId = ref(
sensors.value?.find((sensor) => sensor.id === 'hn-stadtgalerie-01')?.id ??
sensors.value?.[0]?.id ??
'hn-stadtgalerie-01',
)
const scenario = ref<Scenario>('sunny-saturday-market')
const EMPTY_PLAN: StaffingResponse = {
sensor: '',
scenario: 'base',
standard: 'standard',
assumptions: {
visitors_per_staff_hour: 25,
safety_factor: 1.15,
min_staff: 1,
shift_length_h: 4,
labor_cost_eur_h: 16,
store_hours: { open: '10:00', close: '20:00', tz: 'Europe/Berlin' },
},
hours: [],
shifts: [],
summary: {
coverage_pct: 0,
cost_eur: 0,
flat_schedule_cost_eur: 0,
overstaffed_hours: 0,
understaffed_hours: 0,
},
why: [],
cached: false,
data_version: '',
model_version: '',
context_version: '',
}
const { data: baseData } = await useFetch<StaffingResponse>('/api/staffing', {
query: computed(() => ({ sensor: sensorId.value, scenario: 'base', standard: 'standard' })),
})
const { data: scenarioData, status } = await useFetch<StaffingResponse>('/api/staffing', {
query: computed(() => ({ sensor: sensorId.value, scenario: scenario.value, standard: 'standard' })),
})
const basePlan = computed(() => baseData.value ?? EMPTY_PLAN)
const scenarioPlan = computed(() => scenarioData.value ?? basePlan.value)
const weekStart = computed(() => {
const first = basePlan.value.hours[0]
return first ? berlinParts(first.t).date : planWeekStart(demoNow)
})
const weekEnd = computed(() => addDays(weekStart.value, 6))
const activeSensor = computed(() => sensors.value?.find((sensor) => sensor.id === sensorId.value))
const sensorOptions = computed(() =>
(sensors.value ?? []).map((sensor) => ({ value: sensor.id, label: sensor.name })),
)
const activePreset = computed(() => presets.value?.find((preset) => preset.id === scenario.value))
const radioOptions = computed(() =>
(presets.value ?? []).map((preset) => ({
value: preset.id,
label: preset.label,
description: preset.description,
})),
)
const baseHours = computed(() => basePlan.value.hours.reduce((sum, hour) => sum + hour.scheduled_staff, 0))
const scenarioHours = computed(() =>
scenarioPlan.value.hours.reduce((sum, hour) => sum + hour.scheduled_staff, 0),
)
const deltaHours = computed(() => scenarioHours.value - baseHours.value)
const deltaCost = computed(() => scenarioPlan.value.summary.cost_eur - basePlan.value.summary.cost_eur)
function peakStaffByDay(plan: StaffingResponse) {
const map: Record<string, number> = {}
for (const hour of plan.hours) {
const date = berlinParts(hour.t).date
map[date] = Math.max(map[date] ?? 0, hour.required_staff)
}
return map
}
const basePeaks = computed(() => peakStaffByDay(basePlan.value))
const scenarioPeaks = computed(() => peakStaffByDay(scenarioPlan.value))
const days = computed(() =>
[...new Set([...Object.keys(basePeaks.value), ...Object.keys(scenarioPeaks.value)])]
.sort()
.map((date) => ({
date,
base: basePeaks.value[date] ?? 0,
scenario: scenarioPeaks.value[date] ?? 0,
})),
)
</script>
<template>
<div class="page page-stack">
<header class="page-header">
<div>
<p class="eyebrow">Simulate · {{ weekLabel(weekStart, weekEnd) }}</p>
<OnyxHeadline is="h1">Change the weather, watch the plan move.</OnyxHeadline>
<p class="lede">
A scenario changes forecast footfall, not history. Compare the shift requirement against the base week
for <strong>{{ activeSensor?.name ?? 'Stadtgalerie' }}</strong>.
</p>
</div>
<div style="min-width: 14rem">
<OnyxSelect
v-model="sensorId"
label="Sensor"
list-label="Inner-city sensors"
:options="sensorOptions"
density="compact"
/>
</div>
</header>
<div class="callout">
<OnyxIcon :icon="iconCircleInformation" size="16px" color="primary" />
The base and scenario plans are generated by Go /api/staffing. The presenter broadcasts from
<NuxtLink to="/control">/control</NuxtLink>; <NuxtLink to="/stage">/stage</NuxtLink> and
<NuxtLink to="/live">/live</NuxtLink> follow the scenario over SSE with a 5 s polling fallback.
</div>
<div class="split-grid">
<div class="card-stack">
<OnyxCard>
<div class="card-header">
<div>
<OnyxHeadline is="h2">Scenario</OnyxHeadline>
<p class="small muted" style="margin: 0">The contract enum is fixed; the API applies the perturbation.</p>
</div>
<OnyxBadge :color="status === 'pending' ? 'warning' : 'success'" density="compact">
{{ status === 'pending' ? 'loading' : 'Go API' }}
</OnyxBadge>
</div>
<OnyxRadioGroup
v-model="scenario"
label="Choose a scenario"
:options="radioOptions"
orientation="vertical"
/>
</OnyxCard>
<OnyxCard>
<div class="card-header">
<div>
<OnyxHeadline is="h2">Day by day</OnyxHeadline>
<p class="small muted" style="margin: 0">Peak required staff per day, base vs scenario.</p>
</div>
</div>
<OnyxTable striped :table-attrs="{ style: 'min-width: 30rem' }">
<template #head>
<tr>
<th scope="col">Day</th>
<th scope="col">Base peak</th>
<th scope="col">Scenario peak</th>
<th scope="col">Δ staff</th>
</tr>
</template>
<tr v-for="day in days" :key="day.date">
<th scope="row" style="text-align: left; font-weight: 600">
{{ formatWeekday(day.date) }}
<span class="muted" style="font-weight: 400">{{ formatShortDate(day.date) }}</span>
</th>
<td>{{ day.base }}</td>
<td>{{ day.scenario }}</td>
<td>
<OnyxBadge :color="day.scenario > day.base ? 'warning' : day.scenario < day.base ? 'success' : 'neutral'" density="compact">
{{ day.scenario === day.base ? '±0' : `${day.scenario > day.base ? '+' : ''}${day.scenario - day.base}` }}
</OnyxBadge>
</td>
</tr>
</OnyxTable>
</OnyxCard>
</div>
<aside class="card-stack">
<OnyxCard>
<div class="card-header">
<OnyxHeadline is="h2">What changes</OnyxHeadline>
<OnyxIcon :icon="iconFlash" size="24px" color="primary" />
</div>
<p style="margin-top: 0"><strong>{{ activePreset?.label ?? 'Base week' }}</strong></p>
<p class="small muted" style="margin-top: 0">{{ activePreset?.description }}</p>
<dl class="metric-list">
<div><dt>Base staff-hours</dt><dd>{{ baseHours }}</dd></div>
<div><dt>Scenario staff-hours</dt><dd>{{ scenarioHours }}</dd></div>
<div><dt>Δ staff-hours</dt><dd>{{ deltaHours >= 0 ? '+' : '' }}{{ deltaHours }}</dd></div>
<div><dt>Δ labour cost</dt><dd>{{ deltaCost >= 0 ? '+' : '' }}{{ formatEuro(deltaCost) }}</dd></div>
<div><dt>Base cost</dt><dd>{{ formatEuro(basePlan.summary.cost_eur) }}</dd></div>
<div><dt>Scenario cost</dt><dd>{{ formatEuro(scenarioPlan.summary.cost_eur) }}</dd></div>
</dl>
<div class="callout" style="margin-top: var(--onyx-density-md)">
<p class="small" style="margin: 0">
<template v-if="deltaHours > 0">
This scenario adds {{ deltaHours }} staff-hours. Check that the Saturday block can be covered before
approving.
</template>
<template v-else-if="deltaHours < 0">
This scenario removes {{ Math.abs(deltaHours) }} staff-hours. The plan gets cheaper, but check the
peak hour before cutting the block.
</template>
<template v-else>
This scenario does not change the shift requirements. That is a result, not a bug.
</template>
</p>
</div>
<OnyxButton
:label="`Apply to plan`"
:icon="iconArrowRight"
icon-position="right"
color="primary"
:link="`/plan?scenario=${scenario}`"
style="margin-top: var(--onyx-density-md)"
/>
</OnyxCard>
<OnyxCard>
<div class="card-header">
<OnyxHeadline is="h3">Scenario rules</OnyxHeadline>
</div>
<ul class="why-list">
<li><span><strong>Base week</strong> — latest forecast weather, no scenario uplift.</span></li>
<li><span><strong>Sunny Saturday + market</strong> — Go applies the market/day uplift to next Saturday.</span></li>
<li><span><strong>Rainy Saturday</strong> — Go applies the wet-weather reduction.</span></li>
<li><span><strong>Wednesday event</strong> — Go applies the weekday evening event uplift.</span></li>
</ul>
<p class="small muted table-note">
Scenario perturbations are produced by the Go/ML stack. This page reads the base and scenario plans from
/api/staffing; it does not invent its own multipliers.
</p>
</OnyxCard>
<OnyxCard>
<div class="card-header">
<OnyxHeadline is="h3">Context</OnyxHeadline>
</div>
<p class="small muted" style="margin-top: 0">
Weather now: {{ context?.weather.now.temp_c ?? '—' }} °C, {{ context?.weather.now.precip_mm ?? '—' }} mm
precipitation.
</p>
<p class="small muted" style="margin: 0">
{{ formatWeekdayShort(weekStart) }} {{ formatShortDate(weekStart) }} → {{ formatWeekdayShort(weekEnd) }}
{{ formatShortDate(weekEnd) }} · Europe/Berlin.
</p>
</OnyxCard>
</aside>
</div>
</div>
</template>
-560
View File
@@ -1,560 +0,0 @@
<script setup lang="ts">
import {
iconArrowRight,
iconCalendar,
iconCheck,
iconMobileSignal,
iconQrCode,
iconSync,
iconTriangleWarning,
iconUserGroup,
} from '@sit-onyx/icons'
import { scenarioLabel } from '#shared/live'
import type {
ForecastResponse,
ScenarioState,
Sensor,
Shift,
StaffingHour,
StaffingResponse,
} from '#shared/types'
import { formatDateTime, formatEuro, formatPercent, formatShortDate, formatWeekday } from '~/utils/format'
useHead({ title: 'Stage — PulseCast live decision' })
const { data: sensors } = await useFetch<Sensor[]>('/api/sensors')
const { data: initialScenario } = await useFetch<ScenarioState>('/api/scenario')
const sensorId = ref(
sensors.value?.find((sensor) => sensor.id === 'hn-stadtgalerie-01')?.id ??
sensors.value?.[0]?.id ??
'hn-stadtgalerie-01',
)
const live = useLiveScenario(initialScenario.value)
const {
data: planData,
status: planStatus,
error: planError,
refresh: refreshPlan,
} = await useFetch<StaffingResponse>('/api/staffing', {
query: computed(() => ({
sensor: sensorId.value,
scenario: live.scenarioId,
standard: 'standard',
})),
})
const {
data: forecastData,
error: forecastError,
refresh: refreshForecast,
} = await useFetch<ForecastResponse>('/api/forecast', {
query: computed(() => ({
sensor: sensorId.value,
horizon: '7d',
scenario: live.scenarioId,
})),
})
// A new version of the same scenario (new weather/event values) does not
// change the query string, so refresh explicitly. A different scenario id
// already triggers useFetch's own query watcher.
let lastScenarioId = live.scenarioId
watch(
() => live.revision,
() => {
if (live.scenarioId === lastScenarioId) {
void refreshPlan()
void refreshForecast()
}
lastScenarioId = live.scenarioId
},
)
const plan = computed<StaffingResponse | null>(() => planData.value ?? null)
const activeSensor = computed(() => sensors.value?.find((sensor) => sensor.id === sensorId.value))
function maxOf<T>(items: T[], score: (item: T) => number): T | undefined {
let best: T | undefined
for (const item of items) if (!best || score(item) > score(best)) best = item
return best
}
const peakShift = computed<Shift | undefined>(() =>
plan.value ? maxOf(plan.value.shifts, (shift) => shift.staff) : undefined,
)
const peakHour = computed<StaffingHour | undefined>(() =>
plan.value ? maxOf(plan.value.hours, (hour) => hour.required_staff) : undefined,
)
const peakStaff = computed(() => peakShift.value?.staff ?? peakHour.value?.required_staff ?? 0)
const totalStaffHours = computed(() =>
plan.value ? plan.value.hours.reduce((sum, hour) => sum + hour.scheduled_staff, 0) : 0,
)
const forecastPeak = computed(() => {
const points = forecastData.value?.points ?? []
return points.length ? Math.max(...points.map((point) => point.v)) : 0
})
const saving = computed(() =>
plan.value ? Math.max(0, plan.value.summary.flat_schedule_cost_eur - plan.value.summary.cost_eur) : 0,
)
const requestUrl = useRequestURL()
const liveUrl = computed(() => {
const origin = import.meta.client ? window.location.origin : requestUrl.origin
return `${origin}/live`
})
const qrSrc = computed(() => `/api/qr?text=${encodeURIComponent(liveUrl.value)}`)
const headline = computed(() => {
if (!plan.value) return 'Waiting for the next staffing plan.'
const shift = peakShift.value
if (!shift) return 'Next week has no shift blocks yet.'
return `${formatWeekday(shift.date)} peak: ${shift.staff} staff, ${shift.start}–${shift.end}.`
})
</script>
<template>
<div class="page page-stack stage-page">
<header class="stage-hero">
<div class="stage-hero__copy">
<div class="stage-kicker">
<OnyxBadge color="neutral" density="compact">PulseCast stage</OnyxBadge>
<LiveStatusBadge :status="live.status" :last-event-at="live.lastEventAt" />
<OnyxBadge v-if="plan?.cached" color="warning" density="compact">cached forecast</OnyxBadge>
</div>
<h1 class="stage-headline">{{ headline }}</h1>
<p class="stage-sub">
{{ activeSensor?.name ?? 'Stadtgalerie' }} · {{ scenarioLabel(live.scenarioId) }} ·
{{ plan ? `${totalStaffHours} staff-hours` : 'waiting for the API' }} · updates live via SSE
</p>
<div class="stage-scenario">
<OnyxIcon :icon="iconCalendar" size="18px" color="primary" />
<span>
<strong>Scenario version {{ live.version || '—' }}</strong>
<template v-if="live.scenarioAt"> · broadcast {{ formatDateTime(live.scenarioAt) }}</template>
</span>
</div>
</div>
<div class="stage-qr">
<div class="stage-qr__frame">
<img :src="qrSrc" width="220" height="220" :alt="`QR code to ${liveUrl}`" />
</div>
<p class="stage-qr__label">
<OnyxIcon :icon="iconQrCode" size="16px" color="primary" />
Scan for the phone view
</p>
<p class="stage-qr__url mono">{{ liveUrl }}</p>
</div>
</header>
<div v-if="planError" class="callout callout--warning" role="alert">
<OnyxIcon :icon="iconTriangleWarning" size="18px" color="warning" />
<div>
<strong>The plan is unavailable.</strong>
<span class="muted">&nbsp;{{ planError.statusMessage ?? 'Check the Go API and ML service.' }}</span>
</div>
<OnyxButton label="Retry" mode="outline" density="compact" :icon="iconSync" @click="refreshPlan()" />
</div>
<div v-else-if="planStatus === 'pending' && !plan" class="callout">
<OnyxIcon :icon="iconSync" size="18px" color="primary" class="spin-slow" />
<span>Loading the current staffing plan…</span>
</div>
<div v-else-if="plan && !plan.hours.length" class="callout callout--warning" role="status">
<OnyxIcon :icon="iconTriangleWarning" size="18px" color="warning" />
<span>No open hours are available for this sensor yet. Check the data window or pick another store.</span>
</div>
<section class="stage-metrics" aria-label="Decision summary">
<div class="stage-metric stage-metric--primary">
<p class="stage-metric__label"><OnyxIcon :icon="iconUserGroup" size="18px" color="primary" /> Peak staff</p>
<p class="stage-metric__value">{{ plan ? peakStaff : '—' }}</p>
<p class="stage-metric__hint">
<template v-if="peakShift">{{ formatWeekday(peakShift.date) }} {{ peakShift.start }}–{{ peakShift.end }}</template>
<template v-else>Per shift block</template>
</p>
</div>
<div class="stage-metric">
<p class="stage-metric__label">Labour cost</p>
<p class="stage-metric__value">{{ plan ? formatEuro(plan.summary.cost_eur) : '—' }}</p>
<p class="stage-metric__hint">{{ plan ? `€${plan.assumptions.labor_cost_eur_h}/h assumption` : '—' }}</p>
</div>
<div class="stage-metric">
<p class="stage-metric__label">Coverage</p>
<p class="stage-metric__value">{{ plan ? formatPercent(plan.summary.coverage_pct, 1) : '—' }}</p>
<p class="stage-metric__hint">
{{ plan ? `${plan.summary.understaffed_hours} h under` : '—' }}
</p>
</div>
<div class="stage-metric">
<p class="stage-metric__label">Forecast peak</p>
<p class="stage-metric__value">{{ forecastPeak ? Math.round(forecastPeak) : '—' }}</p>
<p class="stage-metric__hint">estimated devices/hour</p>
</div>
<div class="stage-metric">
<p class="stage-metric__label">vs flat schedule</p>
<p class="stage-metric__value">−{{ plan ? formatEuro(saving) : '—' }}</p>
<p class="stage-metric__hint">same coverage, fewer hours</p>
</div>
</section>
<div class="stage-grid">
<section class="stage-panel" aria-labelledby="stage-decision">
<div class="stage-panel__head">
<OnyxHeadline id="stage-decision" is="h2">The decision on stage</OnyxHeadline>
<OnyxBadge color="success" density="compact">{{ scenarioLabel(live.scenarioId) }}</OnyxBadge>
</div>
<p class="stage-decision">
<template v-if="peakShift">
Put <strong>{{ peakShift.staff }} staff</strong> on {{ formatWeekday(peakShift.date) }}
{{ formatShortDate(peakShift.date) }}, {{ peakShift.start }}–{{ peakShift.end }}.
</template>
<template v-else>Pick a store and scenario; the recommendation appears here.</template>
</p>
<p class="stage-why">
<OnyxIcon :icon="iconCheck" size="18px" color="success" />
<template v-if="plan">
{{ plan.summary.understaffed_hours === 0 ? 'Every open hour is covered by the block plan.' : `${plan.summary.understaffed_hours} hours are below requirement.` }}
{{ plan.summary.overstaffed_hours }} hours are intentionally over requirement.
</template>
<template v-else>Nothing to approve yet.</template>
</p>
<div class="stage-actions">
<OnyxButton label="Presenter control" link="/control" color="primary" :icon="iconArrowRight" icon-position="right" />
<OnyxButton label="Open full plan" link="/plan" mode="outline" />
<OnyxButton label="Refresh" mode="plain" :icon="iconSync" @click="refreshPlan()" />
</div>
<p v-if="forecastError" class="small muted">
Forecast refresh failed: {{ forecastError.statusMessage }}
</p>
</section>
<aside class="stage-panel stage-panel--aside">
<div class="stage-panel__head">
<OnyxHeadline is="h2">On every phone</OnyxHeadline>
<OnyxBadge color="info" density="compact">no login</OnyxBadge>
</div>
<div class="stage-phone">
<div class="stage-phone__screen">
<p class="stage-phone__kicker"><OnyxIcon :icon="iconMobileSignal" size="14px" color="primary" /> LIVE</p>
<p class="stage-phone__value">{{ plan ? peakStaff : '—' }} staff</p>
<p class="stage-phone__label">
<template v-if="peakShift">{{ formatWeekday(peakShift.date) }} · {{ peakShift.start }}–{{ peakShift.end }}</template>
<template v-else>Waiting for the plan</template>
</p>
<p class="stage-phone__scenario">{{ scenarioLabel(live.scenarioId) }} · v{{ live.version || '—' }}</p>
</div>
</div>
<p class="small muted">
The audience scans the QR code. The same scenario event refreshes the phone view and this screen within
the SSE round trip.
</p>
</aside>
</div>
<footer class="stage-footer">
<span>
<strong>Assumptions:</strong> {{ plan?.assumptions.visitors_per_staff_hour ?? 25 }} visitors per staff-hour,
×{{ plan?.assumptions.safety_factor ?? 1.15 }} safety, {{ plan?.assumptions.shift_length_h ?? 4 }} h blocks,
store hours {{ plan?.assumptions.store_hours.open ?? '10:00' }}–{{ plan?.assumptions.store_hours.close ?? '20:00' }}.
</span>
<span class="muted">
Estimated devices, not people · 8 sensors in a 580 m cluster · no POS or payroll feed ·
last update {{ plan ? formatDateTime(live.scenarioAt || plan.context_version) : '—' }}
</span>
</footer>
</div>
</template>
<style scoped>
.stage-page {
gap: clamp(1rem, 2vw, 1.75rem);
}
.stage-hero {
display: grid;
grid-template-columns: minmax(0, 1fr) auto;
gap: clamp(1rem, 3vw, 2.5rem);
align-items: center;
padding: clamp(1.25rem, 2.5vw, 2.5rem);
border: 1px solid var(--onyx-color-base-primary-200);
border-radius: var(--onyx-radius-component-container-soft);
background:
radial-gradient(circle at 100% 0%, var(--onyx-color-base-primary-200), transparent 45%),
linear-gradient(135deg, var(--onyx-color-base-primary-100), var(--onyx-color-base-neutral-100) 70%);
}
.stage-kicker,
.stage-scenario,
.stage-actions {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: var(--onyx-density-sm);
}
.stage-headline {
max-width: 24ch;
margin: var(--onyx-density-sm) 0 0;
font-size: clamp(2.1rem, 4.8vw, 4.5rem);
font-weight: 800;
letter-spacing: -0.03em;
line-height: 1.02;
color: var(--onyx-color-text-icons-primary-intense);
}
.stage-sub {
max-width: 70ch;
margin: var(--onyx-density-sm) 0 0;
color: var(--onyx-color-text-icons-neutral-medium);
font-size: clamp(0.95rem, 1.5vw, 1.15rem);
}
.stage-scenario {
margin-top: var(--onyx-density-md);
font-size: 0.9rem;
}
.stage-qr {
display: flex;
flex-direction: column;
align-items: center;
gap: var(--onyx-density-xs);
text-align: center;
}
.stage-qr__frame {
padding: 0.65rem;
border: 1px solid var(--onyx-color-base-neutral-300);
border-radius: var(--onyx-radius-component-container-soft);
background: #fff;
box-shadow: var(--onyx-shadow-soft-bottom);
}
.stage-qr__frame img {
display: block;
width: min(220px, 32vw);
height: auto;
}
.stage-qr__label {
display: flex;
align-items: center;
gap: 0.35rem;
margin: 0;
font-weight: 600;
}
.stage-qr__url {
max-width: 18rem;
margin: 0;
overflow-wrap: anywhere;
color: var(--onyx-color-text-icons-neutral-medium);
}
.stage-metrics {
display: grid;
grid-template-columns: repeat(5, minmax(0, 1fr));
gap: var(--onyx-density-sm);
}
.stage-metric {
min-width: 0;
padding: var(--onyx-density-md);
border: 1px solid var(--onyx-color-base-neutral-300);
border-radius: var(--onyx-radius-component-container-soft);
background: var(--onyx-color-base-neutral-100);
}
.stage-metric--primary {
border-color: var(--onyx-color-base-primary-400);
background: var(--onyx-color-base-primary-100);
}
.stage-metric__label {
display: flex;
align-items: center;
gap: 0.35rem;
margin: 0;
color: var(--onyx-color-text-icons-neutral-medium);
font-size: 0.8rem;
font-weight: 600;
}
.stage-metric__value {
margin: var(--onyx-density-xs) 0 0;
font-size: clamp(1.5rem, 2.6vw, 2.5rem);
font-weight: 800;
line-height: 1.05;
}
.stage-metric__hint {
margin: var(--onyx-density-2xs) 0 0;
color: var(--onyx-color-text-icons-neutral-soft);
font-size: 0.75rem;
}
.stage-grid {
display: grid;
grid-template-columns: minmax(0, 1.65fr) minmax(16rem, 1fr);
gap: var(--onyx-density-lg);
align-items: start;
}
.stage-panel {
min-width: 0;
padding: clamp(1rem, 2vw, 1.75rem);
border: 1px solid var(--onyx-color-base-neutral-300);
border-radius: var(--onyx-radius-component-container-soft);
background: var(--onyx-color-base-neutral-100);
}
.stage-panel--aside {
background: var(--onyx-color-base-neutral-200);
}
.stage-panel__head {
display: flex;
flex-wrap: wrap;
align-items: center;
justify-content: space-between;
gap: var(--onyx-density-xs);
}
.stage-panel__head h2 {
margin: 0;
}
.stage-decision {
margin: var(--onyx-density-md) 0 0;
font-size: clamp(1.1rem, 2vw, 1.5rem);
line-height: 1.35;
}
.stage-why {
display: flex;
gap: var(--onyx-density-xs);
align-items: flex-start;
margin: var(--onyx-density-sm) 0 0;
color: var(--onyx-color-text-icons-neutral-medium);
}
.stage-actions {
margin-top: var(--onyx-density-lg);
}
.stage-phone {
display: flex;
justify-content: center;
margin-block: var(--onyx-density-md);
}
.stage-phone__screen {
width: min(15rem, 100%);
padding: var(--onyx-density-md);
border: 6px solid #1e293b;
border-radius: 1.5rem;
background: #fff;
box-shadow: var(--onyx-shadow-soft-bottom);
}
.stage-phone__kicker {
display: flex;
align-items: center;
gap: 0.25rem;
margin: 0;
color: var(--onyx-color-text-icons-primary-intense);
font-size: 0.7rem;
font-weight: 700;
letter-spacing: 0.08em;
}
.stage-phone__value {
margin: 0.35rem 0 0;
font-size: 2.2rem;
font-weight: 800;
line-height: 1;
}
.stage-phone__label {
margin: 0.25rem 0 0;
font-size: 0.85rem;
}
.stage-phone__scenario {
margin: 0.75rem 0 0;
color: var(--onyx-color-text-icons-neutral-medium);
font-size: 0.72rem;
}
.stage-footer {
display: flex;
flex-wrap: wrap;
justify-content: space-between;
gap: var(--onyx-density-sm);
padding-top: var(--onyx-density-sm);
border-top: 1px solid var(--onyx-color-base-neutral-300);
color: var(--onyx-color-text-icons-neutral-medium);
font-size: 0.75rem;
line-height: 1.45;
}
.stage-footer span {
max-width: 75ch;
}
.spin-slow {
animation: spin 1.4s linear infinite;
}
@keyframes spin {
to {
transform: rotate(360deg);
}
}
@media (prefers-reduced-motion: reduce) {
.spin-slow {
animation: none;
}
}
@media (max-width: 1100px) {
.stage-metrics {
grid-template-columns: repeat(3, minmax(0, 1fr));
}
}
@media (max-width: 900px) {
.stage-hero,
.stage-grid {
grid-template-columns: minmax(0, 1fr);
}
.stage-qr {
align-items: flex-start;
text-align: left;
}
.stage-qr__frame img {
width: min(180px, 50vw);
}
}
@media (max-width: 576px) {
.stage-metrics {
grid-template-columns: repeat(2, minmax(0, 1fr));
}
.stage-headline {
font-size: clamp(1.8rem, 8vw, 2.6rem);
}
.stage-footnote {
display: none;
}
}
</style>