:root {
  --bg: #090e17;
  --card-bg: #131c2b;
  --card-inner: #0d1522;
  --header-bg: #1c273a;
  --border: #23334d;
  --text: #e2e8f0;
  --text-dim: #94a3b8;
  --cyan: #00d2ff;
  --cyan-glow: rgba(0, 210, 255, 0.25);
  --green: #00e676;
  --green-glow: rgba(0, 230, 118, 0.25);
  --red: #f87171;
  --amber: #fbbf24;
  --radius-lg: 14px;
  --radius-md: 8px;
  --radius-sm: 6px;
}

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

body {
  background-color: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, monospace;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px;
}

#cctv-app {
  width: 100%;
  max-width: 1400px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.7);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ==================== HEADER ==================== */
.app-header {
  background: var(--header-bg);
  padding: 14px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 12px;
}

.header-left {
  display: flex;
  align-items: center;
}

.brand-title-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-title-wrap h2 {
  font-size: 1.25rem;
  color: var(--cyan);
  letter-spacing: 0.5px;
  font-weight: 700;
}

.site-sub {
  font-size: 0.75rem;
  color: var(--text-dim);
  font-family: monospace;
  margin-top: 2px;
}

.pulse {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 10px var(--green);
  animation: pulse-ring 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes pulse-ring {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(1.25); }
}

/* Header Navigation (Switching between Solar & Feeds) */
.header-center {
  display: flex;
  align-items: center;
}

.nav-links {
  display: flex;
  background: rgba(13, 21, 34, 0.75);
  border: 1px solid var(--border);
  border-radius: 30px;
  padding: 3px;
  gap: 4px;
}

.nav-btn {
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-dim);
  padding: 6px 14px;
  border-radius: 20px;
  transition: all 0.25s ease;
  display: flex;
  align-items: center;
  gap: 6px;
}

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

.nav-btn.active {
  background: var(--cyan);
  color: #090e17;
  font-weight: 700;
  box-shadow: 0 2px 10px var(--cyan-glow);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 20px;
  font-family: monospace;
  background: rgba(251, 191, 36, 0.15);
  color: var(--amber);
  border: 1px solid rgba(251, 191, 36, 0.35);
  transition: all 0.3s ease;
}

.status-badge.live {
  background: rgba(0, 230, 118, 0.15);
  color: var(--green);
  border-color: rgba(0, 230, 118, 0.4);
  box-shadow: 0 0 10px var(--green-glow);
}

.status-badge.offline {
  background: rgba(248, 113, 113, 0.15);
  color: var(--red);
  border-color: rgba(248, 113, 113, 0.4);
}

.status-indicator {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.clock-display {
  font-size: 0.85rem;
  font-family: monospace;
  color: var(--text-dim);
  background: rgba(0, 0, 0, 0.3);
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.icon-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.2s ease;
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: var(--cyan);
}

/* ==================== TOOLBAR ==================== */
.toolbar {
  background: #101826;
  border-bottom: 1px solid var(--border);
  padding: 10px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  position: relative;
  z-index: 50;
}

.tool-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tool-label {
  font-size: 0.78rem;
  color: var(--text-dim);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.segmented-control {
  display: flex;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 2px;
  gap: 2px;
}

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

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

.seg-btn.active {
  background: #1f2d44;
  color: var(--cyan);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

.tool-action-btn {
  background: #182436;
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: all 0.2s ease;
}

.tool-action-btn:hover {
  border-color: var(--cyan);
  color: var(--cyan);
}

/* ==================== CAMERA STAGE ==================== */
.camera-stage {
  padding: 16px;
  display: grid;
  gap: 16px;
  background: var(--bg);
  min-height: 580px;
  flex: 1;
}

/* Layout Switching */
.camera-stage.layout-grid,
.camera-stage.grid-view {
  grid-template-columns: repeat(2, 1fr);
}

/* Focused Single View (1 Camera at a time) */
.camera-stage.layout-single .camera-card,
.camera-stage.single-view .camera-card {
  display: none !important;
}

.camera-stage.layout-single .camera-card.active-focus,
.camera-stage.layout-single .camera-card.active-cam,
.camera-stage.single-view .camera-card.active-focus,
.camera-stage.single-view .camera-card.active-cam {
  display: flex !important;
  grid-column: 1 / -1;
  max-width: 1080px;
  width: 100%;
  margin: 0 auto;
}

/* Camera Card Component */
.camera-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.4);
  transition: border-color 0.2s ease, transform 0.2s ease;
}

.camera-card:hover {
  border-color: rgba(0, 210, 255, 0.4);
}

.camera-header {
  background: #141f30;
  padding: 8px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
}

.camera-info {
  display: flex;
  align-items: center;
  gap: 8px;
}

.cam-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-dim);
}

