/* ============================================================
   Monitor — a8n.bolder.1 visual redesign
   Toolbar reorganized into grouped clusters (view controls vs. debug
   layers) instead of one flat row of chips; camera tiles rebuilt as
   operational cards with a real status badge, icon-only fullscreen
   action, and debug output moved behind a native <details> disclosure.
   ============================================================ */

.monitor-toolbar {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  flex-wrap: wrap;
}

.toolbar-select {
  min-height: 32px;
  padding: 0 10px;
  border: 0;
  border-radius: calc(var(--r-sm) - 3px);
  background: transparent;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.toolbar-select:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.monitor-layers {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
}

.monitor-layer {
  border: 0;
  border-radius: calc(var(--r-sm) - 3px);
  padding: 6px 11px;
  background: transparent;
  color: var(--text-2);
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
  transition: background .12s ease, color .12s ease;
}

.monitor-layer:hover {
  color: var(--text);
}

.monitor-layer:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.monitor-layer.is-active {
  background: var(--surface);
  color: var(--accent);
  box-shadow: 0 1px 2px rgba(0, 0, 0, .25);
}

/* The debug layer is a secondary/advanced toggle, not a peer of
   Транспорт/Номера/Зоны/Линия — visually recessive until active. */
.monitor-layer[data-layer-toggle="debug"] {
  color: var(--muted);
  font-style: italic;
}

.monitor-layer[data-layer-toggle="debug"].is-active {
  color: var(--amber);
  font-style: normal;
}

.monitor-grid {
  display: grid;
  gap: var(--sp-5);
}

.monitor-grid[data-layout="1"] {
  grid-template-columns: 1fr;
}

.monitor-grid[data-layout="4"] {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.monitor-grid[data-layout="9"] {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

/* ---------- Camera panel ---------- */

.cam-panel {
  min-height: 280px;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--panel-shadow);
  overflow: hidden;
}

.cam-panel__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  background: var(--panel-bg-strong);
  border-bottom: 1px solid var(--border);
}

.cam-panel__identity {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-width: 0;
}

.cam-status-dot {
  flex-shrink: 0;
  width: 9px;
  height: 9px;
  margin-top: 6px;
  border-radius: 50%;
  background: var(--muted);
}

.cam-status-dot.is-online {
  background: var(--green);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--green) 22%, transparent);
  animation: alprPulse 2.4s infinite;
}

.cam-status-dot.is-offline {
  background: var(--red);
}

.cam-panel__identity-text {
  min-width: 0;
}

.cam-panel__name {
  margin: 0 0 6px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.005em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cam-panel__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.cam-panel__expand {
  flex-shrink: 0;
}

.cam-panel__note {
  padding: 7px var(--sp-4);
  border-bottom: 1px solid var(--border);
  background: var(--accent-soft);
  color: var(--accent-2);
  font-size: 11.5px;
  font-weight: 600;
}

.cam-panel__stage {
  position: relative;
  overflow: hidden;
  aspect-ratio: 16 / 9;
  background: #080b11;
}

.live-media {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.live-media-wrap {
  position: relative;
  width: 100%;
  height: 100%;
}

.live-media--iframe {
  border: 0;
  background: #080b11;
}

.live-media-shield {
  position: absolute;
  inset: 0;
  z-index: 1;
  cursor: default;
}

.cam-overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}

.cam-overlay .cam-bbox {
  z-index: 4;
}

.cam-overlay .cam-bbox--plate {
  z-index: 5;
}

.cam-zone,
.cam-direction {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.cam-zone {
  z-index: 1;
}

.cam-zone polygon {
  fill: rgba(245, 158, 11, .08);
  stroke: rgba(245, 158, 11, .88);
  stroke-width: .005;
  stroke-dasharray: .02 .016;
  vector-effect: non-scaling-stroke;
}

.cam-zone--vehicle polygon {
  fill: rgba(34, 197, 94, .10);
  stroke: rgba(34, 197, 94, .95);
}

.cam-zone--exclusion polygon {
  fill: rgba(245, 158, 11, .10);
  stroke: rgba(156, 163, 175, .95);
}

.cam-geometry-legend {
  position: absolute;
  right: 10px;
  bottom: 10px;
  z-index: 6;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  max-width: calc(100% - 20px);
  font-size: 10px;
  font-weight: 700;
}

.cam-geometry-legend span { padding: 3px 6px; border-radius: 5px; background: rgba(3, 9, 22, .78); }
.cam-geometry-legend__roi { color: #4ade80; }
.cam-geometry-legend__ignore { color: #fbbf24; }

.cam-zone__label {
  position: absolute;
  left: 12px;
  top: 12px;
  z-index: 3;
  padding: 4px 7px;
  border-radius: 8px;
  background: rgba(245, 158, 11, .85);
  color: #130b02;
  font-size: 11px;
  font-weight: 800;
}

.cam-direction {
  z-index: 3;
}

.cam-direction polyline {
  fill: none;
  stroke: rgba(96, 165, 250, .96);
  stroke-width: .006;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
}

.cam-panel__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: var(--sp-3) var(--sp-4);
}

.cam-panel__debug {
  border-top: 1px solid var(--border-2);
}

.cam-panel__debug > summary {
  list-style: none;
  cursor: pointer;
  padding: 9px var(--sp-4);
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.cam-panel__debug > summary::-webkit-details-marker {
  display: none;
}

.cam-panel__debug > summary::before {
  content: "▸ ";
}

.cam-panel__debug[open] > summary::before {
  content: "▾ ";
}

.cam-panel__debug > summary:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.live-debug__summary {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--r-xs);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 12px;
}

.live-debug__metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.live-debug__metrics span {
  padding: 4px 7px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 11px;
}

.live-debug__cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-3);
  margin-top: 10px;
}

.live-debug__cols strong {
  display: block;
  margin-bottom: 5px;
  color: var(--text);
  font-size: 12px;
}

.live-debug__cols ul {
  display: grid;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-2);
}

