/* nvr-rs — styles (reprend les jetons des maquettes) */
:root {
  --bg: #0B0C0E; --panel: #111316; --surface: #141619; --surface-2: #1C1F23; --border: #262A30;
  --text: #ECEDEE; --muted: #A1A6AE; --faint: #6E747C;
  --person: #FFB224; --vehicle: #5B9CFF; --animal: #3DD68C; --live: #FF5A5A;
  --rec-main: #4A5361; --pin: #B78CFF; --motion: #59636F; --rec-sub: #2C333C;
  --mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  --sans: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 14px var(--sans); }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.spacer { flex: 1 1 auto; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }

.topbar { display: flex; align-items: center; gap: 16px; padding: 10px 16px; border-bottom: 1px solid var(--border); background: var(--panel); position: sticky; top: 0; z-index: 10; }
.brand { font-weight: 700; font-size: 17px; letter-spacing: -.01em; }
.pill { padding: 5px 10px; border: 1px solid var(--border); border-radius: 999px; font: 12px var(--mono); color: var(--muted); display: inline-flex; gap: 6px; align-items: center; }

.btn { min-height: 38px; padding: 0 12px; border: 0; border-radius: 9px; background: var(--surface-2); display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-weight: 500; white-space: nowrap; }
.btn:hover { background: var(--border); }
.btn.live { color: var(--live); }
.btn.live[aria-pressed="true"] { background: var(--live); color: #fff; }
.seg { display: flex; gap: 3px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 3px; }
.seg button { min-height: 32px; min-width: 40px; padding: 0 10px; border: 0; border-radius: 7px; background: transparent; color: var(--muted); font-size: 13px; }
.seg button[aria-pressed="true"] { background: var(--border); color: var(--text); }

/* Grille */
.grid { display: grid; gap: 8px; padding: 12px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 380px), 1fr)); }
.tile { position: relative; aspect-ratio: 16/9; background: #050607; border-radius: 10px; overflow: hidden; display: block; }
.tile canvas, .stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; display: block; }
.tile:hover { outline: 2px solid var(--border); }
.badge { position: absolute; background: rgba(0,0,0,.6); padding: 4px 8px; border-radius: 6px; font: 500 12px var(--sans); display: inline-flex; gap: 6px; align-items: center; }
.badge.mono { font: 500 11px var(--mono); color: #D5D8DD; }

/* Caméra */
.cam { display: flex; flex-direction: column; gap: 10px; padding: 12px; max-width: 1600px; margin: 0 auto; }
.stage { position: relative; aspect-ratio: 16/9; max-height: calc(100vh - 260px); width: 100%; background: #050607; border-radius: 12px; overflow: hidden; }
.stage .hud { position: absolute; top: 10px; left: 10px; right: 10px; display: flex; gap: 6px; flex-wrap: wrap; pointer-events: none; }
.stage .hud .badge { position: static; }
.stage .msg { position: absolute; inset: 0; display: none; align-items: center; justify-content: center; text-align: center; padding: 16px; color: var(--muted); background: rgba(5,6,7,.7); }
.stage .msg.on { display: flex; }
.controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.clock { font: 600 20px var(--mono); letter-spacing: -.02em; min-width: 9ch; }
.clock small { display: block; font: 500 11px var(--sans); color: var(--muted); letter-spacing: 0; }

.tlwrap { position: relative; background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 8px; }
#tl { display: block; width: 100%; height: 96px; touch-action: none; cursor: grab; border-radius: 6px; }
#tl.dragging { cursor: grabbing; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); }
.legend span { display: inline-flex; gap: 6px; align-items: center; }
.stats { font: 11px var(--mono); color: var(--faint); }

/* Événements */
.evsection { display: flex; flex-direction: column; gap: 8px; }
.evh { font-size: 15px; margin: 0; }
.evgrid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr)); }
.ev { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; display: flex; flex-direction: column; }
.ev.rejected { opacity: .45; }
.evimg { position: relative; display: block; padding: 0; border: 0; background: #050607; width: 100%; }
.evimg img { display: block; width: 100%; height: auto; }
.evbox { position: absolute; border: 2px solid; border-radius: 3px; pointer-events: none; }
.evnone { display: block; aspect-ratio: 16/9; color: var(--faint); font-size: 12px; padding: 12px; }
.evmeta { display: flex; align-items: center; gap: 8px; padding: 8px 10px; }
.evtext { display: flex; flex-direction: column; min-width: 0; flex: 1 1 auto; font-size: 13px; }
.evtext .mono { font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.verdict { display: flex; gap: 4px; }
.verdict button { width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--border); background: transparent; color: var(--muted); }
.verdict button[data-v="1"][aria-pressed="true"] { background: rgba(61,214,140,.18); border-color: #3DD68C; color: #3DD68C; }
.verdict button[data-v="-1"][aria-pressed="true"] { background: rgba(255,122,122,.18); border-color: #FF7A7A; color: #FF7A7A; }
.side { display: flex; flex-direction: column; gap: 10px; padding: 12px; }
.layout2 { display: grid; grid-template-columns: minmax(0, 1fr) 360px; align-items: start; }
@media (max-width: 1100px) { .layout2 { grid-template-columns: 1fr; } }

/* PTZ */
.ptzpanel { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; padding: 10px; background: var(--panel); border: 1px solid var(--border); border-radius: 12px; }
.ptzpanel[hidden] { display: none; }
.ptzpad { display: grid; grid-template-columns: repeat(3, 46px); gap: 5px; touch-action: none; user-select: none; }
.ptzpad button { height: 46px; border: 0; border-radius: 9px; background: var(--surface-2); font-size: 16px; }
.ptzpad button:active, .ptzpanel [data-op]:active { background: var(--border); }
.ptzcol { display: flex; flex-direction: column; gap: 8px; flex: 1 1 260px; }
.ptzpanel [data-op] { touch-action: none; user-select: none; }

/* Éditeur de zones */
#zoneSvg { position: absolute; cursor: crosshair; touch-action: none; }
#zoneSvg[hidden] { display: none; }
#zoneSvg polygon, #zoneSvg polyline { stroke-width: 3; vector-effect: non-scaling-stroke; }
#zoneSvg .zmask { fill: rgba(255,90,90,.28); stroke: #FF5A5A; }
#zoneSvg .zzone { fill: rgba(91,156,255,.22); stroke: #5B9CFF; }
#zoneSvg .zdraw { fill: none; stroke-dasharray: 6 4; }
#zoneSvg .zpt { fill: #fff; stroke: #000; stroke-width: 1; vector-effect: non-scaling-stroke; }
#zoneSvg .zpt.first { fill: #FFB224; }
.stage.editing { cursor: crosshair; }
.zonepanel { display: flex; flex-direction: column; gap: 8px; padding: 10px; border: 1px solid rgba(91,156,255,.45); background: rgba(91,156,255,.06); border-radius: 12px; }
.zonepanel[hidden] { display: none; }
.input { min-height: 38px; padding: 0 10px; border-radius: 9px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; min-width: 0; }
.zdel { background: none; border: 0; color: var(--muted); padding: 0 0 0 4px; }
.btn.primary { background: var(--text); color: var(--bg); font-weight: 600; }
#zonesBtn[aria-pressed="true"] { background: rgba(91,156,255,.2); color: #9CC2FF; }

.clippanel { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 8px 10px; border: 1px solid rgba(255,178,36,.45); background: rgba(255,178,36,.06); border-radius: 12px; }
.clippanel[hidden], #pinsRow[hidden] { display: none; }
#clipBtn[aria-pressed="true"] { background: rgba(255,178,36,.18); color: #FFCF73; }
.pinchip { padding: 0 4px 0 0; gap: 0; border-color: rgba(183,140,255,.45); }
.pinchip button { background: none; border: 0; color: var(--text); padding: 6px 8px; font: 12px var(--mono); }
.pinchip button[data-unpin] { color: var(--muted); padding: 6px; }
.stage { touch-action: none; user-select: none; }
.stage.zoomed { cursor: grab; }
.stage.panning { cursor: grabbing; }
.stage canvas { will-change: transform; }
.stage .fsbar { position: absolute; left: 10px; right: 10px; bottom: 10px; display: flex; gap: 6px; align-items: center; pointer-events: none; }
.stage .fsbar > * { pointer-events: auto; }
.stage .fsbar .btn { background: rgba(0,0,0,.55); min-height: 36px; min-width: 40px; }
.stage .fsbar .btn:hover { background: rgba(0,0,0,.8); }
.stage .fsclock { position: static; display: none; }
.stage:fullscreen { max-height: none; aspect-ratio: auto; border-radius: 0; width: 100vw; height: 100vh; }
.stage:fullscreen .fsclock { display: inline-flex; font-size: 13px; }

@media (max-width: 640px) {
  .cam { padding: 8px; }
  .clock { font-size: 17px; }
  .stage { max-height: none; }
}