.cam-dot.live {
  background: var(--green);
  box-shadow: 0 0 6px var(--green);
}

.cam-name {
  font-size: 0.85rem;
  font-weight: 700;
  color: #f1f5f9;
  letter-spacing: 0.3px;
}

.cam-ip-badge {
  font-size: 0.7rem;
  font-family: monospace;
  color: #64748b;
  background: rgba(0, 0, 0, 0.25);
  padding: 2px 6px;
  border-radius: 4px;
}

.camera-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.badge-res {
  font-size: 0.68rem;
  font-family: monospace;
  font-weight: 700;
  background: rgba(0, 210, 255, 0.15);
  color: var(--cyan);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid rgba(0, 210, 255, 0.3);
}

.cam-icon-btn {
  background: transparent;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 4px;
  font-size: 0.85rem;
  transition: all 0.2s ease;
}

.cam-icon-btn:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
}

/* Video Container & Overlays */
.video-container {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #060a10;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

video, video-stream {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

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

.mjpeg-feed {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.video-overlay {
  position: absolute;
  top: 10px;
  left: 10px;
  right: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  pointer-events: none;
  z-index: 5;
}

.overlay-badge {
  font-family: monospace;
  font-size: 0.72rem;
  font-weight: 700;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  padding: 3px 8px;
  border-radius: 4px;
  backdrop-filter: blur(4px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  letter-spacing: 0.5px;
}

.overlay-badge.status {
  color: var(--green);
  border-color: rgba(0, 230, 118, 0.3);
}

/* Loading & Error States */
.loading-state,
.error-state {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(6, 10, 16, 0.9);
  z-index: 10;
  padding: 16px;
  text-align: center;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid rgba(0, 210, 255, 0.15);
  border-top-color: var(--cyan);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 10px;
}

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

.loading-text {
  font-size: 0.8rem;
  color: var(--text-dim);
  font-family: monospace;
}

.error-icon {
  font-size: 1.8rem;
  margin-bottom: 6px;
}

.error-msg {
  font-size: 0.82rem;
  color: var(--red);
  margin-bottom: 10px;
  font-weight: 500;
}

.retry-btn {
  background: rgba(0, 210, 255, 0.15);
  color: var(--cyan);
  border: 1px solid rgba(0, 210, 255, 0.4);
  font-size: 0.76rem;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.retry-btn:hover {
  background: var(--cyan);
  color: #090e17;
}

.hidden {
  display: none !important;
}

/* ==================== FOOTER ==================== */
.app-footer {
  background: var(--header-bg);
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.78rem;
  color: var(--text-dim);
  flex-wrap: wrap;
  gap: 8px;
}

.footer-credits .brand-text {
  color: var(--cyan);
  font-weight: 600;
}

.footer-credits .author-text {
  color: #f1f5f9;
  font-weight: 600;
}

.footer-meta {
  font-family: monospace;
  font-size: 0.74rem;
  color: #64748b;
  display: flex;
  align-items: center;
  gap: 6px;
}

.meta-sep {
  color: #334155;
}

/* ==================== SETTINGS MODAL ==================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
}

.modal-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  max-width: 520px;
  width: 100%;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.8);
  overflow: hidden;
}

.modal-header {
  background: var(--header-bg);
  padding: 14px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 {
  font-size: 1.05rem;
  color: var(--cyan);
}

.modal-close-btn {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 1.4rem;
  cursor: pointer;
  line-height: 1;
}

.modal-close-btn:hover {
  color: #fff;
}

.modal-body {
  padding: 18px;
}

.modal-desc {
  font-size: 0.82rem;
  color: var(--text-dim);
  margin-bottom: 16px;
  line-height: 1.5;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

.form-input {
  width: 100%;
  background: var(--card-inner);
  border: 1px solid var(--border);
  color: #fff;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-family: monospace;
  font-size: 0.85rem;
  outline: none;
  transition: border-color 0.2s ease;
}

.form-input:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 8px var(--cyan-glow);
}

.form-hint {
  display: block;
  font-size: 0.72rem;
  color: #64748b;
  margin-top: 6px;
  line-height: 1.5;
}

.channel-map-list {
  background: var(--card-inner);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 0.78rem;
  font-family: monospace;
}

.channel-row {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.channel-row:last-child {
  border-bottom: none;
}

.channel-row code {
  color: var(--cyan);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}

.btn {
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.2s ease;
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.15);
}

.btn-primary {
  background: var(--cyan);
  color: #090e17;
  font-weight: 700;
  box-shadow: 0 2px 10px var(--cyan-glow);
}

.btn-primary:hover {
  background: #22dbff;
}

/* ==================== RESPONSIVE DESIGN ==================== */
@media (max-width: 900px) {
  .camera-stage.layout-grid {
    grid-template-columns: 1fr;
  }
  .app-header {
    flex-direction: column;
    align-items: stretch;
  }
  .header-left, .header-center, .header-right {
    justify-content: space-between;
  }
  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }
  .tool-group-right {
    justify-content: space-between;
  }
}

/* ==================== PIN AUTH MODAL ==================== */
.pin-card {
  max-width: 380px;
  text-align: center;
  padding: 30px 24px;
}

.pin-icon-wrap {
  width: 60px;
  height: 60px;
  margin: 0 auto 16px;
  background: rgba(0, 210, 255, 0.1);
  border: 1px solid rgba(0, 210, 255, 0.3);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  box-shadow: 0 0 20px var(--cyan-glow);
}

.pin-title {
  font-size: 1.2rem;
  color: #fff;
  margin-bottom: 6px;
}

.pin-desc {
  font-size: 0.82rem;
  color: var(--text-dim);
  margin-bottom: 22px;
}

.pin-input-group {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-bottom: 16px;
}

.pin-digit {
  width: 52px;
  height: 58px;
  background: var(--card-inner);
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--cyan);
  font-size: 1.8rem;
  font-weight: 700;
  text-align: center;
  outline: none;
  font-family: monospace;
  transition: all 0.2s ease;
}

.pin-digit:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 12px var(--cyan-glow);
  background: rgba(0, 210, 255, 0.05);
}

.pin-error {
  color: var(--red);
  font-size: 0.8rem;
  margin-bottom: 14px;
  min-height: 18px;
}

.pin-remember-wrap {
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
}

.pin-remember-wrap input {
  accent-color: var(--cyan);
  cursor: pointer;
}

.pin-submit-btn {
  width: 100%;
  padding: 12px;
  font-size: 0.95rem;
}

.pin-hint {
  font-size: 0.72rem;
  color: #64748b;
  margin-top: 16px;
}

.pin-hint code {
  color: var(--cyan);
  background: rgba(0, 0, 0, 0.4);
  padding: 2px 6px;
  border-radius: 4px;
}

/* ==================== IDLE / PAUSE OVERLAY ==================== */
.idle-overlay {
  position: fixed;
  inset: 0;
  background: rgba(9, 14, 23, 0.88);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 900;
  padding: 16px;
}

.idle-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px 28px;
  text-align: center;
  max-width: 420px;
  width: 100%;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.9);
}