.live-debug__timeline {
  display: grid;
  gap: 6px;
  padding: 10px var(--sp-4) var(--sp-3);
}

.live-debug__timeline strong {
  color: var(--text);
  font-size: 12px;
}

.live-debug__timeline ol {
  display: grid;
  gap: 5px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.live-debug__timeline li {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: var(--r-xs);
  background: var(--surface-2);
  font-size: 11.5px;
}

.live-debug__timeline small {
  color: var(--muted);
  font-family: var(--font-mono);
}

.live-tile.is-fullscreen {
  position: fixed;
  inset: 12px;
  z-index: 60;
  background: var(--bg);
}

.live-tile.is-fullscreen .cam-panel__stage {
  height: calc(100vh - 148px);
  aspect-ratio: auto;
}

@media (max-width: 900px) {
  .monitor-grid[data-layout="4"],
  .monitor-grid[data-layout="9"] {
    grid-template-columns: 1fr;
  }

  .live-debug__cols {
    grid-template-columns: 1fr;
  }

  .cam-bbox__tag,
  .cam-bbox__ocr {
    font-size: 10px;
  }
}

/* A8n.7.4.4.35b: stay management modal overlay */
.modal-overlay {
  position: fixed; inset: 0; z-index: 1100;
  background: rgba(5,9,16,0.65); backdrop-filter: blur(2px);
  display: flex; align-items: flex-start; justify-content: center;
  padding-top: 10vh; overflow-y: auto;
}
.modal-overlay .modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: var(--sp-6);
  width: 460px; max-width: 95vw; max-height: 80vh;
  overflow-y: auto; box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  display: flex; flex-direction: column; gap: var(--sp-4);
}
.modal-overlay .modal__head {
  display: flex; justify-content: space-between; align-items: center;
}
.modal-overlay .modal__head h3 { margin: 0; font-size: 16px; }
.modal-overlay .modal__body { display: flex; flex-direction: column; gap: 10px; }
.modal-overlay .modal__body label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.modal-overlay .modal__body input,
.modal-overlay .modal__body select,
.modal-overlay .modal__body textarea {
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--r-xs);
  padding: 8px 10px; font-size: 13px;
}
.modal-overlay .modal__foot {
  display: flex; flex-direction: column; gap: 8px;
}
.modal-overlay .modal__error { font-size: 12px; color: var(--red); }
.modal-overlay .exit-candidate {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px; border: 1px solid var(--border);
  border-radius: var(--r-xs); cursor: pointer; font-size: 12px;
}
.modal-overlay .exit-candidate:hover { border-color: var(--accent); }
.modal-overlay .exit-candidate.selected { border-color: var(--accent); background: var(--accent-soft); }
.modal-overlay .exit-candidate__time { font-weight: 600; min-width: 60px; }
.modal-overlay .exit-candidate__plate { font-family: var(--font-mono); }
.modal-overlay .exit-candidate__warn { color: var(--amber); font-size: 11px; }
