:root {
  color-scheme: dark;
  --bg: #15131a;
  --sidebar: #19161f;
  --surface: #201c28;
  --raised: #2b2435;
  --line: #393141;
  --text: #f5eff4;
  --muted: #bcb1c4;
  --purple: #c8b0f7;
  --green: #c5dba8;
  --amber: #e2c6a5;
  --radius: 15px;
  font-family: Inter, "Segoe UI", sans-serif;
  font-size: 16px;
  font-synthesis: none;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; color: var(--text); background: var(--bg); }
button, input, select { font: inherit; }
button, select, a { -webkit-tap-highlight-color: transparent; }
button, select { cursor: pointer; }
button:disabled { cursor: default; opacity: .55; }
button { color: inherit; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--purple); outline-offset: 3px; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(30px, 3.2vw, 48px); letter-spacing: -.045em; line-height: 1.08; font-weight: 720; }
h2 { font-size: 19px; line-height: 1.25; letter-spacing: -.025em; }
h3 { font-size: 16px; line-height: 1.3; }
.muted { color: var(--muted); }
.compact { font-size: .83rem; line-height: 1.45; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.top {
  height: 67px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 0 27px;
  border-bottom: 1px solid var(--line);
  background: #19161e;
}
.brand { display: inline-flex; gap: 10px; align-items: center; text-decoration: none; font-weight: 800; letter-spacing: .045em; font-size: 21px; }
.brand-mark {
  background: var(--green);
  color: #292538;
  width: 27px;
  height: 27px;
  border-radius: 7px;
  position: relative;
}
.brand-mark::before, .brand-mark::after { content: ""; position: absolute; top: 6px; width: 3px; height: 15px; background: currentColor; transform: skewX(-18deg); border-radius: 1px; }
.brand-mark::before { left: 9px; }
.brand-mark::after { right: 9px; }
.brand-name { margin-left: 8px; border-left: 1px solid var(--line); padding-left: 14px; font-size: .82rem; font-weight: 500; letter-spacing: 0; color: var(--muted); }
.top-actions { display: flex; align-items: center; gap: 12px; }
.tag { display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 4px 9px; border-radius: 6px; background: #2e2736; color: #ded3e2; font-size: .73rem; line-height: 1.35; font-weight: 620; white-space: nowrap; }
.tag i, .status-dot { display: inline-block; border-radius: 50%; width: 7px; height: 7px; flex: 0 0 7px; background: currentColor; }
.demo-tag, .history-tag { color: var(--purple); background: #372b47; }
.record-tag { color: var(--green); background: #263128; }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 9px 13px; border: 1px solid transparent; border-radius: 8px; min-height: 38px; font-size: .84rem; line-height: 1.1; font-weight: 660; text-decoration: none; white-space: nowrap; }
.button.secondary { background: #2b2533; border-color: #44394d; }
.button.secondary:hover { background: #3b3046; }
.button.action { background: var(--green); color: #20261a; }
.button.action:hover { background: #d9edc4; }
.button span { font-size: .8em; }
.error, .loading { max-width: 720px; margin: 26px auto; padding: 16px 20px; color: var(--muted); }
.error { display: flex; align-items: center; justify-content: space-between; gap: 16px; border: 1px solid #695043; border-radius: 8px; color: var(--amber); }

.owner-shell { display: grid; grid-template-columns: 210px minmax(0, 1fr); min-height: calc(100vh - 67px); }
.sidebar { padding: 26px 15px; border-right: 1px solid var(--line); background: var(--sidebar); }
.owner-nav { display: grid; gap: 5px; }
.owner-nav button {
  display: flex; gap: 12px; align-items: center; text-align: left; padding: 10px 12px;
  min-height: 43px; background: transparent; color: var(--muted); border: 1px solid transparent; border-radius: 8px;
  font-size: .85rem; font-weight: 650;
}
.owner-nav button:hover { background: #27212f; color: var(--text); }
.owner-nav [aria-pressed="true"] { color: #e9dbfa; background: #31263e; border-color: #463657; }
.nav-icon { width: 15px; height: 15px; border: 1.5px solid currentColor; border-radius: 3px; display: inline-block; position: relative; opacity: .88; }
.grid-icon::before, .grid-icon::after { content: ""; position: absolute; inset: 0 5px; background: currentColor; }
.grid-icon::after { inset: 5px 0; }
.frame-icon { height: 11px; }
.frame-icon::after { content: ""; position: absolute; width: 4px; height: 4px; background: currentColor; border-radius: 50%; inset: 2px 4px; }
.list-icon::after { content: ""; position: absolute; inset: 4px 2px auto; border-top: 1px solid currentColor; box-shadow: 0 3px currentColor; }
.owner-main { width: min(100%, 1660px); min-width: 0; padding: 28px clamp(18px, 3vw, 44px) 22px; }
.page-title { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin-bottom: 17px; }
.eyebrow { margin-bottom: 8px; color: var(--muted); font-size: .77rem; font-weight: 650; }
.context-line { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 13px; color: var(--muted); font-size: .82rem; }
.timecode { font-variant-numeric: tabular-nums; letter-spacing: .04em; font-size: .8rem; }
.context-line .timecode { margin-left: auto; }
.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { padding: 14px 17px 13px; min-width: 0; border: 1px solid var(--line); background: #211d29; border-radius: 12px; }
.stat:first-child { border-color: #414b39; background: linear-gradient(110deg, #252c26, #23242a); }
.stat-label { display: flex; align-items: center; gap: 7px; font-size: .79rem; color: var(--muted); }
.stat-value { display: block; margin: 4px 0 0; font-size: clamp(24px, 3.2vw, 39px); font-weight: 730; letter-spacing: -.04em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.free { color: var(--green); }
.busy { color: var(--purple); }
.unknown { color: var(--amber); }
.overview-grid { display: grid; grid-template-columns: minmax(0, 1.9fr) minmax(265px, 1fr); align-items: start; gap: 14px; }
.side-cards { display: grid; gap: 14px; min-width: 0; }
.card { min-width: 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); padding: 19px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 6px; }
.heat-scroll { overflow-x: auto; padding: 4px 4px 5px; margin: 11px -4px 0; }
.heatmap { display: grid; min-width: 414px; grid-template-columns: 29px repeat(16, minmax(18px, 1fr)); gap: 4px; }
.axis, .week-label { color: var(--muted); font-size: .71rem; font-variant-numeric: tabular-nums; align-self: center; }
.axis { text-align: center; }
.heat-cell { --intensity: 0%; background: color-mix(in srgb, #8752cc var(--intensity), #302940); color: var(--text); border: 1px solid #ffffff18; border-radius: 5px; height: clamp(23px, 2.3vw, 31px); padding: 0; min-width: 0; font-size: clamp(8px, .75vw, 10px); font-weight: 660; font-variant-numeric: tabular-nums; }
.heat-cell:hover { border-color: #ffe7fc; }
.heat-cell[aria-pressed="true"] { outline: 2px solid #e9d5ff; outline-offset: 0; border-color: #e9d5ff; }
.chart-legend { margin-top: 9px; display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: .72rem; }
.heat-scale { width: 64px; height: 6px; border-radius: 4px; background: linear-gradient(90deg, #322a41, #8a54ce); }
.legend-note { margin-left: auto; text-align: right; }
.divider { margin: 15px 0; height: 1px; background: var(--line); }
.bar-chart { display: grid; grid-template-columns: repeat(16, minmax(0, 1fr)); align-items: end; gap: 4px; margin-top: 12px; }
.bar-button { display: grid; grid-template-rows: 82px auto; gap: 4px; min-width: 0; padding: 0; border: 0; background: transparent; color: var(--muted); }
.bar-track { display: flex; align-items: end; background: #30283b; border: 1px solid transparent; border-radius: 4px; overflow: hidden; }
.bar-fill { display: block; width: 100%; height: var(--value); background: #8461b0; border-radius: 3px 3px 0 0; }
.bar-button:hover .bar-track, .bar-button[aria-pressed="true"] .bar-track { border-color: var(--purple); }
.bar-button[aria-pressed="true"] .bar-fill { background: var(--purple); }
.bar-label { position: relative; font-size: .68rem; line-height: 1.3; font-variant-numeric: tabular-nums; }
.bar-button[aria-pressed="true"] .bar-label { color: var(--text); }
.bar-button:nth-child(2n) .bar-label { color: transparent; }
.slot-metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 14px 0; }
.slot-metrics strong { display: block; margin-bottom: 1px; font-size: clamp(18px, 2.25vw, 28px); line-height: 1.15; font-variant-numeric: tabular-nums; letter-spacing: -.045em; }
.slot-metrics span { font-size: .72rem; color: var(--muted); }
.group-list { display: grid; gap: 11px; border-top: 1px solid var(--line); padding-top: 12px; }
.group-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 8px; font-size: .8rem; }
.group-row strong { color: var(--purple); font-variant-numeric: tabular-nums; }
.group-bar { display: block; height: 4px; border-radius: 4px; background: #372e43; overflow: hidden; }
.group-row .group-bar { grid-column: 1 / -1; }
.group-bar i { display: block; height: 100%; width: var(--value); background: #b093db; border-radius: inherit; }
.text-button { margin-top: 13px; padding: 4px 0; border: 0; color: var(--purple); text-align: left; background: transparent; font-size: .81rem; font-weight: 650; }
.text-button:hover { text-decoration: underline; }
.preview {
  display: flex; place-content: center; align-items: center; width: 100%; aspect-ratio: 16 / 7;
  margin: 10px 0; border: 1px solid #55445c; border-radius: 9px; padding: 0; overflow: hidden;
  background: linear-gradient(0deg, #281f31bb, #1b1e2370), var(--poster, none) center 49% / cover, #272332;
}
.preview span { display: grid; place-content: center; color: #211929; background: var(--text); padding-left: 2px; width: 39px; height: 39px; border-radius: 50%; font-size: .82rem; }
.preview:hover span { background: var(--purple); }
.footer { margin-top: 22px; color: var(--muted); font-size: .72rem; }
.footer a { text-underline-offset: 3px; }

.segmented { display: inline-flex; gap: 3px; padding: 3px; border: 1px solid var(--line); background: #1b1722; border-radius: 9px; }
.segmented button { padding: 7px 12px; min-height: 35px; border-radius: 6px; border: 1px solid transparent; background: transparent; color: var(--muted); font-size: .83rem; font-weight: 650; white-space: nowrap; }
.segmented button:hover { color: var(--text); }
.segmented [aria-pressed="true"] { color: #f1e6fb; background: #382c47; border-color: #4c3b5e; }
.camera-grid { display: grid; grid-template-columns: minmax(0, 1.98fr) minmax(250px, 1fr); gap: 15px; align-items: start; margin-top: 15px; }
.stage { position: relative; overflow: hidden; border-radius: 9px; margin-top: 12px; aspect-ratio: 16 / 9; background: #0f0b14; }
.stage video, .stage svg { display: block; width: 100%; height: 100%; }
.stage svg { position: absolute; inset: 0; pointer-events: none; }
.shape polygon { fill: currentColor; fill-opacity: .18; stroke: currentColor; stroke-width: 2; }
.shape circle { fill: currentColor; stroke: #261e30; stroke-width: 1; }
.shape rect { fill: #211a28; stroke: currentColor; stroke-width: 1; }
.shape text { fill: currentColor; font-size: 14px; font-weight: 740; text-anchor: middle; dominant-baseline: central; }
.stage .dim { opacity: .27; }
.stage .focused polygon { stroke-width: 4; fill-opacity: .29; }
.video-controls { display: flex; gap: 12px; align-items: center; margin-top: 11px; }
.video-controls input { flex: 1; min-width: 0; accent-color: var(--purple); }
.video-controls .timecode { min-width: 84px; text-align: right; }
.zone-list { display: grid; gap: 4px; margin-top: 10px; }
.zone-row { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; align-items: center; text-align: left; gap: 8px; width: 100%; min-height: 41px; padding: 7px; background: #282230; border: 1px solid #393043; border-radius: 7px; font-size: .83rem; }
.zone-row:hover, .zone-row[aria-pressed="true"] { background: #3a2d46; border-color: #766084; }
.zone-nr { color: var(--muted); font-size: .75rem; letter-spacing: .025em; font-variant-numeric: tabular-nums; }
.zone-name { overflow-wrap: anywhere; }
.zone-name small { display: block; margin-top: 2px; font-size: .72rem; color: var(--muted); }
.zone-state { display: inline-flex; align-items: center; gap: 5px; font-size: .72rem; white-space: nowrap; }
.filters { display: flex; gap: 11px; flex-wrap: wrap; margin: 12px 0; align-items: end; }
.filters label { display: grid; gap: 4px; font-size: .78rem; color: var(--muted); }
.filters .sr-only { display: block; }
select, input[type="search"] { min-height: 38px; max-width: 100%; padding: 7px 10px; border: 1px solid #493d54; border-radius: 7px; background: #282230; color: var(--text); font-size: .85rem; }
input::placeholder { color: var(--muted); }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; font-size: .86rem; }
th, td { padding: 10px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-size: .78rem; font-weight: 660; }
td .zone-nr { margin-right: 6px; }
td .group-bar { margin-top: 4px; min-width: 46px; max-width: 105px; }
.empty { padding: 10px 0; color: var(--muted); font-size: .85rem; }

.visitor { width: min(100%, 675px); margin: auto; padding: 29px 17px 35px; }
.visitor .page-title { margin-bottom: 14px; }
.visit-tabs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); margin-bottom: 12px; }
.visitor .stat-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; margin: 11px 0; }
.visitor .stat { padding: 9px 7px 10px; }
.visitor .stat-label { font-size: .74rem; }
.visitor .stat-value { font-size: 30px; }
.visitor-replay { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.visit-zones { margin-top: 12px; }
.visit-filters { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 7px; }
.visit-filters :is(input, select) { min-width: 0; }
.visit-history .bar-button { grid-template-rows: 118px auto; }
.visit-history .bar-fill { background: #a6ba95; }
.visit-history [aria-pressed="true"] .bar-fill { background: var(--green); }
.visit-history .estimate .bar-fill { background: repeating-linear-gradient(135deg, #7b629d, #7b629d 3px, #655180 3px, #655180 6px); }
.station-select, .station-select select { width: 100%; }
.weekday-tabs { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.weekday-tabs button { padding-inline: 3px; }
.visit-legend { justify-content: space-between; gap: 8px; }
#estimate-legend { display: inline-flex; align-items: center; gap: 5px; }
#estimate-legend i { width: 11px; height: 10px; border-radius: 2px; background: repeating-linear-gradient(135deg, #7b629d, #7b629d 2px, #655180 2px, #655180 4px); }

@media (max-width: 1130px) {
  .owner-shell { grid-template-columns: 170px minmax(0, 1fr); }
  .overview-grid { grid-template-columns: minmax(0, 1.5fr) minmax(220px, 1fr); }
  .card { padding: 15px; }
}
@media (max-width: 940px) {
  .owner-shell { display: block; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--line); padding: 8px 15px; }
  .owner-nav { display: flex; }
  .owner-nav button { min-height: 37px; }
}
@media (max-width: 730px) {
  .overview-grid, .camera-grid { grid-template-columns: minmax(0, 1fr); }
  .side-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .top { height: 56px; padding: 0 14px; }
  .brand-name { display: none; }
  .owner-main, .visitor { padding-top: 18px; }
}
@media (max-width: 520px) {
  .top-actions { gap: 6px; }
  .owner-main { padding-inline: 12px; }
  .owner-nav button { gap: 7px; padding: 7px; font-size: .8rem; }
  .owner-main .page-title { flex-wrap: wrap; align-items: start; gap: 10px; }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
  .side-cards { grid-template-columns: minmax(0, 1fr); }
  .card { padding: 13px; border-radius: 11px; }
  .bar-chart { gap: 3px; }
  .visitor { padding-inline: 11px; }
  .zone-row { gap: 6px; }
  .segmented button { padding-inline: 7px; }
}