.idle-icon {
  font-size: 2.5rem;
  margin-bottom: 12px;
}

.idle-card h3 {
  font-size: 1.25rem;
  color: #fff;
  margin-bottom: 8px;
}

.idle-card p {
  font-size: 0.85rem;
  color: var(--text-dim);
  margin-bottom: 22px;
  line-height: 1.5;
}

.idle-card .btn {
  width: 100%;
  padding: 12px;
  font-size: 0.95rem;
}

@keyframes pinShake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-6px); border-color: var(--red); }
  40%, 80% { transform: translateX(6px); border-color: var(--red); }
}

.pin-shake {
  animation: pinShake 0.4s ease-in-out;
}


/* ==================== SD CARD PLAYBACK & DOWNLOADS ==================== */
.highlight-btn {
  background: rgba(0, 210, 255, 0.15) !important;
  color: var(--cyan) !important;
  border-color: rgba(0, 210, 255, 0.4) !important;
}

.highlight-btn:hover {
  background: rgba(0, 210, 255, 0.3) !important;
  box-shadow: 0 0 10px var(--cyan-glow);
}

.sd-card-modal {
  max-width: 760px;
  width: 95%;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
}

.sd-card-modal .modal-body {
  overflow-y: auto;
  padding-right: 8px;
}

.sd-controls-grid {
  display: grid;
  grid-template-columns: 2fr 1.5fr auto;
  gap: 12px;
  align-items: flex-end;
  margin-bottom: 16px;
}

