:root {
  --bg-dark: #0a0d14;
  --bg-surface: #121722;
  --bg-surface-elevated: #1a2233;
  --border-color: #1f2a3d;
  --border-hover: #2d3c58;
  
  --text-main: #f0f4f8;
  --text-muted: #8a9bb0;
  
  --accent-green: #00e676;
  --accent-cyan: #00b0ff;
  --accent-red: #ff1744;
  --accent-amber: #ffab00;
  
  --timeline-bg: #151c2b;
  --timeline-rec: rgba(0, 230, 118, 0.7);
  --timeline-rec-active: #00e676;
  
  --font-ui: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  background-color: var(--bg-dark);
  color: var(--text-main);
  font-family: var(--font-ui);
  min-height: 100vh;
  overflow-x: hidden;
  user-select: none;
}

/* Modal de Autenticación */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 13, 20, 0.85);
  backdrop-filter: blur(12px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.auth-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 32px 24px;
  width: 100%;
  max-width: 380px;
  text-align: center;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
}

.auth-logo img {
  border-radius: 16px;
  margin-bottom: 16px;
}

.auth-card h2 {
  font-size: 1.3rem;
  margin-bottom: 8px;
  font-weight: 600;
}

.auth-card p {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 24px;
}

.auth-card input {
  width: 100%;
  padding: 14px 16px;
  background: var(--bg-dark);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  color: #fff;
  font-size: 1.1rem;
  text-align: center;
  font-family: var(--font-mono);
  margin-bottom: 16px;
  outline: none;
}

.auth-card input:focus {
  border-color: var(--accent-green);
  box-shadow: 0 0 12px rgba(0, 230, 118, 0.2);
}

.auth-card button {
  width: 100%;
  padding: 14px;
  background: var(--accent-green);
  color: #0a0d14;
  font-weight: 700;
  font-size: 1rem;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s;
}

.auth-card button:hover {
  background: #00c853;
  transform: translateY(-1px);
}

.auth-error {
  color: var(--accent-red);
  margin-top: 12px;
  font-size: 0.85rem;
}

/* App Layout */
.app-layout {
  max-width: 1280px;
  margin: 0 auto;
  padding: 12px 16px 40px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Header */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 16px;
}

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

.rec-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 23, 68, 0.15);
  border: 1px solid rgba(255, 23, 68, 0.3);
  padding: 4px 10px;
  border-radius: 20px;
}

.rec-dot {
  width: 8px;
  height: 8px;
  background: var(--accent-red);
  border-radius: 50%;
  animation: pulse-rec 1.2s infinite;
}

@keyframes pulse-rec {
  0% { transform: scale(0.9); opacity: 0.4; }
  50% { transform: scale(1.3); opacity: 1; box-shadow: 0 0 8px var(--accent-red); }
  100% { transform: scale(0.9); opacity: 0.4; }
}

.rec-text {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.75rem;
  color: var(--accent-red);
  letter-spacing: 1px;
}

.brand-titles h1 {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.brand-sub {
  font-size: 0.7rem;
  color: var(--accent-cyan);
  font-weight: 600;
  letter-spacing: 1px;
}

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

.drive-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  padding: 6px 12px;
  border-radius: 12px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.drive-badge svg {
  color: var(--accent-cyan);
}

.digital-clock {
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 700;
  color: var(--accent-green);
  background: #000;
  padding: 6px 12px;
  border-radius: 10px;
  border: 1px solid rgba(0, 230, 118, 0.3);
}

/* Selector de Cámaras */
.cam-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.cam-tab {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  padding: 12px 16px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 0.95rem;
  font-weight: 600;
  transition: all 0.2s;
}

.cam-tab:hover {
  background: var(--bg-surface-elevated);
  border-color: var(--border-hover);
}

.cam-tab.active {
  background: linear-gradient(135deg, rgba(0, 176, 255, 0.15), rgba(0, 230, 118, 0.05));
  border-color: var(--accent-cyan);
  color: #fff;
  box-shadow: 0 4px 15px rgba(0, 176, 255, 0.15);
}

.cam-badge {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  background: rgba(255, 255, 255, 0.08);
  padding: 2px 6px;
  border-radius: 6px;
}

/* Controles de Fecha */
.date-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  padding: 8px 12px;
  border-radius: 14px;
}

.date-picker-wrap input {
  background: var(--bg-dark);
  border: 1px solid var(--border-color);
  color: #fff;
  padding: 6px 12px;
  border-radius: 8px;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  outline: none;
}

