.video-page {
  max-width: 1300px;
  margin: 0 auto;
  padding-bottom: 35px;
}

.video-heading,
.video-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.video-heading {
  margin-bottom: 26px;
}

.video-heading h1 {
  margin: 0 0 6px;
  font-size: 26px;
}

.video-heading p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.video-count {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.video-toolbar {
  margin-bottom: 20px;
}

.video-layout-switch {
  display: inline-flex;
  padding: 4px;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}

.video-layout-switch button {
  width: 40px;
  height: 35px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.video-layout-switch button.active {
  background: #0088ff;
  color: white;
}

.video-add-btn {
  padding: 12px 18px;
  border: 0;
  border-radius: 11px;
  background: #0088ff;
  color: white;
  font: inherit;
  font-size: 12px;
  font-weight: 650;
  cursor: pointer;
}

.video-grid {
  display: grid;
  gap: 16px;
}

.video-grid.cols-1 {
  grid-template-columns: 1fr;
}

.video-grid.cols-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.video-grid.cols-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.camera-card {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
}

.camera-screen {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #141b23;
  color: #a7b0bc;
}

.camera-state {
  position: absolute;
  top: 14px;
  left: 14px;
  padding: 6px 10px;
  border-radius: 7px;
  background: #28313c;
  color: #bec7d1;
  font-size: 10px;
}

.camera-screen-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 12px;
}

.camera-screen-icon {
  font-size: 35px;
  opacity: 0.4;
}

.camera-expand {
  position: absolute;
  right: 12px;
  bottom: 12px;
  padding: 7px 10px;
  border: 1px solid #475463;
  border-radius: 8px;
  background: #26303b;
  color: white;
  font-size: 11px;
  cursor: pointer;
}

.camera-details {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 16px;
}

.camera-details strong,
.camera-details small {
  display: block;
}

.camera-details strong {
  font-size: 13px;
  margin-bottom: 5px;
}

.camera-details small {
  color: var(--muted);
  font-size: 11px;
}

.camera-actions {
  display: flex;
  gap: 5px;
}

.camera-actions button {
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface-soft);
  color: var(--text);
  cursor: pointer;
}

.video-empty {
  grid-column: 1 / -1;
  padding: 65px 20px;
  text-align: center;
  background: var(--surface);
  border: 1px dashed var(--line);
  border-radius: 16px;
}

.video-empty-symbol {
  font-size: 48px;
  color: var(--muted);
}

.video-empty h2 {
  font-size: 18px;
}

.video-empty p {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 20px;
}

.video-camera-form {
  display: grid;
  gap: 12px;
  margin-bottom: 20px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
}

.video-camera-form h3 {
  margin: 0;
  font-size: 16px;
}

.video-camera-form input {
  width: 100%;
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

.video-camera-form > div {
  display: flex;
  gap: 10px;
}

.video-dialog {
  width: min(950px, 95vw);
  max-width: none;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  color: var(--text);
  overflow: hidden;
}

.video-dialog::backdrop {
  background: rgba(0, 0, 0, 0.75);
}

.video-dialog-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
}

.video-dialog-bar button {
  border: 0;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}

.video-dialog-screen {
  display: grid;
  place-items: center;
  aspect-ratio: 16 / 9;
  background: #141b23;
  color: #a7b0bc;
  font-size: 13px;
}

@media (max-width: 700px) {
  .video-heading {
    align-items: flex-start;
  }

  .video-grid.cols-2,
  .video-grid.cols-3 {
    grid-template-columns: 1fr;
  }

  .video-heading h1 {
    font-size: 23px;
  }

  .video-count {
    font-size: 10px;
  }
}

/* Camera action buttons */
.camera-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.camera-actions button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-soft);
  color: var(--muted);
  cursor: pointer;
  transition:
    background 0.18s ease,
    color 0.18s ease;
}

.camera-actions button:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.camera-actions button[data-camera-delete]:hover {
  color: #e45465;
}

.camera-actions button svg,
.camera-actions button img {
  width: 17px;
  height: 17px;
}

.video-edit-dialog {
  width: min(440px, calc(100vw - 32px));
  max-width: none;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  color: var(--text);
}

.video-edit-dialog::backdrop {
  background: rgba(10, 17, 27, 0.55);
}

.video-edit-form {
  display: grid;
  gap: 12px;
  padding: 26px;
}

.video-edit-form h2 {
  margin: 0 0 10px;
  font-size: 20px;
}

.video-edit-form label {
  font-size: 12px;
  font-weight: 600;
}

.video-edit-form input {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

.video-edit-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 12px;
}

.video-edit-actions button {
  min-height: 40px;
  padding: 10px 16px;
  border-radius: 10px;
  cursor: pointer;
}

.video-edit-actions .video-delete-btn {
  background: #dc4055;
  border: 1px solid #dc4055;
  color: #fff;
}

.video-edit-actions .video-delete-btn:hover {
  background: #c42f44;
}

/* Add camera modal */
.video-edit-dialog .video-camera-form {
  margin: 0;
  padding: 26px;
  border: 0;
  border-radius: 18px;
  box-shadow: none;
}