.sd-btn-wrap {
  margin-bottom: 0;
}

.sd-btn-wrap .btn {
  padding: 10px 16px;
  font-size: 0.85rem;
  white-space: nowrap;
}

.sd-auth-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #090e17;
  padding: 8px 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  margin-bottom: 14px;
  font-size: 0.82rem;
}

.sd-auth-status {
  color: #94a3b8;
}

.sd-auth-status.online {
  color: var(--green);
}

.sd-auth-status.warning {
  color: var(--amber);
}

.sd-auth-box {
  background: #111a28;
  padding: 14px;
  border-radius: 8px;
  border: 1px solid rgba(0, 210, 255, 0.3);
  margin-bottom: 14px;
}

.sd-auth-hint {
  font-size: 0.82rem;
  color: #cbd5e1;
  margin-bottom: 10px;
  line-height: 1.4;
}

.sd-auth-input-group {
  display: flex;
  gap: 8px;
  margin-bottom: 6px;
}

.sd-auth-input-group input {
  flex: 1;
}

.btn-xs {
  padding: 3px 8px;
  font-size: 0.75rem;
}

.sd-status-msg {
  padding: 10px;
  border-radius: 6px;
  margin-bottom: 12px;
  font-size: 0.84rem;
  background: rgba(0, 210, 255, 0.1);
  color: var(--cyan);
  border: 1px solid rgba(0, 210, 255, 0.25);
  display: flex;
  align-items: center;
  gap: 8px;
}

.sd-status-msg.error {
  background: rgba(239, 68, 68, 0.15);
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.3);
}

.sd-recordings-container {
  margin-bottom: 18px;
}

.sd-table-wrap {
  background: #090e17;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  max-height: 280px;
  overflow-y: auto;
}

.sd-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
}

.sd-table th {
  background: #131c2b;
  color: #94a3b8;
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.72rem;
  letter-spacing: 0.05em;
  padding: 10px 12px;
  text-align: left;
  position: sticky;
  top: 0;
  z-index: 2;
  border-bottom: 1px solid var(--border);
}

.sd-table td {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  color: #f1f5f9;
}

.sd-table tbody tr:hover {
  background: rgba(0, 210, 255, 0.04);
}

.sd-empty-state {
  text-align: center;
  color: #64748b;
  padding: 24px 12px !important;
  font-style: italic;
}

