:root {
  --bg-main: #06090f;
  --bg-card: #0d121d;
  --bg-card-hover: #141c2c;
  --border-color: #1e293b;
  --border-focus: #38bdf8;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --primary: #0284c7;
  --primary-hover: #0369a1;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  overflow-x: hidden;
  max-width: 100vw;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg-main);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  max-width: 100vw;
}

/* Header */
.header {
  background-color: #0b111e;
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
}

.header-container {
  max-width: 1800px;
  margin: 0 auto;
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand-group {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-icon {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, #0284c7, #0369a1);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  box-shadow: 0 0 15px rgba(2, 132, 199, 0.4);
}

.brand-title {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(90deg, #38bdf8, #818cf8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 0.2s ease;
}

.nav-item:hover {
  color: #fff;
  background-color: rgba(255, 255, 255, 0.05);
}

.nav-item.active {
  color: #38bdf8;
  background-color: rgba(56, 189, 248, 0.1);
  border: 1px solid rgba(56, 189, 248, 0.2);
}

.live-pulse {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--danger);
  box-shadow: 0 0 8px var(--danger);
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0% { transform: scale(0.95); opacity: 0.8; }
  50% { transform: scale(1.3); opacity: 1; }
  100% { transform: scale(0.95); opacity: 0.8; }
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 500;
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s;
}

.btn-sm {
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
}

.btn-primary {
  background-color: var(--primary);
  color: #fff;
}
.btn-primary:hover { background-color: var(--primary-hover); }

.btn-secondary {
  background-color: #1e293b;
  color: #cbd5e1;
  border: 1px solid #334155;
}
.btn-secondary:hover { background-color: #334155; color: #fff; }

.btn-danger {
  background-color: rgba(239, 68, 68, 0.15);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.3);
}
.btn-danger:hover { background-color: rgba(239, 68, 68, 0.3); color: #fff; }

.btn-block { width: 100%; justify-content: center; }

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.6rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
}
.badge-info { background: rgba(56, 189, 248, 0.15); color: #38bdf8; border: 1px solid rgba(56, 189, 248, 0.3); }
.badge-success { background: rgba(16, 185, 129, 0.15); color: #34d399; border: 1px solid rgba(16, 185, 129, 0.3); }
.badge-secondary { background: #1e293b; color: #94a3b8; }
.badge-obj { background: rgba(245, 158, 11, 0.15); color: #fbbf24; border: 1px solid rgba(245, 158, 11, 0.3); font-size: 0.65rem; padding: 0.1rem 0.35rem; border-radius: 4px; font-weight: 600; }
.badge-motion { background: rgba(168, 85, 247, 0.15); color: #c084fc; border: 1px solid rgba(168, 85, 247, 0.3); font-size: 0.65rem; padding: 0.1rem 0.35rem; border-radius: 4px; font-weight: 600; }

/* Main Content Container */
.main-content {
  flex: 1;
  padding: 1.25rem;
}

.page-container {
  max-width: 1800px;
  margin: 0 auto;
}

/* Toolbar */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  background-color: var(--bg-card);
  padding: 0.75rem 1.25rem;
  border-radius: 8px;
  border: 1px solid var(--border-color);
}

.toolbar-left, .toolbar-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.section-title {
  font-size: 1.1rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.indicator-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--success);
  box-shadow: 0 0 8px var(--success);
}

.grid-selector {
  display: flex;
  background-color: #0b111e;
  padding: 2px;
  border-radius: 6px;
  border: 1px solid var(--border-color);
}

.grid-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 0.3rem 0.6rem;
  border-radius: 4px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.grid-btn.active, .grid-btn:hover {
  background-color: var(--primary);
  color: #fff;
}

/* Multi-Select Camera Pill Selector (Radio-style modern pills) */
.camera-pills-bar {
  margin-bottom: 1rem;
  width: 100%;
}

.camera-pills-field {
  grid-column: 1 / -1;
  width: 100%;
}

.camera-pill-selector {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  overflow-x: auto;
  padding: 0.35rem 0.2rem 0.6rem 0.2rem;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}

.camera-pill-selector::-webkit-scrollbar {
  height: 4px;
}
.camera-pill-selector::-webkit-scrollbar-thumb {
  background: #334155;
  border-radius: 4px;
}

.cam-radio-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.9rem;
  background: #111827;
  border: 1px solid #1f2937;
  border-radius: 9999px;
  color: #94a3b8;
  font-size: 0.825rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.cam-radio-pill:hover {
  border-color: #38bdf8;
  color: #f8fafc;
  background: #1e293b;
}

.cam-radio-pill .pill-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #475569;
  transition: all 0.2s;
  flex-shrink: 0;
}

.cam-radio-pill.active {
  background: linear-gradient(135deg, rgba(2, 132, 199, 0.25), rgba(14, 165, 233, 0.15));
  border-color: #0ea5e9;
  color: #38bdf8;
  font-weight: 600;
  box-shadow: 0 0 12px rgba(14, 165, 233, 0.3);
}

.cam-radio-pill.active .pill-dot {
  background: #38bdf8;
  box-shadow: 0 0 8px #38bdf8;
}

/* Camera Grid (16:9 Aspect Ratio) */
.camera-grid {
  display: grid;
  gap: 1rem;
}

.grid-3x3 { grid-template-columns: repeat(3, 1fr); }
.grid-2x2 { grid-template-columns: repeat(2, 1fr); }
.grid-1x1 { grid-template-columns: 1fr; }

@media (max-width: 1200px) {
  .grid-3x3 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 768px) {
  .grid-3x3, .grid-2x2 { grid-template-columns: 1fr; }
}

.camera-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  position: relative;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.camera-card:hover {
  border-color: #334155;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.camera-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.75rem;
  background-color: rgba(11, 17, 30, 0.85);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.camera-title-badge {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.status-indicator {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: var(--success);
}

.camera-name {
  font-size: 0.85rem;
  font-weight: 600;
}

.camera-loc {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.cam-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
}
.cam-btn:hover { color: #fff; }

/* 16:9 Viewport */
.video-viewport {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9; /* CRITICAL: Force 16:9 Aspect Ratio */
  background-color: #030712;
  overflow: hidden;
}

.surveillance-video {
  width: 100%;
  height: 100%;
  object-fit: fill !important; /* CRITICAL: Stretches anamorphic 960x1080 into proper 16:9 widescreen */
  display: block;
}

/* Live Card Hover Play Overlay (Disabled per user request for seamless touch/fullscreen) */
.live-play-overlay {
  display: none !important;
}

.video-loader {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  background-color: rgba(3, 7, 18, 0.8);
  font-size: 0.75rem;
  color: var(--text-muted);
  z-index: 10;
}

.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid rgba(255, 255, 255, 0.1);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.camera-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.35rem 0.75rem;
  background-color: #0b111e;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  color: #64748b;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

/* S3 Filter & Banner */
.filter-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 1.25rem;
  margin-bottom: 1rem;
}

.filter-form {
  display: grid;
  grid-template-columns: 1.5fr 1.5fr auto;
  gap: 1rem;
  align-items: end;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

@media (max-width: 900px) {
  .filter-form { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 600px) {
  .filter-form { grid-template-columns: 1fr; }
}

.form-field label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}

.form-select, .form-group input {
  width: 100%;
  background-color: #0b111e;
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 0.6rem 0.8rem;
  border-radius: 6px;
  font-size: 0.875rem;
  outline: none;
  transition: border-color 0.15s;
}

.form-select:focus, .form-group input:focus {
  border-color: var(--border-focus);
}

.s3-banner {
  background: linear-gradient(90deg, rgba(2, 132, 199, 0.1), rgba(15, 23, 42, 0.6));
  border: 1px solid rgba(56, 189, 248, 0.2);
  border-radius: 8px;
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.s3-banner-content {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.s3-banner-icon {
  color: #38bdf8;
}

.s3-banner h4 {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 0.2rem;
}

.s3-banner p {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.s3-banner code {
  background-color: rgba(0, 0, 0, 0.3);
  padding: 0.1rem 0.3rem;
  border-radius: 4px;
  color: #e2e8f0;
}

/* Results & Clips Grid */
.results-container {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 1.25rem;
}

.results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.results-title-group {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* View Mode Toggle (Video Utuh / Sesi vs Segmen 10s) */
.view-mode-toggle {
  display: flex;
  background-color: var(--bg-dark);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 2px;
  gap: 2px;
}

.view-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0.35rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  background: transparent;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.view-btn:hover {
  color: #fff;
}

.view-btn.active {
  background-color: #2563eb;
  color: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

/* Session Card Styling */
.session-card {
  border-left: 3px solid #38bdf8 !important;
}

.session-card.has-event {
  border-left: 3px solid #fbbf24 !important;
}

.clip-session-tag {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: rgba(56, 189, 248, 0.15);
  color: #38bdf8;
  font-size: 0.68rem;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  font-weight: 600;
}

/* Modal Playlist Controls */
.session-nav-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.auto-next-label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.75rem;
  color: #94a3b8;
  cursor: pointer;
  user-select: none;
  margin-left: 0.25rem;
}

.auto-next-label input {
  cursor: pointer;
  accent-color: #2563eb;
}

.empty-state, .loading-state {
  text-align: center;
  padding: 4rem 1rem;
  color: var(--text-muted);
}

.empty-state svg {
  margin-bottom: 1rem;
  opacity: 0.4;
}

.clips-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

.clip-card {
  background-color: #0b111e;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  transition: all 0.2s;
}

.clip-card:hover {
  border-color: #38bdf8;
  transform: translateY(-2px);
}

.clip-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75rem;
}

.clip-camera {
  font-weight: 600;
  color: #38bdf8;
}

.clip-time {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.9rem;
  font-weight: 600;
}

.clip-size {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.clip-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-top: 0.25rem;
}

.clip-btn-group {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.clip-date-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  font-weight: 500;
  color: #94a3b8;
  background-color: rgba(255, 255, 255, 0.05);
  padding: 0.2rem 0.45rem;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  margin-left: auto;
}

/* Frigate Camera Popover Dropdown */
.camera-popover-field {
  position: relative;
}

.camera-filter-wrapper {
  position: relative;
}

.camera-dropdown-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0.6rem 0.85rem;
  background-color: var(--bg-dark);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  color: #fff;
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.camera-dropdown-btn:hover {
  border-color: #38bdf8;
  background-color: #162032;
}

.btn-cam-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 500;
}

.chevron-icon {
  transition: transform 0.2s ease;
  color: var(--text-muted);
}

.camera-dropdown-btn.open .chevron-icon {
  transform: rotate(180deg);
}

.frigate-popover {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  width: 280px;
  max-width: 90vw;
  background-color: #0b111e;
  border: 1px solid #1e293b;
  border-radius: 10px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.7), 0 8px 10px -6px rgba(0, 0, 0, 0.7);
  z-index: 100;
  padding: 0.75rem;
  animation: fadeInPop 0.15s ease-out;
}

@keyframes fadeInPop {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

.popover-section-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  color: #64748b;
  letter-spacing: 0.05em;
  padding: 0.25rem 0.5rem 0.5rem;
  border-bottom: 1px solid #1e293b;
  margin-bottom: 0.4rem;
}

.camera-radio-list {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  max-height: 360px;
  overflow-y: auto;
}

.camera-radio-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.6rem;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s ease;
  user-select: none;
}

.camera-radio-item:hover {
  background-color: rgba(255, 255, 255, 0.06);
}

.camera-radio-item.active {
  background-color: rgba(56, 189, 248, 0.1);
}

.cam-item-label {
  font-size: 0.85rem;
  color: #e2e8f0;
  font-weight: 500;
}

.camera-radio-item.active .cam-item-label {
  color: #38bdf8;
  font-weight: 600;
}

/* iOS / Frigate Style Toggle Pill */
.toggle-pill {
  position: relative;
  width: 38px;
  height: 22px;
  background-color: #334155;
  border-radius: 9999px;
  transition: background-color 0.2s ease;
  flex-shrink: 0;
}

.toggle-pill.active {
  background-color: #2563eb;
}

.toggle-circle {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  background-color: #ffffff;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.toggle-pill.active .toggle-circle {
  transform: translateX(16px);
}

.popover-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 0.6rem;
  padding-top: 0.6rem;
  border-top: 1px solid #1e293b;
}

.btn-ghost {
  background: transparent;
  color: #94a3b8;
  border: 1px solid transparent;
  cursor: pointer;
  border-radius: 4px;
  padding: 0.35rem 0.75rem;
}

.btn-ghost:hover {
  color: #fff;
  background-color: rgba(255, 255, 255, 0.05);
}

/* Real Video Thumbnail & Badges */
.clip-thumbnail {
  position: relative;
  cursor: pointer;
  border-radius: 6px;
  overflow: hidden;
  background-color: #030712;
}

.clip-aspect-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.clip-preview-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
  background-color: #050811;
  transition: transform 0.3s ease, filter 0.2s ease;
}

.clip-card:hover .clip-preview-video {
  transform: scale(1.03);
}

.clip-play-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.25);
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
}

.clip-card:hover .clip-play-overlay {
  opacity: 1;
}

.clip-play-overlay svg {
  color: #38bdf8;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.8));
}

.clip-badges-top {
  position: absolute;
  top: 6px;
  left: 6px;
  right: 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  pointer-events: none;
  z-index: 2;
}

.clip-badges-bottom {
  position: absolute;
  bottom: 6px;
  left: 6px;
  right: 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  pointer-events: none;
  z-index: 2;
}

.clip-badge-time {
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  color: #f1f5f9;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.clip-badge-dur {
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  color: #94a3b8;
  font-size: 0.7rem;
  font-weight: 500;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
}

/* S3 Sync Status Badges */
.badge-sync {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  backdrop-filter: blur(4px);
  display: inline-flex;
  align-items: center;
  gap: 3px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

.badge-s3-synced {
  background-color: rgba(16, 185, 129, 0.85);
  color: #ffffff;
  border: 1px solid rgba(52, 211, 153, 0.6);
}

.badge-s3-pending {
  background-color: rgba(217, 119, 6, 0.85);
  color: #ffffff;
  border: 1px solid rgba(251, 191, 36, 0.6);
}

.badge-s3-missing {
  background-color: rgba(220, 38, 38, 0.85);
  color: #ffffff;
  border: 1px solid rgba(248, 113, 113, 0.6);
}

/* Modal Video Player */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-overlay {
  position: absolute;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
}

.modal-dialog {
  position: relative;
  width: 100%;
  max-width: 960px;
  background-color: #0b111e;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
  z-index: 10;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
}

.modal-title-group h3 {
  font-size: 1rem;
  font-weight: 600;
}

.modal-title-group p {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.modal-close-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
}
.modal-close-btn:hover { color: #fff; }

.modal-video-wrapper {
  aspect-ratio: 16 / 9;
  background-color: #000;
}

.modal-video {
  width: 100%;
  height: 100%;
  object-fit: fill !important; /* 16:9 stretch in playback */
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.25rem;
  border-top: 1px solid var(--border-color);
}

.playback-controls {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.speed-btn {
  background-color: #1e293b;
  border: 1px solid #334155;
  color: #cbd5e1;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  cursor: pointer;
}

.speed-btn.active {
  background-color: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* Login Page Styling */
.login-body {
  background-color: var(--bg-main);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.login-card {
  width: 100%;
  max-width: 400px;
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 2rem;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
}

.login-header {
  text-align: center;
  margin-bottom: 1.5rem;
}

.login-logo {
  width: 56px;
  height: 56px;
  margin: 0 auto 1rem;
  background: linear-gradient(135deg, #0284c7, #0369a1);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  box-shadow: 0 0 20px rgba(2, 132, 199, 0.5);
}

.login-header h2 {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 0.3rem;
}

.login-header p {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.login-form .form-group {
  margin-bottom: 1.2rem;
}

.login-form label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}

.alert-error {
  background-color: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #fca5a5;
  padding: 0.75rem;
  border-radius: 6px;
  font-size: 0.8rem;
  margin-bottom: 1rem;
}

.login-footer {
  text-align: center;
  margin-top: 1.5rem;
  font-size: 0.75rem;
  color: #64748b;
}

/* Footer */
.footer {
  border-top: 1px solid var(--border-color);
  padding: 1rem;
  text-align: center;
  font-size: 0.75rem;
  color: #64748b;
  background-color: #0b111e;
}

.footer-link {
  color: inherit;
  text-decoration: none;
  font-weight: 500;
  transition: color 0.15s ease, text-decoration 0.15s ease;
}

.footer-link:hover {
  color: #38bdf8;
  text-decoration: underline;
}

/* ========================================================= */
/* FRIGATE TRACKED OBJECTS & 2-COLUMN DETAILS MODAL STYLING  */
/* ========================================================= */

/* Primary Mode Switcher (Tracked Events vs 24/7 Archive) */
.mode-switch-group {
  display: flex;
  align-items: center;
  background-color: var(--bg-dark);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 3px;
  gap: 3px;
}

.mode-tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0.45rem 0.9rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  background: transparent;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.mode-tab-btn:hover {
  color: #fff;
}

.mode-tab-btn.active {
  background-color: #0284c7;
  color: #ffffff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}

/* Tracked Event Card */
.clip-card.event-card {
  border-left: 3px solid #38bdf8 !important;
  background-color: #0b111e;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.clip-card.event-card:hover {
  transform: translateY(-2px);
  border-color: #38bdf8;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

.event-thumb-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.clip-card.event-card:hover .event-thumb-img {
  transform: scale(1.04);
}

.badge-event-label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(2, 132, 199, 0.85);
  color: #ffffff;
  font-weight: 700;
  font-size: 0.72rem;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  backdrop-filter: blur(4px);
  border: 1px solid rgba(56, 189, 248, 0.5);
  text-transform: capitalize;
}

.badge-event-cam {
  background: rgba(15, 23, 42, 0.85);
  color: #94a3b8;
  font-size: 0.68rem;
  font-weight: 600;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  backdrop-filter: blur(4px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  text-transform: uppercase;
}

/* Tracked Object Details Modal Layout (Matching Screenshot) */
.tracked-modal-dialog {
  max-width: 1080px;
  width: 95vw;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  background-color: #090e17;
  border: 1px solid #1e293b;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.85);
}

.tracked-modal-body {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 1.25rem;
  padding: 1.25rem;
  overflow-y: auto;
  flex: 1;
}

@media (max-width: 860px) {
  .tracked-modal-body {
    grid-template-columns: 1fr;
    gap: 1rem;
    padding: 0.85rem;
  }
}

/* Left Column: Video & Controls */
.tracked-video-col {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.tracked-video-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background-color: #000000;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid #1e293b;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

.tracked-video-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.75rem;
  background-color: #0b111e;
  border: 1px solid #1e293b;
  border-radius: 6px;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* Right Column: Tracking Details Sidebar */
.tracked-details-col {
  display: flex;
  flex-direction: column;
  background-color: #0b111e;
  border: 1px solid #1e293b;
  border-radius: 8px;
  padding: 1rem;
  overflow: hidden;
}

/* Frigate Tabs Nav (Pills) */
.tracked-tabs-nav {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border-bottom: 1px solid #1e293b;
  padding-bottom: 0.75rem;
  margin-bottom: 1rem;
}

.tracked-nav-pill {
  padding: 0.4rem 0.85rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: #94a3b8;
  background-color: rgba(255, 255, 255, 0.04);
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.tracked-nav-pill:hover {
  color: #f1f5f9;
  background-color: rgba(255, 255, 255, 0.08);
}

.tracked-nav-pill.active {
  background-color: #2563eb;
  color: #ffffff;
  border-color: #3b82f6;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

/* Event Metadata Header in Details Pane */
.event-meta-header {
  margin-bottom: 1.25rem;
}

.event-meta-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.15rem;
  font-weight: 700;
  color: #f8fafc;
  margin-bottom: 0.25rem;
}

.event-icon {
  font-size: 1.3rem;
}

.event-label-text {
  text-transform: capitalize;
}

.event-timerange-text {
  font-size: 0.78rem;
  color: #94a3b8;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 500;
}

/* Vertical Tracking Timeline */
.tracking-timeline-wrapper {
  position: relative;
  padding-left: 1.5rem;
  margin-top: 0.5rem;
  flex: 1;
  overflow-y: auto;
}

.timeline-line {
  position: absolute;
  top: 8px;
  bottom: 8px;
  left: 5px;
  width: 2px;
  background-color: #38bdf8;
  opacity: 0.6;
  border-radius: 1px;
}

.timeline-items {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.timeline-step {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.timeline-dot {
  position: absolute;
  top: 4px;
  left: -1.5rem;
  width: 12px;
  height: 12px;
  background-color: #38bdf8;
  border: 2px solid #090e17;
  border-radius: 50%;
  box-shadow: 0 0 8px rgba(56, 189, 248, 0.8);
}

.timeline-step-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: #f1f5f9;
}

.timeline-step-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.timeline-score {
  font-size: 0.75rem;
  color: #38bdf8;
  font-weight: 600;
  background-color: rgba(56, 189, 248, 0.1);
  padding: 0.05rem 0.35rem;
  border-radius: 4px;
}

.timeline-step-time {
  font-size: 0.75rem;
  color: #94a3b8;
  font-family: 'JetBrains Mono', monospace;
}

/* Thumbnail Pane */
.tracked-thumbnail-wrapper {
  width: 100%;
  height: 100%;
  min-height: 250px;
  background-color: #000;
  border-radius: 6px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #1e293b;
}

.tracked-thumb-img {
  max-width: 100%;
  max-height: 380px;
  object-fit: contain;
}

/* ========================================================= */
/* GEMINI AI SURVEILLANCE INTELLIGENCE STYLES                */
/* ========================================================= */

.btn-ai-header {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0.35rem 0.85rem;
  background: linear-gradient(135deg, #4f46e5, #0284c7);
  color: #ffffff;
  font-size: 0.78rem;
  font-weight: 700;
  border: 1px solid rgba(167, 139, 250, 0.4);
  border-radius: 9999px;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(79, 70, 229, 0.4);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  margin-left: 0.5rem;
}

.btn-ai-header:hover {
  transform: translateY(-1px) scale(1.02);
  box-shadow: 0 4px 15px rgba(79, 70, 229, 0.6);
  border-color: #a78bfa;
}

.ai-sparkle {
  color: #fde047;
  font-size: 0.95rem;
  filter: drop-shadow(0 0 4px rgba(253, 224, 71, 0.8));
}

.ai-nav-pill {
  border: 1px solid rgba(167, 139, 250, 0.3) !important;
}

.ai-nav-pill.active {
  background: linear-gradient(135deg, #4f46e5, #2563eb) !important;
  color: #fff !important;
  border-color: #818cf8 !important;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.5) !important;
}

.btn-ai-action {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: linear-gradient(135deg, #3730a3, #1e40af);
  color: #f1f5f9;
  border: 1px solid rgba(129, 140, 248, 0.4);
  padding: 0.3rem 0.65rem;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-ai-action:hover {
  background: linear-gradient(135deg, #4338ca, #1d4ed8);
  border-color: #a5b4fc;
  color: #fff;
  transform: translateY(-1px);
}

/* AI Analysis Pane in Modal */
.ai-analysis-container {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  background-color: #0b1329;
  border: 1px solid rgba(99, 102, 241, 0.3);
  border-radius: 8px;
  padding: 1rem;
}

.ai-header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding-bottom: 0.5rem;
}

.ai-title-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.ai-badge-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: #a5b4fc;
}

.ai-loading-box {
  text-align: center;
  padding: 2rem 1rem;
  color: #94a3b8;
  font-size: 0.82rem;
}

.ai-loading-box .spinner {
  width: 28px;
  height: 28px;
  margin: 0 auto 0.75rem;
  border-color: rgba(129, 140, 248, 0.2);
  border-top-color: #818cf8;
}

.ai-results-box {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.ai-section {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  background-color: rgba(255, 255, 255, 0.03);
  padding: 0.6rem 0.75rem;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.ai-section-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: #cbd5e1;
}

.ai-section-text {
  font-size: 0.82rem;
  line-height: 1.45;
  color: #e2e8f0;
}

/* Risk Badges */
.badge-risk-rendah {
  background-color: rgba(16, 185, 129, 0.2) !important;
  color: #34d399 !important;
  border: 1px solid #10b981 !important;
}

.badge-risk-sedang {
  background-color: rgba(245, 158, 11, 0.2) !important;
  color: #fbbf24 !important;
  border: 1px solid #f59e0b !important;
}

.badge-risk-tinggi {
  background-color: rgba(239, 68, 68, 0.25) !important;
  color: #f87171 !important;
  border: 1px solid #ef4444 !important;
}

/* Daily Briefing Modal */
.ai-briefing-dialog {
  max-width: 760px;
  width: 95vw;
}

.briefing-modal-body {
  max-height: 75vh;
  overflow-y: auto;
  padding: 1.25rem;
}

.briefing-card {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.briefing-header-block {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(135deg, rgba(79, 70, 229, 0.15), rgba(2, 132, 199, 0.15));
  padding: 0.85rem 1rem;
  border-radius: 8px;
  border: 1px solid rgba(99, 102, 241, 0.3);
}

.briefing-stat {
  display: flex;
  flex-direction: column;
}

.stat-num {
  font-size: 1.5rem;
  font-weight: 800;
  color: #38bdf8;
  font-family: 'JetBrains Mono', monospace;
}

.stat-desc {
  font-size: 0.72rem;
  color: #94a3b8;
  text-transform: uppercase;
  font-weight: 600;
}

.briefing-exec-summary {
  background-color: #0b111e;
  border: 1px solid #1e293b;
  border-radius: 8px;
  padding: 1rem;
}

.briefing-list {
  list-style: none;
  padding: 0;
  margin: 0.5rem 0 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.briefing-list li {
  position: relative;
  padding-left: 1.2rem;
  font-size: 0.82rem;
  color: #cbd5e1;
  line-height: 1.4;
}

.briefing-list li::before {
  content: "•";
  position: absolute;
  left: 0.3rem;
  color: #38bdf8;
  font-weight: bold;
}

.tracked-thumb-img {
  max-width: 100%;
  max-height: 380px;
  object-fit: contain;
}

/* ==========================================================
   EVENTS PAGINATION BAR (30 PER PAGE WITH PAGE BUTTONS)
   ========================================================== */
.events-pagination-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 2rem;
  padding: 1rem 1.25rem;
  background: #0f172a;
  border: 1px solid #1e293b;
  border-radius: 12px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.pagination-info {
  font-size: 0.85rem;
  color: #94a3b8;
}

.pagination-info strong {
  color: #f8fafc;
  font-weight: 600;
}

.pagination-buttons {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.pag-numbers {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.pag-btn,
.pag-num-btn,
.pag-jump-btn {
  background: #1e293b;
  color: #cbd5e1;
  border: 1px solid #334155;
  border-radius: 6px;
  padding: 0.4rem 0.75rem;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.pag-btn:hover:not(:disabled),
.pag-num-btn:hover:not(.active),
.pag-jump-btn:hover {
  background: #334155;
  color: #ffffff;
  border-color: #475569;
}

.pag-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

.pag-num-btn {
  min-width: 2.2rem;
  height: 2.2rem;
  padding: 0 0.5rem;
}

.pag-num-btn.active {
  background: #0284c7;
  color: #ffffff;
  border-color: #38bdf8;
  font-weight: 700;
  box-shadow: 0 0 10px rgba(2, 132, 199, 0.4);
}

.pag-dots {
  color: #64748b;
  padding: 0 0.25rem;
  font-weight: bold;
}

.pagination-jump {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.82rem;
  color: #94a3b8;
}

.pag-jump-input {
  width: 3.8rem;
  padding: 0.35rem 0.5rem;
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 6px;
  color: #f8fafc;
  font-size: 0.82rem;
  text-align: center;
}

.pag-jump-input:focus {
  outline: none;
  border-color: #0284c7;
  box-shadow: 0 0 0 2px rgba(2, 132, 199, 0.2);
}

@media (max-width: 768px) {
  /* Header Professional Mobile Layout (Clean Margins & No Overflow) */
  .header-container {
    padding: 0.6rem 0.85rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    row-gap: 0.6rem;
  }

  .brand-group {
    gap: 0.5rem;
  }

  .brand-icon {
    width: 32px;
    height: 32px;
  }

  .brand-title {
    font-size: 1.1rem;
  }

  .brand-subtitle {
    display: none; /* Hide subtitle on mobile for professional compact header */
  }

  .header-actions {
    margin-left: auto;
  }

  .header-actions .btn {
    padding: 0.35rem 0.65rem;
    font-size: 0.75rem;
    border-radius: 6px;
  }

  .nav-links {
    order: 3;
    width: 100%;
    display: flex;
    background: rgba(15, 23, 42, 0.85);
    padding: 3px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    gap: 4px;
    margin: 0;
    box-sizing: border-box;
  }

  .nav-item {
    flex: 1;
    justify-content: center;
    padding: 0.45rem 0.65rem;
    font-size: 0.825rem;
    border-radius: 6px;
    text-align: center;
  }

  /* Toolbar */
  .toolbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }

  .toolbar-left, .toolbar-right {
    width: 100%;
    justify-content: space-between;
  }

  /* Modal Responsive Fixes (100% Mobile Viewport & No Horizontal Cutoff) */
  .modal {
    padding: 0.35rem;
  }

  .tracked-modal-dialog {
    width: 100%;
    max-width: 100%;
    max-height: 94vh;
    border-radius: 10px;
    margin: 0;
  }

  .tracked-modal-body {
    grid-template-columns: 1fr;
    gap: 0.75rem;
    padding: 0.75rem 0.5rem;
    overflow-y: auto;
  }

  .tracked-video-col {
    min-width: 0;
    width: 100%;
  }

  .tracked-video-wrapper {
    width: 100%;
    max-width: 100%;
    aspect-ratio: 16 / 9;
    box-sizing: border-box;
    border-radius: 6px;
  }

  .tracked-video-wrapper video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #000;
  }

  .tracked-video-controls {
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.5rem;
  }

  .playback-controls {
    flex-wrap: wrap;
    gap: 0.3rem;
  }

  .session-nav-controls {
    flex-wrap: wrap;
    gap: 0.3rem;
  }

  .tracked-details-col {
    min-width: 0;
    width: 100%;
    box-sizing: border-box;
    padding: 0.75rem;
  }

  .filter-card {
    padding: 0.85rem 0.75rem;
  }

  .footer {
    padding: 1.25rem 0.75rem;
    font-size: 0.75rem;
  }

  .events-pagination-bar {
    flex-direction: column;
    align-items: stretch;
    text-align: center;
  }
  .pagination-buttons {
    justify-content: center;
  }
  .pagination-jump {
    justify-content: center;
  }

  /* Full-width responsive clips grid on mobile (Matching Live tab layout) */
  .clips-grid {
    grid-template-columns: 1fr;
    gap: 0.85rem;
    width: 100%;
    max-width: 100%;
  }

  .clip-card {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }

  .filter-form {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  .camera-pills-bar {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .main-content, .page-container {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }
}

/* ==========================================================================
   Surveillance History & Scrubbable Timeline Styles
   ========================================================================== */

.history-page {
  padding-bottom: 3rem;
}

/* Visibility Helpers for Responsive Polish */
.history-title-mobile, .label-mobile, .btn-text-mobile {
  display: none;
}
.history-title-desktop, .label-desktop, .btn-text-desktop {
  display: inline;
}

@media (max-width: 640px) {
  .history-title-mobile, .label-mobile, .btn-text-mobile {
    display: inline;
  }
  .history-title-desktop, .label-desktop, .btn-text-desktop {
    display: none;
  }
}

/* Camera Pills Horizontal Scroller with Hidden Native Scrollbars */
.camera-pills-bar {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  -ms-overflow-style: none;
  padding-bottom: 0.35rem;
}

.camera-pills-bar::-webkit-scrollbar {
  display: none;
}

.history-quick-stats {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

/* Controls Card Layout */
.history-controls-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 0.85rem 1.25rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow-sm);
}

.history-controls-grid {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.controls-grid-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

@media (min-width: 1025px) {
  .history-controls-grid {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
  }
  .controls-grid-row {
    flex: 1;
    justify-content: flex-start;
    gap: 1.25rem;
  }
  .controls-row-actions {
    justify-content: flex-end;
  }
}

.control-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.control-group label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.history-select {
  padding: 0.45rem 1rem;
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
}

.current-time-display {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(56, 189, 248, 0.25);
  border-radius: var(--radius-md);
  padding: 0.45rem 0.85rem;
}

.current-time-display .time-label {
  font-size: 0.725rem;
  font-weight: 700;
  color: #38bdf8;
  letter-spacing: 0.5px;
}

.current-time-display .time-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.95rem;
  font-weight: 600;
  color: #f8fafc;
}

.motion-jump-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.zoom-range-group {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.2rem 0.35rem;
}

.zoom-range-group .zoom-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
  margin-right: 0.25rem;
  margin-left: 0.25rem;
}

.zoom-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.25rem 0.55rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
}

.zoom-btn:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.05);
}

.zoom-btn.active {
  background: var(--primary);
  color: #ffffff;
}

/* --- History Workspace Layout (Video + Side Panel) --- */
.history-workspace {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 1.5rem;
  align-items: start;
}

@media (max-width: 1100px) {
  .history-workspace {
    grid-template-columns: 1fr;
  }
}

.history-main-player {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.history-video-container {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000000;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  justify-content: center;
}

.history-video-container video {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.video-overlay-header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: 0.85rem 1.25rem;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.85) 0%, rgba(0, 0, 0, 0) 100%);
  display: flex;
  justify-content: space-between;
  align-items: center;
  pointer-events: none;
  z-index: 10;
}

.active-cam-title {
  font-size: 1rem;
  font-weight: 700;
  color: #ffffff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
  margin-right: 0.6rem;
}

.video-source-pill {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-sm);
  background: rgba(16, 185, 129, 0.25);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.4);
}

.segment-duration-tag {
  font-size: 0.75rem;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 600;
  color: #e2e8f0;
  background: rgba(15, 23, 42, 0.75);
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.history-video-loading, .history-no-video {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(4px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.85rem;
  color: #f8fafc;
  z-index: 20;
}

.history-no-video {
  color: var(--text-muted);
  text-align: center;
  padding: 2rem;
}

.history-no-video h3 {
  color: #f1f5f9;
  font-size: 1.15rem;
  margin: 0;
}

.history-no-video p {
  font-size: 0.85rem;
  margin: 0;
  max-width: 320px;
}

/* --- Playback Toolbar --- */
.history-playback-toolbar {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 0.75rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  box-shadow: var(--shadow-sm);
}

.playback-controls-left, .playback-controls-center, .playback-controls-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.speed-selector {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.2rem 0.35rem;
}

.speed-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
  margin-left: 0.25rem;
}

.speed-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
}

.speed-btn:hover {
  color: var(--text-primary);
}

.speed-btn.active {
  background: rgba(255, 255, 255, 0.15);
  color: #ffffff;
}

/* --- Waveform Zoom Controls Bar (Between Playback Toolbar & Waveform) --- */
.timeline-zoom-bar {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 0.6rem 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-sm);
}

.timeline-zoom-bar .zoom-range-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.25rem 0.5rem;
}

.timeline-zoom-bar .zoom-label {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-right: 0.35rem;
}

.timeline-zoom-bar .zoom-btn {
  padding: 0.3rem 0.75rem;
  font-size: 0.78rem;
  border-radius: var(--radius-sm);
}

/* --- Timeline & Motion Waveform Area --- */
.timeline-wrapper {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1rem 1.25rem 1.25rem;
  box-shadow: var(--shadow-md);
}

.timeline-header-legend {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.85rem;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.legend-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.timeline-legend-items {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.legend-color {
  width: 10px;
  height: 10px;
  border-radius: 2px;
}

.color-recording { background: #334155; }
.color-motion { background: #f59e0b; }
.color-event { background: #ef4444; }

.timeline-scrubber-area {
  position: relative;
  width: 100%;
  height: 108px;
  background: #0f172a;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.1);
  overflow: visible;
  cursor: pointer;
  user-select: none;
  margin-top: 26px; /* Generous gap for the red time badge above needle */
  touch-action: none;
}

.timeline-ruler {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 22px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  pointer-events: none;
}

.ruler-tick {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  background: rgba(255, 255, 255, 0.2);
}

.ruler-label {
  position: absolute;
  top: 4px;
  left: 4px;
  font-size: 0.65rem;
  font-family: 'JetBrains Mono', monospace;
  color: rgba(255, 255, 255, 0.55);
  white-space: nowrap;
}

#timeline-waveform-canvas {
  position: absolute;
  top: 24px;
  left: 0;
  width: 100%;
  height: 84px;
  display: block;
}

/* Draggable Playhead Scrubber Needle */
.timeline-playhead {
  position: absolute;
  top: -8px;
  bottom: -4px;
  width: 2px;
  background: #ef4444;
  pointer-events: none;
  z-index: 15;
  transition: left 0.05s linear;
}

.playhead-line {
  position: absolute;
  top: 20px;
  bottom: 0;
  left: -1px;
  width: 3px;
  background: #ef4444;
  box-shadow: 0 0 8px rgba(239, 68, 68, 0.8);
}

.playhead-badge {
  position: absolute;
  top: -22px;
  left: 50%;
  transform: translateX(-50%);
  background: #ef4444;
  color: #ffffff;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.15rem 0.45rem;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  box-shadow: var(--shadow-sm);
}

.playhead-handle {
  position: absolute;
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%);
  width: 14px;
  height: 14px;
  background: #ef4444;
  border-radius: 50%;
  border: 2px solid #ffffff;
  box-shadow: var(--shadow-sm);
}

/* Hover Tooltip */
.timeline-hover-tooltip {
  position: absolute;
  top: -46px;
  transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid rgba(56, 189, 248, 0.4);
  border-radius: var(--radius-sm);
  padding: 0.3rem 0.6rem;
  pointer-events: none;
  z-index: 30;
  text-align: center;
  box-shadow: var(--shadow-md);
}

.tooltip-time {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  font-weight: 700;
  color: #38bdf8;
}

.tooltip-info {
  font-size: 0.68rem;
  color: #cbd5e1;
}

/* --- Side Panel Styles --- */
.history-side-panel {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.side-panel-section {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1rem;
  box-shadow: var(--shadow-sm);
}

.side-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.85rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--border-color);
}

.side-section-header h3 {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.side-camera-list {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  max-height: calc(100vh - 220px);
  min-height: 520px;
  overflow-y: auto;
  padding-right: 0.35rem;
}

.side-cam-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s ease;
}

.side-cam-card:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(56, 189, 248, 0.4);
  transform: translateX(3px);
}

.side-cam-thumb {
  position: relative;
  width: 68px;
  height: 46px;
  background: #0f172a;
  border-radius: var(--radius-sm);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.side-cam-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}

.side-cam-badge {
  position: absolute;
  bottom: 2px;
  right: 2px;
  font-size: 0.58rem;
  font-weight: 700;
  padding: 0.08rem 0.3rem;
  border-radius: 2px;
  text-transform: uppercase;
  letter-spacing: 0.2px;
}

.side-cam-badge.badge-motion {
  background: rgba(245, 158, 11, 0.25);
  color: #f59e0b;
  border: 1px solid rgba(245, 158, 11, 0.45);
}

.side-cam-badge.badge-rec {
  background: rgba(56, 189, 248, 0.2);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.4);
}

.side-cam-badge.badge-empty {
  background: rgba(100, 116, 139, 0.2);
  color: #94a3b8;
  border: 1px solid rgba(100, 116, 139, 0.3);
}

.side-cam-info {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  overflow: hidden;
  flex: 1;
}

.side-cam-name {
  font-size: 0.825rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.side-cam-action {
  font-size: 0.7rem;
  color: #38bdf8;
  font-weight: 600;
}

.side-cam-empty {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-align: center;
  padding: 1.5rem 0.5rem;
}

/* ==========================================================================
   Mobile Responsive Media Queries for Timeline Page
   ========================================================================== */

@media (max-width: 768px) {
  .history-toolbar {
    margin-bottom: 0.75rem;
  }

  .history-toolbar .section-title {
    font-size: 1.05rem;
  }

  .history-controls-card {
    padding: 0.65rem 0.75rem;
    margin-bottom: 0.85rem;
  }

  .history-controls-grid {
    gap: 0.5rem;
  }

  .controls-row-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    width: 100%;
  }

  .date-control-group {
    flex: 1;
    min-width: 0;
  }

  .history-select {
    width: 100%;
    padding: 0.35rem 0.45rem;
    font-size: 0.78rem;
  }

  .current-time-display {
    padding: 0.35rem 0.55rem;
    gap: 0.35rem;
    flex-shrink: 0;
  }

  .current-time-display .time-label {
    font-size: 0.65rem;
  }

  .current-time-display .time-value {
    font-size: 0.8rem;
  }

  .controls-row-actions {
    display: flex;
    align-items: center;
    justify-content: stretch;
    width: 100%;
  }

  .motion-jump-group {
    display: flex;
    width: 100%;
    gap: 0.5rem;
  }

  .motion-jump-group .btn {
    flex: 1;
    justify-content: center;
    padding: 0.38rem 0.6rem;
    font-size: 0.78rem;
  }

  /* Playback Toolbar Mobile Layout */
  .history-playback-toolbar {
    padding: 0.6rem 0.65rem;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
  }

  .playback-controls-left {
    order: 1;
    gap: 0.35rem;
  }

  .playback-controls-left .btn {
    padding: 0.35rem 0.6rem;
    font-size: 0.78rem;
  }

  .playback-controls-right {
    order: 2;
    gap: 0.35rem;
  }

  .playback-controls-right .btn {
    padding: 0.35rem 0.6rem;
    font-size: 0.78rem;
  }

  .playback-controls-center {
    order: 3;
    width: 100%;
    justify-content: center;
    margin-top: 0.2rem;
  }

  .speed-selector {
    width: 100%;
    justify-content: space-around;
    padding: 0.15rem 0.35rem;
  }

  .speed-label {
    font-size: 0.7rem;
  }

  .speed-btn {
    padding: 0.2rem 0.45rem;
    font-size: 0.7rem;
  }

  /* Waveform Zoom Bar Mobile */
  .timeline-zoom-bar {
    padding: 0.45rem 0.65rem;
  }

  .timeline-zoom-bar .zoom-range-group {
    width: 100%;
    justify-content: space-between;
    gap: 0.2rem;
    padding: 0.2rem 0.35rem;
  }

  .timeline-zoom-bar .zoom-label {
    font-size: 0.72rem;
    margin-right: 0.15rem;
  }

  .timeline-zoom-bar .zoom-btn {
    padding: 0.22rem 0.4rem;
    font-size: 0.7rem;
    flex: 1;
    text-align: center;
  }

  /* Timeline Waveform Container Mobile */
  .timeline-wrapper {
    padding: 0.75rem 0.75rem 1rem;
  }

  .timeline-header-legend {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.35rem;
    margin-bottom: 0.35rem;
  }

  .legend-title {
    font-size: 0.8rem;
  }

  .timeline-legend-items {
    width: 100%;
    justify-content: space-between;
    gap: 0.25rem;
    font-size: 0.68rem;
  }

  .playhead-handle {
    width: 16px;
    height: 16px;
    bottom: -8px;
  }

  /* Side Camera List Responsive 2-Column Grid on Mobile */
  .side-panel-section {
    padding: 0.75rem;
  }

  .side-camera-list {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
    max-height: none;
    min-height: auto;
    overflow-y: visible;
    padding-right: 0;
  }

  .side-cam-card {
    flex-direction: column;
    align-items: stretch;
    gap: 0.45rem;
    padding: 0.55rem;
    background: var(--bg-surface);
  }

  .side-cam-card:hover {
    transform: none;
  }

  .side-cam-thumb {
    width: 100%;
    height: 38px;
  }

  .side-cam-name {
    font-size: 0.78rem;
  }

  .side-cam-action {
    font-size: 0.68rem;
  }
}

@media (max-width: 380px) {
  .side-camera-list {
    grid-template-columns: 1fr;
  }
}

/* ==========================================================================
   PTZ Hub & Dropdown Navigation Styles
   ========================================================================== */

/* Navbar Dropdown */
.nav-dropdown-wrapper {
  position: relative;
  display: inline-block;
}

.nav-dropdown-wrapper .dropdown-chevron {
  transition: transform 0.2s ease;
  margin-left: 2px;
}

.nav-dropdown-wrapper:hover .dropdown-chevron {
  transform: rotate(180deg);
}

.nav-dropdown-menu {
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 210px;
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 8px;
  padding: 6px;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5);
  display: none;
  flex-direction: column;
  gap: 4px;
  z-index: 1000;
  margin-top: 4px;
}

.nav-dropdown-wrapper:hover .nav-dropdown-menu {
  display: flex;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 6px;
  color: #f1f5f9;
  text-decoration: none;
  font-size: 0.85rem;
  transition: all 0.15s ease;
}

.dropdown-item:hover {
  background: rgba(56, 189, 248, 0.12);
  color: #38bdf8;
}

.dropdown-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.dropdown-dot.green { background: #22c55e; box-shadow: 0 0 6px #22c55e; }
.dropdown-dot.blue { background: #38bdf8; box-shadow: 0 0 6px #38bdf8; }

.dropdown-title {
  font-weight: 600;
  line-height: 1.2;
}

.dropdown-sub {
  font-size: 0.72rem;
  color: #94a3b8;
  font-family: monospace;
}

/* ==========================================================================
   PTZ CAMERA CONTROLLER WORKSTATION (Direct No-Tailscale Routing)
   ========================================================================== */
.ptz-page-container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 0.5rem;
}

.ptz-workspace-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
  margin-top: 1.25rem;
}

@media (min-width: 992px) {
  .ptz-workspace-grid {
    grid-template-columns: minmax(0, 1.45fr) minmax(360px, 1fr);
    align-items: start;
  }
}

/* Video Monitor Card */
.ptz-monitor-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  display: flex;
  flex-direction: column;
}

.ptz-monitor-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.9rem 1.25rem;
  background: rgba(15, 23, 42, 0.7);
  border-bottom: 1px solid var(--border-color);
}

.ptz-cam-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.ptz-cam-title-line {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ptz-cam-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: #f8fafc;
  margin: 0;
}

.ptz-cam-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.ptz-video-viewport {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  background: #000000;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ptz-video-element {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}

.ptz-monitor-footer {
  padding: 0.75rem 1.25rem;
  background: rgba(15, 23, 42, 0.5);
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.78rem;
  color: #94a3b8;
  flex-wrap: wrap;
  gap: 8px;
}

/* PTZ Control Panel Card */
.ptz-control-panel-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  display: flex;
  flex-direction: column;
}

.ptz-control-header {
  padding: 0.9rem 1.25rem;
  background: rgba(15, 23, 42, 0.7);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.ptz-control-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: #f8fafc;
  display: flex;
  align-items: center;
  gap: 8px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.ptz-control-body {
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  align-items: center;
}

/* 8-Way D-Pad */
.ptz-dpad-container {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  padding: 0.25rem 0;
}

.ptz-dpad-grid {
  display: grid;
  grid-template-columns: repeat(3, 76px);
  grid-template-rows: repeat(3, 76px);
  gap: 12px;
}

@media (max-width: 480px) {
  .ptz-dpad-grid {
    grid-template-columns: repeat(3, 64px);
    grid-template-rows: repeat(3, 64px);
    gap: 8px;
  }
}

.ptz-dpad-btn {
  background: #1e293b;
  border: 2px solid #334155;
  color: #f8fafc;
  border-radius: 12px;
  font-size: 26px;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
  transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

.ptz-dpad-btn:hover {
  background: #334155;
  border-color: #38bdf8;
  color: #ffffff;
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(56, 189, 248, 0.25);
}

.ptz-dpad-btn:active, .ptz-dpad-btn.active-press {
  background: #0284c7 !important;
  border-color: #38bdf8 !important;
  color: #ffffff !important;
  transform: translateY(1px) scale(0.95);
  box-shadow: 0 0 16px rgba(56, 189, 248, 0.6) !important;
}

.ptz-home-btn {
  background: rgba(30, 41, 59, 0.9);
  border-color: #38bdf8;
  color: #38bdf8;
  font-size: 24px;
}

.ptz-home-btn:hover {
  background: rgba(56, 189, 248, 0.15);
  border-color: #38bdf8;
  color: #ffffff;
}

/* Step Size Selector */
.ptz-step-block {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ptz-block-label {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.ptz-step-btn-group {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  width: 100%;
}

.ptz-step-btn {
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid #334155;
  background: #1e293b;
  color: #cbd5e1;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: all 0.2s ease;
}

.ptz-step-btn:hover {
  border-color: #64748b;
  color: #ffffff;
}

.ptz-step-btn.active {
  background: #0284c7;
  border-color: #38bdf8;
  color: #ffffff;
  box-shadow: 0 0 12px rgba(2, 132, 199, 0.4);
}

/* Live Status Box */
.ptz-status-box {
  width: 100%;
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 0.85rem;
  color: #38bdf8;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 42px;
  box-sizing: border-box;
}

.ptz-status-text {
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 6px;
}

.ptz-status-latency {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* Keyboard Guide */
.ptz-keyboard-guide {
  width: 100%;
  background: rgba(255, 255, 255, 0.02);
  border: 1px dashed rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 0.78rem;
  color: #94a3b8;
  line-height: 1.5;
}

.ptz-key-tag {
  display: inline-block;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 4px;
  padding: 1px 5px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  color: #f1f5f9;
}

/* Stream Quality Selector Pills */
.stream-quality-pills {
  display: inline-flex;
  align-items: center;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 2px;
  gap: 2px;
}

.quality-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.quality-btn:hover {
  color: #f8fafc;
  background: rgba(255, 255, 255, 0.05);
}

.quality-btn.active {
  background: #0284c7;
  color: #ffffff;
  box-shadow: 0 0 10px rgba(2, 132, 199, 0.4);
}


