/* ---- Live Grid ---- */
    .live-grid {
      flex: 1;
      display: grid;
      gap: 2px;
      padding: 2px;
      overflow: auto;
      min-height: 0;
      align-content: stretch;
    }

    .stream-cell {
      position: relative;
      background: #000;
      display: flex;
      align-items: stretch;
      justify-content: stretch;
      overflow: hidden;
      border: 1px solid transparent;
      transition: border-color 0.2s;
      min-height: 0;
      min-width: 0;
    }

    .stream-cell-video {
      position: absolute;
      inset: 0;
      z-index: 1;
      display: flex;
      align-items: center;
      justify-content: center;
      background: #000;
      overflow: hidden;
    }

    .stream-cell.active-border {
      border-color: var(--accent);
    }

    .stream-cell img,
    .stream-cell-video img,
    .stream-cell video,
    .stream-cell-video video {
      width: 100%;
      height: 100%;
      object-fit: contain;
      object-position: center center;
      display: block;
      background: #000;
    }

    .stream-bottom-controls {
      position: absolute;
      bottom: 8px;
      right: 8px;
      z-index: 3;
      display: flex;
      align-items: center;
      gap: 6px;
    }

    .stream-lag {
      font-size: 11px;
      font-variant-numeric: tabular-nums;
      line-height: 1.4;
      padding: 1px 6px;
      border-radius: 4px;
      background: rgba(0, 0, 0, 0.55);
      color: #8ef58e;
      pointer-events: none;
      text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
    }

    .stream-lag.pending {
      opacity: 0.55;
    }

    .stream-quality,
    .stream-fps {
      min-width: 46px;
      text-align: center;
      font-variant-numeric: tabular-nums;
      padding: 2px 7px;
      font-size: 11px;
      font-weight: 600;
      letter-spacing: 0.04em;
      border: 1px solid rgba(255, 255, 255, 0.3);
      border-radius: 4px;
      background: rgba(0, 0, 0, 0.55);
      color: #ddd;
      cursor: pointer;
    }

    .stream-fps {
      min-width: 52px;
    }

    .stream-quality:hover,
    .stream-fps:hover {
      background: rgba(0, 0, 0, 0.75);
      color: #fff;
    }

    .stream-quality.hd,
    .stream-fps.hd {
      color: #fff;
      border-color: var(--accent, #4da3ff);
      background: var(--accent, #1f6feb);
    }

    .stream-lag.warn {
      color: #ffd166;
    }

    .stream-lag.bad {
      color: #ff6b6b;
    }

    .stream-live-status {
      position: absolute;
      top: 8px;
      left: 8px;
      z-index: 3;
      display: flex;
      align-items: center;
      gap: 6px;
      pointer-events: none;
    }

    .stream-live-label {
      display: none;
      font-size: 12px;
      color: #ff6b6b;
      text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
    }

    .stream-live-status.buffering .stream-live-label {
      display: inline;
    }

    .stream-live-dot {
      width: 10px;
      height: 10px;
      border-radius: 50%;
      flex-shrink: 0;
      box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.5);
    }

    .stream-live-status.live .stream-live-dot {
      background: #3ddc84;
    }

    .stream-live-status.buffering .stream-live-dot {
      background: #ff6b6b;
    }

    .stream-live-status.pending .stream-live-dot {
      background: #888;
      opacity: 0.7;
    }

    .stream-overlay {
      position: absolute;
      top: 8px;
      left: 10px;
      font-size: 12px;
      color: #ccc;
      text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
      pointer-events: none;
      z-index: 2;
    }

    /* HLS tiles: sit camera name below the buffering / live-status row */
    .stream-cell:has(.stream-live-status) .stream-overlay {
      top: 28px;
    }

    .playback-tile-btn {
      height: 24px;
      min-width: 40px;
      font-size: 11px;
      border: 1px solid var(--accent);
      color: var(--accent);
      background: rgba(0, 184, 148, 0.15);
      border-radius: 4px;
      cursor: pointer;
      padding: 0 8px;
    }

    .playback-tile-btn.stop {
      border-color: var(--danger);
      color: var(--danger);
      background: rgba(231, 76, 60, 0.15);
    }

    .stream-close {
      position: absolute;
      top: 6px;
      right: 8px;
      width: 22px;
      height: 22px;
      background: rgba(0, 0, 0, 0.5);
      border: none;
      border-radius: 4px;
      color: #ccc;
      font-size: 14px;
      cursor: pointer;
      display: flex;
      align-items: center;
      justify-content: center;
      z-index: 10;
      transition: background 0.15s;
    }

    .stream-close:hover {
      background: rgba(231, 76, 60, 0.6);
      color: #fff;
    }

    .empty-state {
      flex: 1;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      color: var(--text-dim);
      gap: 12px;
      font-size: 14px;
    }

    .empty-icon {
      font-size: 48px;
      opacity: 0.3;
    }
