/* @spec spec://modules/demo/FEAT-004-service-demo#scenarios */
:root {
  color-scheme: dark;
  font-family: Inter, "Segoe UI", system-ui, sans-serif;
  --bg: #15121d;
  --side: #191522;
  --surface: #211b2c;
  --surface-raised: #282033;
  --line: #3b3248;
  --line-subtle: #342c40;
  --ink: #f7f4fb;
  --muted: #b7adc5;
  --quiet: #a297b2;
  --violet: #d0baff;
  --purple: #a586e1;
  --sage: #b7d59b;
  --rose: #f0a6a7;
  --warning: #efc58f;
  --mono: "IBM Plex Mono", "Cascadia Mono", ui-monospace, monospace;
  --radius: 12px;
  font-size: 14px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 300px; background: var(--bg); color: var(--ink); }
a { color: inherit; text-decoration: none; }
button, select, input, textarea { font: inherit; color: inherit; }
button, select { cursor: pointer; }
button:disabled { cursor: default; opacity: .6; }
:focus-visible { outline: 2px solid var(--violet); outline-offset: 3px; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(30px, 3.2vw, 45px); line-height: 1.06; letter-spacing: -.048em; font-weight: 720; }
h2 { font-size: 19px; line-height: 1.25; letter-spacing: -.018em; font-weight: 680; }
h3 { font-size: 15px; line-height: 1.35; letter-spacing: -.012em; font-weight: 650; }
.icon { width: 19px; height: 19px; flex: none; vertical-align: middle; }
.muted { color: var(--muted); }
.subtle { color: var(--quiet); font-size: 12px; }
.numeric { font-variant-numeric: tabular-nums; white-space: nowrap; }
.sr-only, .skip-link:not(:focus) {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.skip-link:focus { position: fixed; z-index: 20; top: 10px; left: 10px; background: var(--surface); padding: 10px; }

.shell { display: grid; grid-template-columns: 218px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 27px 15px 19px;
  background: linear-gradient(150deg, #201929 0%, var(--side) 55%); border-right: 1px solid var(--line-subtle);
}
.wordmark { display: flex; align-items: center; gap: 11px; margin: 0 7px 44px; width: fit-content; font-size: 17px; font-weight: 720; letter-spacing: -.035em; }
.wordmark small { display: block; margin-top: 3px; font-size: 11px; color: var(--muted); font-weight: 500; letter-spacing: 0; }
.brand-symbol {
  display: grid; grid-template-columns: 6px 6px; grid-auto-rows: 6px; place-content: center;
  gap: 2.5px; width: 36px; height: 36px; border: 1px solid #a684da; border-radius: 10px;
  background: #301f45; transform: rotate(-7deg); box-shadow: 0 4px 16px #0e0a18a0;
}
.brand-symbol i { border-radius: 1.5px; background: var(--violet); }
.brand-symbol i:nth-child(2) { background: var(--sage); transform: translate(1px, -1px); }
.brand-symbol i:nth-child(4) { border: 1px solid var(--violet); background: transparent; }
.navigation { display: flex; flex-direction: column; gap: 6px; }
.navigation a {
  position: relative; display: flex; align-items: center; gap: 11px; color: var(--muted);
  border: 1px solid transparent; border-radius: 9px; padding: 11px 12px; font-size: 13px; font-weight: 560;
}
.navigation a:hover { background: #2a2135; color: var(--ink); }
.navigation a[aria-current] { color: var(--violet); background: #322641; border-color: #49375e; }
.navigation a[aria-current]::after { content: ""; position: absolute; right: 11px; width: 4px; height: 4px; border-radius: 50%; background: var(--violet); }
.sidebar-footer { display: flex; align-items: flex-start; gap: 9px; padding: 14px 7px 3px; margin: auto 5px 0; border-top: 1px solid var(--line-subtle); font-size: 12px; }
.sidebar-footer small { display: block; margin-top: 4px; color: var(--quiet); font-size: 11px; line-height: 1.3; }
.live-dot { flex: none; width: 6px; height: 6px; margin-top: 5px; border-radius: 50%; background: var(--sage); box-shadow: 0 0 10px #b7d59b44; }

.workspace { min-width: 0; background: radial-gradient(95% 456px at 44% -150px, #332543 2%, var(--bg) 100%); }
.topbar { display: flex; align-items: center; justify-content: space-between; min-height: 61px; gap: 14px; padding: 8px clamp(18px, 3vw, 43px); border-bottom: 1px solid var(--line-subtle); }
.breadcrumb { color: var(--muted); font-weight: 550; font-size: 13px; }
.topbar-tools, .persona { display: flex; align-items: center; }
.topbar-tools { min-width: 0; }
.persona { gap: 9px; width: min(60vw, 270px); max-width: 100%; min-width: 0; cursor: pointer; }
.avatar { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; color: var(--violet); font-weight: 750; font-size: 11px; background: #382a48; border: 1px solid #4b3a5f; flex: none; }
.persona-copy { flex: 1; display: grid; grid-template-columns: minmax(0, 1fr); gap: 1px; min-width: 0; }
.persona-copy small { font-size: 10px; color: var(--quiet); }
.persona select { padding: 0 4px 1px 0; border: 0; background: transparent; max-width: 100%; font-size: 12px; font-weight: 610; text-overflow: ellipsis; }
option { background: var(--surface-raised); color: var(--ink); }

main { width: min(100%, 1550px); padding: 32px clamp(18px, 3vw, 43px) 45px; margin: 0 auto; }
.page-heading, .section-heading, .panel-heading { display: flex; justify-content: space-between; align-items: center; gap: 14px; }
.page-heading { margin-bottom: 25px; align-items: flex-end; }
.page-heading p, .section-heading p, .dialog-heading p { margin-top: 7px; color: var(--muted); line-height: 1.45; }
.section-heading { margin: 23px 0 11px; }
.section-heading p { margin-top: 4px; font-size: 12px; }
.heading-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; justify-content: flex-end; }
.panel { background: var(--surface); border: 1px solid var(--line-subtle); border-radius: var(--radius); min-width: 0; }
.button, .icon-button, .select-field, .filters select, .edit-form :is(select, input, textarea) {
  border: 1px solid var(--line); border-radius: 8px; background: #272031; color: var(--ink);
}
.button, .icon-button, .select-field { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 37px; }
.button { padding: 0 11px; font-weight: 610; font-size: 12px; white-space: nowrap; }
.button .icon, .select-field .icon { width: 16px; height: 16px; }
.button.primary { background: var(--violet); border-color: var(--violet); color: #251832; }
.button:hover, .icon-button:hover { border-color: #76628b; background: #342841; }
.button.primary:hover { color: #1c1029; background: #e0cfff; border-color: #e0cfff; }
.icon-button { width: 34px; min-height: 34px; padding: 0; color: var(--muted); flex: none; }
.icon-button:hover { color: var(--ink); }
.text-button { display: inline-flex; align-items: center; gap: 3px; border: 0; background: transparent; color: var(--violet); padding: 0; font-size: 12px; font-weight: 600; }
.text-button:hover { color: #eddeff; text-decoration: underline; }
.text-button .icon { width: 15px; height: 15px; }
.select-field { justify-content: stretch; padding: 0 8px; color: var(--muted); max-width: 100%; }
.select-field select { min-width: 0; width: 100%; align-self: stretch; border: 0; background: transparent; font-size: 12px; font-weight: 600; }

.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.metric { min-height: 112px; padding: 12px 14px 11px; background: linear-gradient(157deg, #272033, var(--surface) 86%); }
.metric-top { display: flex; align-items: center; justify-content: space-between; gap: 5px; color: var(--muted); font-size: 12px; }
.metric-icon { width: 29px; height: 29px; display: grid; place-items: center; border-radius: 7px; border: 1px solid #4c3b61; background: #352946; color: var(--violet); flex: none; }
.metric-icon .icon { width: 16px; height: 16px; }
.metric strong { display: block; margin: 1px 0 4px; font-size: clamp(24px, 2.45vw, 36px); line-height: 1.06; letter-spacing: -.053em; font-variant-numeric: tabular-nums; }
.metric small { color: var(--quiet); font-size: 11px; }
.metric:first-child strong { color: var(--sage); }

.camera-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); gap: 11px; }
.camera-card { overflow: hidden; }
.camera-card:focus-within { border-color: var(--violet); }
.camera-grid:has(> :only-child) .camera-card { max-width: 560px; }
.camera-image {
  position: relative; display: grid; place-items: center; width: 100%; aspect-ratio: 2.1; isolation: isolate;
  padding: 0; border: 0; border-bottom: 1px solid var(--line-subtle);
  background: radial-gradient(ellipse at 75% 10%, #3b2a52, #1c1727 70%); overflow: hidden;
}
.camera-image::before { content: ""; position: absolute; inset: 0; z-index: -2; opacity: .35; background: repeating-linear-gradient(90deg, transparent 0 28px, #6f5b891e 29px 30px), repeating-linear-gradient(transparent 0 28px, #6f5b8924 29px 30px); }
.camera-image::after { content: ""; position: absolute; inset: 0; z-index: -1; background: linear-gradient(158deg, #100b16a0, transparent 46%, #0a07104d); }
.camera-image img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: center 48%; z-index: -2; filter: brightness(.81) saturate(.83); }
.camera-image:hover img { filter: brightness(.96) saturate(.9); }
.camera-image:focus-visible { outline-offset: -3px; }
.camera-placeholder { color: #a287bc; opacity: .4; display: grid; place-items: center; }
.camera-placeholder .icon { width: 36px; height: 36px; }
.camera-image:has(img:not([hidden])) .camera-placeholder { display: none; }
.play-tile {
  position: absolute; right: 10px; bottom: 9px; display: grid; place-items: center; width: 35px; height: 35px;
  border: 1px solid #ebe2ff8a; border-radius: 50%; color: #f4ecff; background: #181223b8;
  transition: color .16s, background .16s, transform .16s;
}
.play-tile .icon { width: 17px; height: 17px; }
.camera-image:hover .play-tile { background: var(--violet); color: #271739; transform: scale(1.07); }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 8px; border: 1px solid #554761; border-radius: 6px; font-size: 10px; font-weight: 680; white-space: nowrap; line-height: 1.25; }
.pill i { width: 5px; height: 5px; flex: none; border-radius: 50%; background: currentColor; }
.connection { background: #1d1729ed; color: var(--muted); }
.connection.live { border-color: #698458; color: #c7e4ae; background: #1f2b1fe8; }
.connection.offline { border-color: #75525b; color: var(--rose); }
.connection.connecting { border-color: #685740; color: var(--warning); }
.camera-image .connection { position: absolute; top: 9px; left: 10px; }
.camera-label { display: flex; justify-content: space-between; align-items: center; gap: 7px; min-height: 59px; padding: 10px 12px; }
.camera-label p { margin-top: 3px; color: var(--quiet); font-size: 11px; }
.camera-people { text-align: right; color: var(--violet); }
.camera-people strong { display: block; font-weight: 670; line-height: 1; font-size: 19px; }
.camera-people small { font-size: 10px; color: var(--quiet); white-space: nowrap; }
.camera-source { margin: 15px 0 0; }

.analysis-grid { display: grid; grid-template-columns: minmax(0, 1.9fr) minmax(220px, 1fr); gap: 11px; }
.chart-panel, .breakdown { padding: 14px 14px 12px; }
.panel-heading { align-items: flex-start; }
.legend { display: flex; flex-wrap: wrap; gap: 7px 12px; margin-top: 7px; font-size: 11px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 4px; }
.legend i { width: 7px; height: 7px; border-radius: 2px; }
.chart-uniform, .chart-resolved { background: var(--sage); }
.chart-no_uniform, .chart-open { background: var(--purple); }
.chart-unclear { background: #675976; }
.chart { display: grid; grid-template-columns: minmax(27px, auto) minmax(0, 1fr); height: 185px; margin-top: 14px; }
.chart-scale { padding: 0 7px 24px 0; display: flex; justify-content: space-between; flex-direction: column; align-items: flex-end; font-size: 9px; color: var(--quiet); font-family: var(--mono); }
.chart-body { display: grid; position: relative; grid-template-columns: repeat(var(--columns), minmax(0, 1fr)); }
.chart-lines { position: absolute; inset: 5px 0 28px; display: flex; flex-direction: column; justify-content: space-between; pointer-events: none; }
.chart-lines i { border-top: 1px solid var(--line); }
.chart-column { position: relative; display: grid; grid-template-rows: 1fr 24px; min-width: 0; padding: 6px 0 0; border: 0; background: transparent; color: var(--muted); }
.chart-column[aria-pressed="true"] { background: #d0baff12; border-radius: 6px; color: var(--ink); }
.chart-column:hover { background: #d0baff0d; border-radius: 6px; }
.bar-space { display: flex; align-items: flex-end; justify-content: center; margin-bottom: 4px; min-height: 0; }
.bar-stack { display: flex; flex-direction: column-reverse; position: relative; width: clamp(10px, 53%, 56px); height: var(--height); border-radius: 3px 3px 1px 1px; }
.bar-stack i { display: block; min-height: 1px; }
.bar-stack i:last-child { border-radius: 3px 3px 0 0; }
.bar-stack b { position: absolute; bottom: calc(100% + 2px); left: 50%; transform: translateX(-50%); color: var(--ink); font-size: 9px; font-variant-numeric: tabular-nums; }
.bar-label { font-family: var(--mono); font-size: clamp(7px, .78vw, 10px); align-self: center; white-space: nowrap; }
.ratio { display: flex; align-items: baseline; flex-wrap: wrap; gap: 7px; margin: 10px 0 2px; }
.ratio strong { color: var(--sage); letter-spacing: -.06em; font-size: 36px; line-height: 1.05; }
.ratio span, .breakdown p { color: var(--muted); font-size: 11px; }
.distribution { display: grid; gap: 9px; margin: 12px 0 10px; }
.distribution-item { display: grid; gap: 4px; }
.distribution-item div:first-child { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 11px; color: var(--muted); }
.distribution-item strong { color: var(--ink); }
.meter { height: 4px; border-radius: 8px; background: #393043; overflow: hidden; }
.meter span { display: block; height: 100%; border-radius: 8px; }

.ledger { overflow: hidden; }
.filters { display: flex; align-items: flex-end; gap: 8px; flex-wrap: wrap; padding: 13px; border-bottom: 1px solid var(--line-subtle); }
.filters label, .edit-form label { display: grid; gap: 4px; color: var(--muted); font-size: 11px; font-weight: 550; }
.filters select, .edit-form :is(select, input, textarea) { padding: 6px 8px; min-height: 35px; min-width: 0; color: var(--ink); }
.filters .export { margin-inline-start: auto; }
.table-scroll { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; text-align: left; }
th { font-size: 11px; font-weight: 580; color: var(--quiet); white-space: nowrap; background: #251e2f; }
td { font-size: 13px; }
td, th { padding: 10px 13px; border-bottom: 1px solid var(--line-subtle); }
td:last-child { text-align: right; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #282134; }
.table-link { border: 0; background: transparent; color: var(--ink); padding: 3px 0; text-align: left; font-weight: 600; }
.table-link:hover { color: var(--violet); text-decoration: underline; }
.event-status.pending { color: var(--warning); border-color: #796344; background: #362b25; }
.event-status.open { color: var(--violet); background: #352647; border-color: #6a527e; }
.event-status.resolved, .event-status.ok { color: var(--sage); background: #273022; border-color: #576845; }
.event-status.dismissed { color: var(--quiet); }
.material-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.material { padding: 18px; }
.material h2 { margin: 13px 0 6px; }
.material p { margin-bottom: 14px; color: var(--muted); line-height: 1.5; }
.empty { display: grid; justify-items: center; gap: 7px; padding: 36px 16px; text-align: center; color: var(--muted); }
.empty .icon { color: var(--purple); width: 23px; height: 23px; }
.empty h3 { color: var(--ink); }
.chart-empty { padding-block: 55px; }

dialog {
  width: min(480px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); padding: 0; overflow: auto;
  background: #211a2b; color: var(--ink); border: 1px solid #514363; border-radius: 14px; box-shadow: 0 18px 90px #080610bc;
}
dialog::backdrop { background: #09070dc8; }
.media-dialog { width: min(900px, calc(100vw - 24px)); }
.dialog-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 16px; border-bottom: 1px solid var(--line-subtle); }
.dialog-heading h2 { font-size: 23px; line-height: 1.16; }
.dialog-heading p { font-size: 12px; }
.dialog-body { padding: 16px; display: grid; gap: 12px; }
.dialog-body p { line-height: 1.5; }
.detail-status, .dialog-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.dialog-actions { justify-content: flex-end; }
.detail-status .muted { font-size: 12px; }
.edit-form textarea { resize: vertical; }
.stream-toolbar, .player-footer { display: flex; justify-content: space-between; align-items: center; padding: 9px 15px; gap: 10px; flex-wrap: wrap; }
.player-footer { font-size: 11px; }
.player { position: relative; aspect-ratio: 16 / 9; background: #0e0c12; }
.player :is(iframe, video, .annotated) { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.stream-message { position: absolute; top: 10%; left: 10%; right: 10%; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px; border-radius: 8px; background: #1c1727e8; color: var(--muted); }
.annotated { display: grid; place-items: center; color: var(--muted); }
.frame-wrap { position: relative; width: min(100%, calc(var(--aspect, 1.7778) * 56.25%)); aspect-ratio: var(--aspect, 1.7778); }
.frame-wrap img { display: block; width: 100%; height: 100%; object-fit: contain; }
.boxes, .boxes i { position: absolute; }
.boxes { inset: 0; }
.boxes i { border: 2px solid var(--sage); border-radius: 3px; }
.boxes .box-1 { border-color: var(--violet); }
.boxes .box-2 { border-color: var(--warning); }
.segmented { display: inline-flex; gap: 3px; padding: 3px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); }
.segmented button { border: 0; border-radius: 5px; padding: 5px 8px; background: transparent; color: var(--muted); font-size: 11px; font-weight: 610; }
.segmented button[aria-pressed="true"] { background: #3c2b51; color: var(--violet); }
.evidence { width: 100%; border-radius: 8px; }
.toast { position: fixed; z-index: 5; bottom: 16px; right: 16px; padding: 10px 14px; border-radius: 8px; background: #392c4a; color: var(--ink); border: 1px solid #614c76; box-shadow: 0 8px 25px #09070d9c; }

@media (max-width: 1060px) {
  .shell { grid-template-columns: 185px minmax(0, 1fr); }
  .sidebar { padding-inline: 10px; }
  .camera-grid { grid-template-columns: repeat(auto-fit, minmax(min(100%, 178px), 1fr)); }
  .metric { padding-inline: 10px; }
  .metric-icon { width: 25px; height: 25px; }
}
@media (max-width: 800px) {
  .shell { display: block; }
  .sidebar { position: static; height: auto; padding: 12px 14px 8px; border-right: 0; border-bottom: 1px solid var(--line); }
  .wordmark { margin: 0 0 10px; }
  .brand-symbol { width: 31px; height: 31px; }
  .navigation { flex-direction: row; gap: 2px; overflow-x: auto; padding-bottom: 2px; }
  .navigation a { padding: 6px 8px; font-size: 12px; white-space: nowrap; gap: 4px; }
  .navigation .icon { width: 15px; height: 15px; }
  .navigation a[aria-current]::after, .sidebar-footer { display: none; }
  .topbar { min-height: 49px; }
  main { padding-top: 22px; }
}
@media (max-width: 580px) {
  .page-heading { display: grid; gap: 12px; margin-bottom: 17px; }
  .heading-actions { justify-content: flex-start; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric { min-height: 93px; }
  .camera-grid, .analysis-grid, .material-grid { grid-template-columns: minmax(0, 1fr); }
  .camera-image { max-height: 220px; }
  .section-heading { align-items: flex-start; }
  .section-heading .select-field { min-width: 112px; }
  .section-heading .subtle { white-space: nowrap; }
  .filters .export { margin-inline-start: 0; }
  .stream-toolbar, .player-footer { padding-inline: 10px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition-duration: 0s !important; } }