.btn-icon, .btn-pill {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  color: #fff;
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.2s;
}

.btn-icon:hover, .btn-pill:hover {
  background: var(--border-hover);
}

/* Monitor de Video */
.monitor-frame {
  background: #000;
  border: 1px solid var(--border-color);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.video-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
}

video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.video-hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 14px 18px;
}

.hud-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: #fff;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.9);
}

.hud-camera {
  background: rgba(0, 0, 0, 0.6);
  padding: 4px 10px;
  border-radius: 6px;
  border-left: 3px solid var(--accent-cyan);
}

.hud-time {
  background: rgba(0, 0, 0, 0.6);
  padding: 4px 10px;
  border-radius: 6px;
}

.video-spinner {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  font-size: 0.9rem;
  color: #fff;
}

.spinner-ring {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(255, 255, 255, 0.2);
  border-top-color: var(--accent-green);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* Barra de Controles del Reproductor */
.player-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--bg-surface);
  border-top: 1px solid var(--border-color);
}

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

.ctrl-btn {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  color: #fff;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
}

.ctrl-btn:hover {
  background: var(--border-hover);
}

.ctrl-btn.main-play {
  background: var(--accent-green);
  color: #000;
  font-weight: 700;
  padding: 6px 14px;
}

.pill-btn {
  font-family: var(--font-mono);
  font-weight: 700;
}

.time-label {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: #fff;
}

.time-divider {
  color: var(--text-muted);
}

/* LÍNEA DE TIEMPO INTERACTIVA (24h) */
.timeline-container {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 18px;
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.timeline-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.timeline-title {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}

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

.legend-box.recorded {
  width: 10px;
  height: 10px;
  background: var(--accent-green);
  border-radius: 2px;
}

.timeline-current-time {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--accent-cyan);
  background: var(--bg-dark);
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid var(--border-color);
}

.timeline-wrapper {
  position: relative;
  width: 100%;
}

.timeline-track {
  position: relative;
  width: 100%;
  height: 48px;
  background: var(--timeline-bg);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  cursor: pointer;
  overflow: hidden;
}

.timeline-segments {
  position: absolute;
  inset: 0;
}

.timeline-segment-block {
  position: absolute;
  top: 0;
  bottom: 0;
  background: var(--timeline-rec);
  border-right: 1px solid rgba(0, 0, 0, 0.4);
  transition: background 0.15s;
}

.timeline-segment-block:hover {
  background: var(--timeline-rec-active);
}

.timeline-segment-block.active {
  background: #00e676;
  box-shadow: inset 0 0 10px rgba(255, 255, 255, 0.5);
}

.timeline-needle {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--accent-red);
  pointer-events: none;
  z-index: 10;
  left: 0%;
  transition: left 0.1s linear;
}

.needle-head {
  position: absolute;
  top: -2px;
  left: -5px;
  width: 12px;
  height: 10px;
  background: var(--accent-red);
  clip-path: polygon(0% 0%, 100% 0%, 50% 100%);
}

.timeline-hours {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* Clips Grid */
.clips-section {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 18px;
  padding: 16px;
}

.clips-header h3 {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--text-muted);
}

.clips-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
  max-height: 240px;
  overflow-y: auto;
}

.clip-card {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  padding: 10px 14px;
  border-radius: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  transition: all 0.15s;
}

.clip-card:hover {
  border-color: var(--accent-green);
  background: rgba(0, 230, 118, 0.05);
}

.clip-card.active {
  border-color: var(--accent-green);
  background: rgba(0, 230, 118, 0.15);
}

.clip-info {
  display: flex;
  flex-direction: column;
}

.clip-time {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.85rem;
}

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

.clip-dl {
  background: none;
  border: none;
  font-size: 1.1rem;
  cursor: pointer;
  padding: 4px;
  opacity: 0.7;
}

.clip-dl:hover {
  opacity: 1;
}

.hidden {
  display: none !important;
}

/* Responsividad para Móviles */
@media (max-width: 640px) {
  .app-layout {
    padding: 8px 10px 30px;
    gap: 10px;
  }
  
  .header-brand h1 {
    font-size: 0.9rem;
  }
  
  .digital-clock {
    font-size: 0.85rem;
    padding: 4px 8px;
  }
  
  .drive-badge {
    display: none;
  }
  
  .player-controls {
    flex-wrap: wrap;
    gap: 8px;
  }
  
  .ctrl-group.center {
    order: 3;
    width: 100%;
    justify-content: center;
  }
}