.sd-download-btn {
  padding: 5px 12px;
  font-size: 0.78rem;
  background: var(--cyan);
  color: #050b14;
  font-weight: 600;
  border-radius: 4px;
  border: none;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.2s;
}

.sd-download-btn:hover {
  filter: brightness(1.15);
  box-shadow: 0 0 10px var(--cyan-glow);
}

.sd-cached-section {
  border-top: 1px solid var(--border);
  padding-top: 14px;
}

.sd-cached-section h4 {
  font-size: 0.85rem;
  color: #94a3b8;
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.sd-cached-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 120px;
  overflow-y: auto;
}

.sd-cache-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #090e17;
  padding: 6px 10px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 0.78rem;
}

.sd-cache-item span {
  color: #cbd5e1;
}

.sd-no-cache {
  color: #475569;
  font-size: 0.8rem;
  font-style: italic;
}

@media (max-width: 640px) {
  .sd-controls-grid {
    grid-template-columns: 1fr;
  }
}

/* ==================== SD INLINE VIDEO PLAYER & THUMBNAILS ==================== */
.sd-player-wrap {
  background: #090e17;
  border: 1px solid var(--cyan);
  border-radius: 8px;
  margin-bottom: 16px;
  overflow: hidden;
  box-shadow: 0 4px 24px rgba(0, 210, 255, 0.15);
  animation: fadeIn 0.25s ease-out;
}

.sd-player-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #111a28;
  padding: 8px 12px;
  border-bottom: 1px solid rgba(0, 210, 255, 0.2);
}

.sd-player-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--cyan);
  display: flex;
  align-items: center;
  gap: 6px;
}

.sd-video-box {
  position: relative;
  background: #000;
  width: 100%;
  min-height: 240px;
  max-height: 440px;
  display: flex;
  align-items: center;
  justify-content: center;
}

#sd-video-element {
  width: 100%;
  max-height: 440px;
  background: #000;
  outline: none;
  display: block;
}

.sd-player-loader {
  position: absolute;
  inset: 0;
  background: rgba(9, 14, 23, 0.88);
  backdrop-filter: blur(4px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 10;
  text-align: center;
  padding: 16px;
}

.sd-player-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #111a28;
  padding: 8px 12px;
  border-top: 1px solid var(--border);
  font-size: 0.78rem;
  color: #94a3b8;
}

.sd-thumb-box {
  position: relative;
  width: 112px;
  height: 63px;
  border-radius: 4px;
  overflow: hidden;
  background: #090e17;
  border: 1px solid rgba(255, 255, 255, 0.1);
  cursor: pointer;
  transition: transform 0.2s, border-color 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sd-thumb-box:hover {
  transform: scale(1.04);
  border-color: var(--cyan);
  box-shadow: 0 0 10px var(--cyan-glow);
}

.sd-thumb-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.sd-thumb-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.8;
  transition: opacity 0.2s;
}

.sd-thumb-box:hover .sd-thumb-overlay {
  opacity: 1;
  background: rgba(0, 0, 0, 0.15);
}

.sd-thumb-play-icon {
  width: 26px;
  height: 26px;
  background: rgba(0, 210, 255, 0.85);
  color: #090e17;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  padding-left: 2px;
  box-shadow: 0 0 8px rgba(0, 210, 255, 0.6);
}

.sd-action-group {
  display: flex;
  gap: 6px;
  align-items: center;
}

.sd-play-btn {
  padding: 5px 10px;
  font-size: 0.78rem;
  background: #0284c7;
  color: #fff;
  font-weight: 600;
  border-radius: 4px;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.2s;
}

.sd-play-btn:hover {
  background: #0369a1;
  box-shadow: 0 0 8px rgba(2, 132, 199, 0.6);
}

.sd-badge {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 600;
}

.sd-badge-cached {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.sd-badge-remote {
  background: rgba(148, 163, 184, 0.15);
  color: #94a3b8;
  border: 1px solid rgba(148, 163, 184, 0.2);
}

.sd-badge-motion {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.3);
}