.video-edit-dialog .video-camera-form > div {
  justify-content: flex-end;
  margin-top: 10px;
}

.video-edit-dialog #camera-cancel {
  min-height: 40px;
  padding: 10px 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-soft);
  color: var(--text);
  cursor: pointer;
}

/* Camera preview */
.camera-screen {
  background: radial-gradient(circle at 50% 45%, #253442 0%, #141c26 55%, #0e151d 100%);
  overflow: hidden;
}

.camera-screen-center {
  text-align: center;
  gap: 12px;
  color: #a3b1c1;
}

.camera-screen-center::before {
  content: '';
  display: block;
  width: 38px;
  height: 38px;
  background: currentColor;
  opacity: 0.35;
  mask: url('/icons/ui/regular/Видеокамера.svg') center / contain no-repeat;
  -webkit-mask: url('/icons/ui/regular/Видеокамера.svg') center / contain no-repeat;
}

/* Polished camera cards */
.camera-card {
  transition:
    border-color 0.18s ease,
    box-shadow 0.18s ease;
}

.camera-card:hover {
  border-color: var(--muted);
}

.camera-state {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: rgba(25, 35, 47, 0.88);
  color: #b3bfcb;
  backdrop-filter: blur(8px);
}

.camera-state::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #8d9baa;
}

.camera-details {
  min-height: 76px;
  gap: 10px;
}

.camera-details > div:first-child {
  flex: 1;
  min-width: 0;
}

.camera-details strong,
.camera-details small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.camera-actions button {
  flex: 0 0 34px;
  transition:
    background 0.15s ease,
    color 0.15s ease;
}

.camera-actions button:focus-visible {
  outline: 2px solid var(--focus, #0088ff);
  outline-offset: 2px;
}

.camera-actions button[data-camera-delete]:hover {
  background: rgba(228, 84, 101, 0.1);
  color: #e45465;
}

@media (max-width: 600px) {
  .camera-details {
    padding: 13px;
  }

  .camera-actions {
    gap: 4px;
  }

  .camera-actions button {
    width: 32px;
    height: 32px;
    flex-basis: 32px;
  }
}

/* Local camera preview */
.camera-screen:has(.camera-live-frame) {
  padding: 0;
  position: relative;
}

.camera-live-frame {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 240px;
  border: 0;
  background: #10151c;
}

/* Camera connection form */
.video-edit-dialog .video-camera-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(440px, 90vw);
  box-sizing: border-box;
}

.video-edit-dialog .video-camera-form > input,
.video-edit-dialog .video-camera-form > select {
  width: 100%;
  box-sizing: border-box;
}

.video-source-fields:not([hidden]) {
  display: flex;
  flex-direction: column;
  gap: 9px;
  width: 100%;
}

.video-source-fields[hidden] {
  display: none !important;
}

.video-source-fields input {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.video-source-fields label {
  font-size: 12px;
  font-weight: 600;
}

.video-connection-note {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
}

#camera-connection-fields[hidden],
.video-browser-panel[hidden],
.video-browser-preview[hidden] {
  display: none !important;
}

/* Camera setup modal — layout fix */
.video-edit-dialog {
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
}

.video-edit-dialog .video-camera-form {
  width: min(440px, calc(100vw - 32px));
  max-width: 100%;
}

.video-edit-dialog .video-browser-panel:not([hidden]) {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  min-width: 0;
}

.video-edit-dialog .video-browser-preview {
  display: block;
  width: 100%;
  height: auto;
  max-height: 230px;
  aspect-ratio: 16 / 9;
  object-fit: contain;
  border-radius: 12px;
  background: #10151c;
}

.video-edit-dialog .video-preview-btn {
  width: 100%;
}

.video-edit-dialog #camera-connection-fields[hidden] {
  display: none !important;
}

.camera-live-video {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 220px;
  object-fit: cover;
  background: #10151c;
}

.camera-browser-start {
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface-soft);
  color: var(--text);
  cursor: pointer;
}

.camera-screen {
  position: relative;
}

.camera-live-stop {
  position: absolute;
  right: 12px;
  bottom: 12px;
  z-index: 2;
  padding: 8px 12px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  cursor: pointer;
}

.camera-remote-frame {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 220px;
  border: 0;
  background: #10151c;
}

.camera-screen-center:has([data-camera-remote]) {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.camera-remote-close {
  position: absolute;
  right: 12px;
  bottom: 12px;
  z-index: 3;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 9px;
  background: rgba(0, 0, 0, 0.75);
  color: #fff;
  padding: 8px 12px;
  cursor: pointer;
}

.camera-screen:has(.camera-remote-frame) {
  position: relative;
  overflow: hidden;
  background: #080d14;
}

.camera-remote-frame {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  aspect-ratio: 16 / 9;
  background: #080d14;
}

.camera-remote-video {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 220px;
  object-fit: contain;
  background: #080d14;
}

.camera-remote-play[hidden] {
  display: none !important;
}

.camera-remote-play {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 4;
  border: 0;
  border-radius: 10px;
  padding: 12px 18px;
  background: #0788ff;
  color: white;
  cursor: pointer;
}
